Closed zoic21 closed 1 year ago
hello @zoic21,
Sure, I can try.
I am not familiar with esphome: is the prefix always the same? has it a default value?
I will also check the documentation.
note: I cannot simply use "/state" suffix in the topic to identify esphome message. This would cause collision with other zigbee2mqtt messages, using state as a type of value (for an ON/OFF button for instance).
Hello,
Yes it's always the same. Maybe to prevent issue with zigbee2mqtt you can add an env variable that indicates root topic of zigbee2mqtt?
Thank in advance
I agree, this was exactly my intent :)
I just needed to know if there was a default value. According esphome documentation, the default seems to be the node name. If the varenv is empty, it will not enter the esphome "parsing" function.
I'll push a commit for you to test tomorrow.
Hello @zoic21,
Please let me know if the code in the branch esphome works for you.
Hello,
Thank it's work but how can I specify multiple esphome root topic. In Esphome each device create a topic in root of mqtt. For example I have 6 devices, each device have a "root" topic, ex : esp-weather-indoor/esp-weather-outdoor/....
this was my original question "is the prefix always the same?" :)
two options here:
esp-
, so you could simply set ESPHOME_TOPIC_PREFIX to esp-
The second solution would be compatible with the first one.
WDYT?
Hello,
Sorry I don't undertand "is the prefix always the same?", I think suffix... Sorry
For me second option is better, we can choose the preffix so list will be perfect. But if you can also handle esp-* it will be better.
Hello, no problem :)
I've updated the branch.
The varenv changed: ESPHOME_TOPIC_PREFIXES This is now a list: prefixes are separated by a comma.
For each prefix in the list, mqtt-exporter will check if the topic is starting by the prefix string.
For your example:
esp-weather-outdoor/sensor/temperature/state => 8.1
esp-weather-indoor/sensor/temperature/state => 20.0
you can either set: ESPHOME_TOPIC_PREFIXES="esp-"
or: ESPHOME_TOPIC_PREFIXES="esp-weather-outdoor/,esp-weather-indoor/"
or: ESPHOME_TOPIC_PREFIXES="esp-weather-outdoor,esp-weather-indoor"
etc...
Please let me know if it works for you
Hello,
Thank a lot !!!! it's perfectly works !!!! With that I can have all my mqtt data in grafana.
Thank a lot.
You are welcome :)
I'll merge that to the master branch later and it will be in the next release.
FYI it has been merged and officially released in the new v1.1.0.
Enjoy 🙂
Hello,
I have lot of esphome device and I want to transfert data from esphome to prometheus, I try mqtt-exporter but format of mqtt message of esphome is not supported, example of topic :
esp-weather-outdoor/sensor/temperature/state
=> 8.1It's like
<prefix>/<name>/sensor/temperature
(shelly) but with state at the end.Is it possible to handle that ?
Thank in advance.