jim-easterbrook / pywws

Python software for USB Wireless WeatherStations
https://pywws.readthedocs.io/
GNU General Public License v2.0
204 stars 62 forks source link

Feature request for mqtt: discovery for Home Assistant #108

Open MaxRower opened 1 year ago

MaxRower commented 1 year ago

Home Assistant won't recognize devices until there is some sort of announcement, what kind of fields to expect in the payload. Maybe this could be included in the mqtt service?

Example of one field in a Sonoff temp & humidity sensor: MQTT publish: topic 'homeassistant/sensor/0x00124b00253c5f14/temperature/config', payload '{"availability":[{"topic":"myhome/bridge/state", "value_template":"{{ value_json.state }}"}],"device":{"identifiers":["zigbee2mqtt_0x00124b00253c5f14"],"manufacturer":"SONOFF","model":"Temperature and humidity sensor (SNZB-02)","name":"Temp Sensor"},"device_class":"temperature","enabled_by_default":true,"name":"Temp Sensor temperature","state_class":"measurement","state_to pic":"myhome/Temp Sensor","unique_id":"0x00124b00253c5f14_temperature_myhome","unit_of_measurement":"°C","value_template":"{{ value_json.temperature }}"}'

Messages should be generated according to the weather.ini template_txt config.

pkerney commented 1 year ago

My guess is that you want automatic recognition like Tasmota does? I have pywws integrating with my HA, but it is very manual. I can paste my pyswws:weather.ini and my hassio:configuration.yaml if you need it. You may be able to do it with the template_txt parameter from the [mqtt] section, but I decoded it on the hassio side as I didn't want to break some other platforms I have setup.