fix: devicecheck biznis logika

This commit is contained in:
2026-02-05 19:51:49 +01:00
parent e060a9e8f8
commit 3f6e8a0808
4 changed files with 197 additions and 17 deletions

59
API.md
View File

@@ -140,10 +140,10 @@ Retrieve all devices in the system (public read access).
```
**Status IDs**:
- `1`: OK/Online
- `2`: Warning
- `3`: Error
- `4`: Offline
- `1`: ok
- `2`: pending
- `3`: lost
- `4`: disabled
---
@@ -840,6 +840,57 @@ Devices can announce themselves by publishing to the discovery topic:
---
### Device Check (State Polling)
The server periodically publishes device check requests to the main MQTT topic and
expects devices to respond on the same topic.
**Topic**: `{configured_mqtt_topic}`
**Request Message Published**:
```json
{
"type": "device_check_request",
"device_id": "uuid",
"requested_at": "2026-01-14T10:00:00Z"
}
```
**Expected Device Response**:
```json
{
"type": "device_check_response",
"device_id": "uuid",
"status": "ok" | "lost" | "pending"
}
```
---
### Sensor Readings via MQTT
Devices can publish sensor readings directly to the main MQTT topic. The server
stores readings only if the `sensor_id` exists in the database.
**Topic**: `{configured_mqtt_topic}`
**Message Format**:
```json
{
"type": "sensor_reading",
"sensor_id": "uuid",
"value": 23.7,
"value_at": "2026-01-14T10:00:00Z"
}
```
**Notes**:
- `type` may also be `sensor_value`.
- `value` may be a number, boolean, or numeric string (e.g., "1", "0", "23.7").
- `value_at` is optional; if omitted, the server uses the current time.
---
## Error Responses
All endpoints may return the following standard error responses: