From 25caea841b2270c807ff198ccd7bb9878e1c6228 Mon Sep 17 00:00:00 2001 From: Travis Shears Date: Sat, 12 Apr 2025 19:35:36 +0200 Subject: [PATCH] create node1 entity in home assistant --- README.md | 33 ++++++++++++++++++++++ node1.json | 58 ++++++++++++++++++++++++++++++++++++++ node1_payload_example.json | 8 ++++++ notes.txt | 41 --------------------------- 4 files changed, 99 insertions(+), 41 deletions(-) create mode 100644 node1.json create mode 100644 node1_payload_example.json delete mode 100644 notes.txt diff --git a/README.md b/README.md index 5ab6d8e..3518286 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,13 @@ Weatherproof Enclosure: [weatherproof-cover-for-outdoor-sensors](https://shop.pi _Note: I would not recommend buying from pimoroni from EU as shipping tax is huge!_ +## Helpful links + +- [pico mqtt Example](https://github.com/raspberrypi/pico-examples/blob/master/pico_w/wifi/mqtt/README) +- [pico pinout](https://pico.pinout.xyz/) +- [home assistant mqtt guide](https://www.home-assistant.io/integrations/mqtt/#testing-your-setup) +- [home assistant device classes](https://www.home-assistant.io/integrations/sensor/#device-class) + ## Dev ### Env Setup @@ -124,3 +131,29 @@ Restarting the program: ```shell (lldb) process plugin packet monitor reset run ``` + +### Home assistant debugging + +#### Subscribe to a topic + +```shell +$ TOPIC=zigbee2mqtt/0xa4c13848a46ea1cf; mosquitto_sub -h 192.168.1.11 -t $TOPIC -u homeassistant -P xxx +``` + +#### Send message + +Config example: + +```shell +$ mosquitto_pub -h 192.168.1.11 -P xxxxxxxx \ +-u homeassistant -t homeassistant/device/bws/node1_001/config \ +-f node1.json -r +``` + +Payload example: + +```shell +$ mosquitto_pub -h 192.168.1.11 -P xxxxxxxx \ +-u homeassistant -t bws/node1/state \ +-f node1_payload_example.json +``` diff --git a/node1.json b/node1.json new file mode 100644 index 0000000..f2febb4 --- /dev/null +++ b/node1.json @@ -0,0 +1,58 @@ +{ + "dev": { + "ids": "bws_node1_001", + "name": "Node1", + "mf": "diy", + "sw": "1.0", + "hw": "1.0" + }, + "cmps": { + "node1_temp": { + "p": "sensor", + "device_class": "temperature", + "unit_of_measurement": "°C", + "value_template": "{{ value_json.temperature}}", + "unique_id": "bws_node1_temp_001" + }, + "node1_humidity": { + "p": "sensor", + "device_class": "humidity", + "unit_of_measurement": "%", + "value_template": "{{ value_json.humidity}}", + "unique_id": "bws_node1_humidity_001" + }, + "node1_pressure": { + "p": "sensor", + "device_class": "atmospheric_pressure", + "unit_of_measurement": "hPa", + "value_template": "{{ value_json.pressure}}", + "unique_id": "bws_node1_pressure_001" + }, + "node1_pm1": { + "p": "sensor", + "device_class": "pm1", + "unit_of_measurement": "µg/m³", + "value_template": "{{ value_json.pm1}}", + "unique_id": "bws_node1_pm1_001" + }, + "node1_pm25": { + "p": "sensor", + "device_class": "pm25", + "unit_of_measurement": "µg/m³", + "value_template": "{{ value_json.pm25}}", + "unique_id": "bws_node1_pm25_001" + }, + "node1_pm10": { + "p": "sensor", + "device_class": "pm10", + "unit_of_measurement": "µg/m³", + "value_template": "{{ value_json.pm10}}", + "unique_id": "bws_node1_pm10_001" + } + }, + "o": { + "name": "diy_pico_w" + }, + "state_topic": "bws/node1/state", + "qos": 1 +} diff --git a/node1_payload_example.json b/node1_payload_example.json new file mode 100644 index 0000000..d1abd57 --- /dev/null +++ b/node1_payload_example.json @@ -0,0 +1,8 @@ +{ + "temperature": 15.2, + "humidity": 58, + "pressure": 945.5, + "pm1": 7, + "pm25": 7, + "pm10": 7 +} diff --git a/notes.txt b/notes.txt deleted file mode 100644 index 4b24de6..0000000 --- a/notes.txt +++ /dev/null @@ -1,41 +0,0 @@ - -## Helpful links -- https://docs.circuitpython.org/projects/minimqtt/en/latest/examples.html -- [how to use settings.toml](https://learn.adafruit.com/circuitpython-octoprint-controller-and-monitor/create-your-settings-toml-file) -- [adafruit-circuitpython-esp32spi docs](https://docs.circuitpython.org/projects/esp32spi/en/latest/) -- [pico pinout](https://pico.pinout.xyz/) -- [home assistant mqtt guide](https://www.home-assistant.io/integrations/mqtt/#testing-your-setup) -- [home assistant device classes](https://www.home-assistant.io/integrations/sensor/#device-class) - -## Home assistant debugging - -homeassistant/sensor/balcony_weather_station/test_bme_280 -homeassistant/sensor/balcony_weather_station/test_bme_280 -{ - "name": "BEM 280 Temperature", - "device_class": "temperature", - "unit_of_measurement": "°C", - "value_template": "{{ value_json.temperature}}", - "state_topic": "homeassistant/sensor/balcony_weather_station/test_bme_280/state", - "unique_id": "balcony_weather_station_bme_280_test_temperature", - "device": { - "identifiers": "balcony_weather_station_001", - "name": "Balcony Weather Station" - } -} - -homeassistant/sensor/balcony_weather_station/test_bme_280/state -{ "temperature": 23.20, "humidity": 50 } - -{ - "name": "BEM 280 Humidity", - "device_class": "humidity", - "unit_of_measurement": "%", - "value_template": "{{ value_json.humidity}}", - "state_topic": "homeassistant/sensor/balcony_weather_station/test_bme_280/state", - "unique_id": "balcony_weather_station_bme_280_test_humidity", - "device": { - "identifiers": "balcony_weather_station_001", - "name": "Balcony Weather Station" - } -}