mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
MQTT docs and presence sensor type #664
This commit is contained in:
@@ -1,13 +1,189 @@
|
||||
## Overview
|
||||
# Overview
|
||||
|
||||
- Feed your data and device changes into [Home Assistant](https://github.com/jokob-sk/NetAlertX/blob/main/docs/HOME_ASSISTANT.md) via the MQTT Mosquito broker. (other brokers might work as well)
|
||||
- Feed your data and device changes into [Home Assistant](https://github.com/jokob-sk/NetAlertX/blob/main/docs/HOME_ASSISTANT.md) via the MQTT Mosquito broker (other brokers might work as well).
|
||||
|
||||
### Usage
|
||||
# Usage
|
||||
|
||||
- Go to settings and fill in relevant details.
|
||||
- Go to settings and fill in relevant details. There are 2 types of "devices" generated and sent to the broker. A generic overview device that contains online/down/archived device stats and then the actual devices detected by the application.
|
||||
|
||||
|
||||
### Notes
|
||||
|
||||
# Sample Payloads
|
||||
|
||||
## Overview device
|
||||
|
||||
The below payloads apply to the device showing overall online/down/archived stats. You can toggle them on/off with the `SEND_STATS` setting.
|
||||
|
||||
### MQTT discovery data:
|
||||
|
||||
>[!NOTE]
|
||||
> You can replace the `netalertx` string of the below topic via the `DEVICE_ID` setting.
|
||||
|
||||
Topic: `homeassistant/sensor/netalertx/online/config`
|
||||
|
||||
|
||||
>[!NOTE]
|
||||
> You can replace the `"name": "NetAlertX"` string of the below payload via the `DEVICE_NAME` setting.
|
||||
|
||||
Payload:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "online",
|
||||
"state_topic": "system-sensors/sensor/netalertx/state",
|
||||
"value_template": "{{value_json.online}}",
|
||||
"unique_id": "netalertx_sensor_online",
|
||||
"device": {
|
||||
"identifiers": [
|
||||
"netalertx_sensor"
|
||||
],
|
||||
"manufacturer": "NetAlertX",
|
||||
"name": "NetAlertX"
|
||||
},
|
||||
"icon": "mdi:wifi-check",
|
||||
"platform": "mqtt"
|
||||
}
|
||||
```
|
||||
|
||||
### MQTT config data sample:
|
||||
|
||||
>[!NOTE]
|
||||
> You can replace the `netalertx` string of the below topic via the `DEVICE_ID` setting.
|
||||
|
||||
Topic: `homeassistant/sensor/netalertx/all/config`
|
||||
|
||||
Payload:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "all",
|
||||
"state_topic": "system-sensors/sensor/netalertx/state",
|
||||
"value_template": "{{value_json.all}}",
|
||||
"unique_id": "netalertx_sensor_all",
|
||||
"device": {
|
||||
"identifiers": [
|
||||
"netalertx_sensor"
|
||||
],
|
||||
"manufacturer": "NetAlertX",
|
||||
"name": "NetAlertX"
|
||||
},
|
||||
"icon": "mdi:wifi",
|
||||
"platform": "mqtt"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### MQTT state data:
|
||||
|
||||
>[!NOTE]
|
||||
> You can replace the `netalertx` string of the below topic via the `DEVICE_ID` setting.
|
||||
|
||||
Topic: `system-sensors/sensor/netalertx/state`
|
||||
|
||||
Payload:
|
||||
|
||||
```json
|
||||
{
|
||||
"online": 30,
|
||||
"down": 36,
|
||||
"all": 66,
|
||||
"archived": 0,
|
||||
"new": 0,
|
||||
"unknown": 0
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Individual devices
|
||||
|
||||
The below payloads apply to individual devices. Every device discovered by the application will generate the below messages. You can toggle them on/off with the `SEND_DEVICES` setting.
|
||||
|
||||
### MQTT discovery data:
|
||||
|
||||
Topic: `homeassistant/sensor/mac_44_ef_44_ef_44_ef/last_ip/config`
|
||||
|
||||
Payload:
|
||||
|
||||
```json
|
||||
|
||||
{
|
||||
"name": "last_ip",
|
||||
"state_topic": "system-sensors/sensor/mac_44_ef_44_ef_44_ef/state",
|
||||
"value_template": "{{value_json.last_ip}}",
|
||||
"unique_id": "mac_44_ef_44_ef_44_ef_sensor_last_ip",
|
||||
"device": {
|
||||
"identifiers": [
|
||||
"mac_44_ef_44_ef_44_ef_sensor"
|
||||
],
|
||||
"manufacturer": "NetAlertX",
|
||||
"name": "Camera - E1"
|
||||
},
|
||||
"icon": "mdi:ip-network",
|
||||
"platform": "mqtt"
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### MQTT state data:
|
||||
|
||||
Topic: `system-sensors/sensor/mac_44_ef_44_ef_44_ef/state`
|
||||
|
||||
Payload:
|
||||
|
||||
```json
|
||||
{
|
||||
"last_ip": "192.168.1.33",
|
||||
"is_new": "0",
|
||||
"vendor": "None",
|
||||
"mac_address": "44:ef:44:ef:44:ef"
|
||||
}
|
||||
```
|
||||
|
||||
### Transmitted message examples:
|
||||
|
||||
Topic: `homeassistant/binary_sensor/mac_44_ef_44_ef_44_ef/is_present/`
|
||||
|
||||
Payload:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "is_present",
|
||||
"state_topic": "system-sensors/binary_sensor/mac_44_ef_44_ef_44_ef/state",
|
||||
"value_template": "{{value_json.is_present}}",
|
||||
"unique_id": "mac_44_ef_44_ef_44_ef_sensor_is_present",
|
||||
"device": {
|
||||
"identifiers": [
|
||||
"mac_44_ef_44_ef_44_ef_sensor"
|
||||
],
|
||||
"manufacturer": "NetAlertX",
|
||||
"name": "Camera - E1"
|
||||
},
|
||||
"icon": "mdi:wifi",
|
||||
"platform": "mqtt"
|
||||
}
|
||||
```
|
||||
|
||||
Topic: `system-sensors/binary_sensor/mac_44_ef_44_ef_44_ef/state`
|
||||
|
||||
Payload:
|
||||
|
||||
```json
|
||||
{
|
||||
"is_present": "OFF"
|
||||
}
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"is_present": "ON"
|
||||
}
|
||||
```
|
||||
|
||||
>[!WARNING]
|
||||
> Please check your Home Assistant MQTT broker debug info for the most up-to-date data nad format as the above might be outdated.
|
||||
|
||||
|
||||
## Implementation Notes
|
||||
|
||||
The first run will take a while, subsequent should be much faster because new sensors don't have to be created anymore. If the first sync times out, try to increase the timeout setting (default: 10s per device). A bit of background:
|
||||
|
||||
@@ -22,5 +198,3 @@ The first run will take a while, subsequent should be much faster because new se
|
||||
|
||||
|
||||
The state is managed differently, the state of the sensor is not included in the hash. This might be improved upon in later releases.
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user