Hi,
This is probably not strictly a esphome question/problem.
When I configure sensors in esphome and mqtt (on one device), homeassistant is creating two entities.
In the “past” they where sensor.<device>_<sensor_name>_mqtt and sensor.<device>_<sensor_name>
.
But once in a while something happens and the mqtt one get renamed to sensor.<device>_<sensor_name>_2
.
And when that happens all my templates are not working anymore.
Also I have 6 identical devices with identical config, but the error seems to pick only a (one?)few of the devices.
My current guess is that this is because of the home assistant auto discovery of mqtt sensors which (i assume) esphome is using by default. That being said, I mean the part of software that decides what the post-fix will be, is the discovery in home assistant.
But is there a way of setting something up in esphome device config that will make the entity name more reliable? (Also preferable, only on selected devices and not for all mqtt sensors there are.)
I can define a unique entity id for a sensor, but than this will be the same for the Native-Api one and the MQTT one (as I understand it). There seems to be no option that affects only one of them.
What is the default solution? Renaming the whole device in the mqtt-section (e.g. topic_prefix)?
regards Frank
which is esphome internal only
Can’t really help you with MQTT because I turned my broker off years ago (and since them have pure joy with the almost setup native api) but AFAIK the names derivative from the name
variable
Use the native api OR mqtt I guess? Why are you using both in parallel?
That might work…
Thanks for the ideas orange-assistant.
Actually, I questioned myself as well on why I have both enabled. I’m using deep sleep on the devices and have “don’t go to deepsleep” topics to enable firmware updates via esphome wifi connection.
Also “in the past” the availability of reported values (by Native-API) and MQTT where different, so the templates only worked on MQTT when the device was sleeping. (Can’t remember exactly, I think if the device is unreachable all “native values” will get set invalid or something along those lines).
I think I will setup a additional device of these sensors and will start from scratch with a new config. The world did go on, there should be a new approach.
Indeed.
If I remember right the native api got some improvements in the past and is was stated that it should be around as performant as mqtt by now as HA will immediately connect to a esphome node ones it announced it existence via mDNS.
Also you could use the native api the same as mqtt to have a esphome node “stay awake” for an update. Just create an helper in HA and read the state in esphome node so it can act acordignly
Afaik that behavior should not happen when you have deep_sleep
in your config. But without deep sleep the default is indeed that that all sensors go to unavailable
when a esphome node disconnects from HA