matthias-bs / BresserWeatherSensorReceiver

Bresser 5-in-1/6-in-1/7-in-1 868 MHz Weather Sensor Radio Receiver for Arduino based on CC1101, SX1276/RFM95W or SX1262
MIT License
100 stars 21 forks source link

Mqtt auto discovery for Home Assistant #157

Open Shadowpost opened 2 months ago

Shadowpost commented 2 months ago

After a number of hours fiddling, I managed to get the sketch working on my ESP8266 and I can recieve data from my weather station. However, this is not formatted and in Home Assistant, I see it as a string of multiple values.

A solution would be a few lines of code that make the data visible for Home Assistant through MQTT auto discovery.

An alternative could be to edit the config.yaml, but I'm not sure how.

Any help will be appreciated!

matthias-bs commented 2 months ago

Hi,

this makes sense. I found the following: https://www.home-assistant.io/integrations/mqtt/#mqtt-discovery If you can provide a JSON file, I will take care of integrating it into the software.

Otherwise I will not take care of this topic anytime soon.

Shadowpost commented 2 months ago

Thanks for responding!

I've spent the afternoon adding the sensors in configuration.yaml for each entity in the mqtt message.

This works now and it shows up in Home Assistant as 1 device with all the sensors.

Screenshot_20240422-223024_Home Assistant

I'm happy how this worked out. You don't need to integrate it for me in particular. For future users, the auto-discovery would make this project a lot more user friendly. :)

Cheers!

matthias-bs commented 2 months ago

Good job! May I ask you to share the configuration.yaml file here for others and maybe as a base for the auto discovery?

Shadowpost commented 2 months ago

Will do. May take a few days. ;)

-------- Oorspronkelijk bericht -------- Van: Matthias Prinke @.> Datum: 22-04-2024 22:47 (GMT+01:00) Aan: matthias-bs/BresserWeatherSensorReceiver @.> Cc: Shadowpost @.>, State change @.> Onderwerp: Re: [matthias-bs/BresserWeatherSensorReceiver] Mqtt auto discovery for Home Assistant (Issue #157)

Good job! May I ask you to share the configuration.yaml file here for others and maybe as a base for the auto discovery?

— Reply to this email directly, view it on GitHubhttps://github.com/matthias-bs/BresserWeatherSensorReceiver/issues/157#issuecomment-2070924693, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BCHT4GUJHRXDABGRP2BN3T3Y6VZNFAVCNFSM6AAAAABGSJBMV2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZQHEZDINRZGM. You are receiving this because you modified the open/close state.Message ID: @.***>

Shadowpost commented 2 months ago

Here is the code I've added to my configuration.yaml in Home Assistant:

mqtt: sensor:

matthias-bs commented 2 months ago

Thanks for providing your configuration! The formatting has been lost by pasting it into the comment. May I ask you to add it again as an attachment or enclosed in three backticks (see https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#quoting-code)?

Shadowpost commented 2 months ago

Bresser HA MQTT custom config.txt I hope this works better. Adding a code directly here is pretty sh*tty...

matthias-bs commented 2 months ago

@Shadowpost Thanks again!

Reposted with formatting:

mqtt:
  sensor:
    - name: "Temperatuur"
      unique_id: "Bresstat_temp"
      state_topic: "ESPWeather/961c/data"
      value_template: "{{ value_json.temp_c }}"
      device_class: "temperature"
      unit_of_measurement: "°C"
      device:
        name: "Weerstation"
        identifiers: "Bresser"
        manufacturer: "Chris"
        model: "Bresser MQTT"
    - name: "Dauwpunt"
      unique_id: "Bresstat_dew"
      state_topic: "ESPWeather/extra"
      value_template: "{{ value_json.dewpoint_c }}"
      device_class: "Temperature"
      unit_of_measurement: "°C"
      device:
        name: "Weerstation"
        identifiers: "Bresser"
        manufacturer: "Chris"
        model: "Bresser MQTT"
    - name: "Gevoelstemperatuur"
      unique_id: "Bresstat_feel"
      state_topic: "ESPWeather/extra"
      value_template: "{{ value_json.perceived_temp_c }}"
      device_class: "Temperature"
      unit_of_measurement: "°C"
      device:
        name: "Weerstation"
        identifiers: "Bresser"
        manufacturer: "Chris"
        model: "Bresser MQTT"
    - name: "Luchtvochtigheid"
      unique_id: "Bresstat_humi"
      state_topic: "ESPWeather/961c/data"
      value_template: "{{ value_json.humidity }}"
      device_class: "humidity"
      unit_of_measurement: "%"
      device:
        name: "Weerstation"
        identifiers: "Bresser"
        manufacturer: "Chris"
        model: "Bresser MQTT"
    - name: "ID"
      unique_id: "Bresstat_id"
      state_topic: "ESPWeather/961c/data"
      value_template: "{{ value_json.id }}"
      device:
        name: "Weerstation"
        identifiers: "Bresser"
        manufacturer: "Chris"
        model: "Bresser MQTT"
    - name: "Kanaal"
      unique_id: "Bresstat_ch"
      state_topic: "ESPWeather/961c/data"
      value_template: "{{ value_json.ch }}"
      device:
        name: "Weerstation"
        identifiers: "Bresser"
        manufacturer: "Chris"
        model: "Bresser MQTT"
    - name: "Batterij"
      unique_id: "Bresstat_batt"
      state_topic: "ESPWeather/961c/data"
      value_template: "{{ value_json.battery_ok }}"
      device:
        name: "Weerstation"
        identifiers: "Bresser"
        manufacturer: "Chris"
        model: "Bresser MQTT"
    - name: "Windvlaag"
      unique_id: "Bresstat_gust"
      state_topic: "ESPWeather/961c/data"
      value_template: "{{ value_json.wind_gust }}"
      device_class: "wind_speed"
      unit_of_measurement: "km/h"
      device:
        name: "Weerstation"
        identifiers: "Bresser"
        manufacturer: "Chris"
        model: "Bresser MQTT"
    - name: "Windsnelheid"
      unique_id: "Bresstat_wind"
      state_topic: "ESPWeather/961c/data"
      value_template: "{{ value_json.wind_avg }}"
      device_class: "wind_speed"
      unit_of_measurement: "km/h"
      device:
        name: "Weerstation"
        identifiers: "Bresser"
        manufacturer: "Chris"
        model: "Bresser MQTT"
    - name: "Windhoek"
      unique_id: "Bresstat_dirdeg"
      state_topic: "ESPWeather/961c/data"
      value_template: "{{ value_json.wind_dir }}"
      unit_of_measurement: "Graden"
      device:
        name: "Weerstation"
        identifiers: "Bresser"
        manufacturer: "Chris"
        model: "Bresser MQTT"
    - name: "Windrichting"
      unique_id: "Bresstat_dircar"
      state_topic: "ESPWeather/extra"
      value_template: "{{ value_json.wind_dir_txt }}"
      device:
        name: "Weerstation"
        identifiers: "Bresser"
        manufacturer: "Chris"
        model: "Bresser MQTT"
    - name: "Windvlaag bft"
      unique_id: "Bresstat_gust_bft"
      state_topic: "ESPWeather/extra"
      value_template: "{{ value_json.wind_gust_bft }}"
      device_class: "wind_speed"
      unit_of_measurement: "Beaufort"
      device:
        name: "Weerstation"
        identifiers: "Bresser"
        manufacturer: "Chris"
        model: "Bresser MQTT"
    - name: "Windsnelheid bft"
      unique_id: "Bresstat_avg_bft"
      state_topic: "ESPWeather/extra"
      value_template: "{{ value_json.wind_avg_bft }}"
      device_class: "wind_speed"
      unit_of_measurement: "Beaufort"
      device:
        name: "Weerstation"
        identifiers: "Bresser"
        manufacturer: "Chris"
        model: "Bresser MQTT"
    - name: "UV-index"
      unique_id: "Bresstat_UV"
      state_topic: "ESPWeather/961c/data"
      value_template: "{{ value_json.uv }}"
      device:
        name: "Weerstation"
        identifiers: "Bresser"
        manufacturer: "Chris"
        model: "Bresser MQTT"
    - name: "Lichtintensiteit"
      unique_id: "Bresstat_light"
      state_topic: "ESPWeather/961c/data"
      value_template: "{{ value_json.wind_gust }}"
      unit_of_measurement: "kLux"
      device:
        name: "Weerstation"
        identifiers: "Bresser"
        manufacturer: "Chris"
        model: "Bresser MQTT"
    - name: "Neerslag totaal"
      unique_id: "Bresstat_rain"
      state_topic: "ESPWeather/961c/data"
      value_template: "{{ value_json.rain }}"
      device_class: "precipitation"
      unit_of_measurement: "mm"
      device:
        name: "Weerstation"
        identifiers: "Bresser"
        manufacturer: "Chris"
        model: "Bresser MQTT"
    - name: "Neerslag vandaag"
      unique_id: "Bresstat_rain_d"
      state_topic: "ESPWeather/961c/data"
      value_template: "{{ value_json.rain_d }}"
      device_class: "precipitation"
      unit_of_measurement: "mm"
      device:
        name: "Weerstation"
        identifiers: "Bresser"
        manufacturer: "Chris"
        model: "Bresser MQTT"
    - name: "Neerslag laatste uur"
      unique_id: "Bresstat_rain_h"
      state_topic: "ESPWeather/961c/data"
      value_template: "{{ value_json.rain_h }}"
      device_class: "precipitation"
      unit_of_measurement: "mm"
      device:
        name: "Weerstation"
        identifiers: "Bresser"
        manufacturer: "Chris"
        model: "Bresser MQTT"
    - name: "Neerslag deze week"
      unique_id: "Bresstat_rain_w"
      state_topic: "ESPWeather/961c/data"
      value_template: "{{ value_json.rain_w }}"
      device_class: "precipitation"
      unit_of_measurement: "mm"
      device:
        name: "Weerstation"
        identifiers: "Bresser"
        manufacturer: "Chris"
        model: "Bresser MQTT"
    - name: "Neerslag deze maand"
      unique_id: "Bresstat_rain_m"
      state_topic: "ESPWeather/961c/data"
      value_template: "{{ value_json.rain_m }}"
      device_class: "precipitation"
      unit_of_measurement: "mm"
      device:
        name: "Weerstation"
        identifiers: "Bresser"
        manufacturer: "Chris"
        model: "Bresser MQTT"
    - name: "Signaal"
      unique_id: "Bresstat_signal"
      state_topic: "ESPWeather/961c/rssi"
      device_class: "signal_strength"
      unit_of_measurement: "dB"
      device:
        name: "Weerstation"
        identifiers: "Bresser"
        manufacturer: "Chris"
        model: "Bresser MQTT"
    - name: "Status"
      unique_id: "Bresstat_stat"
      state_topic: "ESPWeather/status"
      device:
        name: "Weerstation"
        identifiers: "Bresser"
        manufacturer: "Chris"
        model: "Bresser MQTT"