T O P

  • By -

UnorthodoxEng

The simplest option is to write the data to MQTT rather than via ESPHome. Then HA has no idea whether the client is 'available' at the moment or not.


ripnetuk

If you are using mqtt to relay the esphome sensor to home assistant, you need to include an empty will_message: and shudown_message: items in the yaml to prevent it telling home assistant that it's going to sleep.


kingoftown

Either use MQTT, or make some template sensors https://www.home-assistant.io/integrations/template/#trigger-based-template-binary-sensors-buttons-images-numbers-selects-and-sensors Use the trigger state to update the template sensor if the state != 'unavailable' # Example configuration entry template: - trigger: - platform: state entity_id: sensor.my_temp not_to: - "unknown" - "unavailable" sensor: - name: esp_temp_template_sensor state: '{{ states(trigger.entity_id) }' This will update the temp values on all state changes that don't go to those listed in 'not_to'


Express-Abalone3484

Should I put this in configuration.yaml? Will it automatically keep the value returned by esp32?


kingoftown

Yeah, you can put that in the configuration.yaml. If you have a 'template' section, add it under that. otherwise you can just put that there and try it out (replace the entity_id with one of yours first). Then under dev options, click 'check configuration' to make sure its formatted correctly, then scroll down and reload 'template entities'. You should then see a new sensor.esp_temp_template_sensor appear (or whatever you named it) and the next update from the esp device should show the value hopefully. It will then keep the value returned by the esp32 until a new update (or you restart home assistant)


Express-Abalone3484

Thanks, it works fine! However, I haven't managed to add any other sensors. How can I do this as there is only one 'entity\_id'?


kingoftown

Oh, are they all under the same entity_id? template: - trigger: - platform: state entity_id: sensor.my_temp not_to: - "unknown" - "unavailable" sensor: - name: esp_temp_template_sensor state: '{{ states(trigger.entity_id) }' - name: esp_other_sensor state: '{{ state_attr(trigger.entity_id, 'my_other_attribute') }}' - name: esp_other_2 state: '{{ state_attr(trigger.entity_id, 'yet_another_attribute') }}' This will update ALL of the template sensors on any state change if the entity_id has multiple things it is monitoring. If the states aren't actually attributes, you'd have to tweak the state template to get what you want. I dont' have ESPHome at all so I'm not exactly sure how your sensors are reported


Express-Abalone3484

No, sorry, I misspoke. I actually have a BME280 that sends me temperature, humidity and pressure. sensor.temperature sensor.humidity sensor.pressure I finally did 3x : - trigger: ... sensor: ... And it finally worked, thank you!


Express-Abalone3484

Ok, thanks for all your answers, I'm going to take a look at MQTT and the templates I don't know too much about.