Sonic local API (2024.2.1)
This is the API hosted on Sonic allowing to manage the device and retrieve collected data. Available endpoints allow to:
- Get device state
- Get/change valve state
- Get telemetry data
- Get power supply status
- Get/change networking status
- Get auto shut-off settings
- Get auto shut-off report
- Execute a command (reboot)
- Get/set webhook URL
Whenever unknown request is received, API returns a 404 Not Found response.
If a webhook is configured, the device will send PUT requests for the following events: "auto-shut-off-report", "telemetry", "valve", "power-supply-changed", "wifi-changed" and "online".
telemetry
Message sent when new telemetry data was collected.
Label | Unit |
---|---|
Flow | ml/min |
Pressure | mbar |
Temperature | °C |
Event volume | ml |
Event duration | s |
{
"type": "telemetry",
"data":
{
"flow": integer,
"pressure": integer,
"temperature": integer,
"event": { "volume": integer, "duration": integer },
"errors": ["flow"/"pressure"/"temperature"],
},
}
valve
Message sent when the valve state changes.
{
"type": "valve",
"data": {
"state": "open"/"closed"/"opening"/"closing/unknown"
}
}
power-supply-changed
Message sent when the power supply status changes.
{
"type": "power-supply-changed",
"data": {
"supply": "battery"/"external"/"external+battery"
]
}
}
auto-shut-off-report
Message sent when the auto shut-off module gets triggered due to detecting a potential leak.
Label | Unit |
---|---|
Volume | ml |
Duration | s |
Timestamp | ms |
{
"type": "auto-shut-off-report",
"data":
{
"type": ["VOLUME_THRESHOLD"/"DURATION_THRESHOLD"],
"volume": integer,
"duration": integer,
"timestamp": integer,
},
}
Get device state
Retrieve specified information from the device: valve state, water flow indicator, MQTT and Wi-Fi connection status, power supply, firmware version, water meter data, and device uptime.
Label | Unit |
---|---|
Water meter volume | L |
Water meter duration | min |
Uptime | s |
Responses
Response samples
- 200
{- "valveState": "closed",
- "waterFlowing": false,
- "mqttConnected": true,
- "wifiConnected": true,
- "powerSupply": "external",
- "firmwareVersion": "2024.1.0",
- "serialNumber": "abcdef1234567890",
- "waterMeter": {
- "positive": {
- "volume": 567820,
- "duration": 3908
}, - "negative": {
- "volume": 567820,
- "duration": 3908
}
}, - "uptime": 1024560
}
Set valve state
Request the change of the valve state. If the valve is already in the desired state, its position won't change.
Request Body schema: application/vnd.wtg.local.valve-change.v1+jsonrequired
state | string Default: "close" Enum: "open" "close" |
Responses
Request samples
- Payload
{- "state": "open"
}
Get telemetry data
Retrieve sensors readings from the device. This includes: flow rate, pressure, water temperature, ongoing event data and potential errors. When an error is detected, the corresponding value is excluded from the payload. When water is not flowing, the event data is excluded from the payload.
Label | Unit |
---|---|
Flow rate | ml/min |
Pressure | mbar |
Water temperature | °C |
Event volume | ml |
Event duration | s |
Responses
Response samples
- 200
{- "flow": 6800,
- "pressure": 2320,
- "temperature": 0,
- "event": {
- "volume": 16000,
- "duration": 90
}, - "errors": [
- [
- "flow",
- "pressure"
]
]
}
Get power status
Retrieve the power status of the device. When the device is running only on external power supply, the battery voltage is excluded from the payload.
Label | Unit |
---|---|
Battery voltage | mV |
Responses
Response samples
- 200
{- "battery": false,
- "external": true,
- "batteriesVoltage": 6800
}
Get networking status
Retrieve the networking status of the device.
Label | Unit |
---|---|
RSSI | dBm |
Wi-Fi uptime | ms |
MQTT uptime | ms |
Responses
Response samples
- 200
{- "mqttConnected": true,
- "wifiConnected": true,
- "ip": "192.168.21.37",
- "gateway": "192.168.1.0",
- "subnet": "192.168.1.0/24",
- "ssid": "MyWi-Fi",
- "rssi": -45,
- "wifiUpTime": 1024560,
- "mqttUpTime": 1023450
}
Update networking configuration
Update the networking configuration of the system.
Request Body schema: application/vnd.wtg.local.network-change.v1+jsonrequired
ssid | string SSID of the Wi-Fi network to connect. |
password | string Password of the Wi-Fi network to connect. |
Responses
Request samples
- Payload
{- "ssid": "MyWi-Fi",
- "password": "password"
}
Execute a command
Execute a specific command on the device.
Command | Description |
---|---|
reboot | Software reboot of the device |
Request Body schema: application/vnd.wtg.local.command.v1+jsonrequired
type | string Value: "reboot" Type of the command to execute. |
Responses
Request samples
- Payload
{- "type": "reboot"
}
Response samples
- 200