Hi All, I am very new to HA, so I’m not sure if this is the correct forum / category for my questions. I have created some ESP32 hardware that is publishing to mqtt in raw text data, not using json. I have added a sensor card to the dashboard but cannot get any connection to the mqtt broker. I add a sensor in config.yaml as below
It should be something like :
Bills_Mesh/master/tank2/level 75.0
char tempString[8];
dtostrf(incomingReadings.float1, 1, 2, tempString);
reconnect_mqtt(); // Reconnect if we have lost connection to broker
client.publish(incomingReadings.topic, tempString); // topic, payload
Well that is not particularly helpful. we were after an example of an actual post to Bills_Mesh/master/tank2/level. But if it is a simple string, what @robertklep said!
Thanks Robertklep, I had seen that example before. Maybe I don’t need any value_template. But I can’t seem to get any data from the mqtt broker in HA. I get “unknown” for the sensor, or Entity is non-numeric".
As the publishing happens within the publish command of pubsubclient the topic and payload are separated and so the payload is simply a float value converted to a string and the topic is “Bills_Mesh etc”. The mqtt explorer shows the value coming in fine. I don’t know exactly what to put into my config.yaml to have the sensor card recognize it.
Thanks again for the help
So if I don’t need a value template, then is it that this template simply parses my data if I need to transform it in some way, and my problem is somewhere else. I don’t seem to be getting the data from the mqtt broker.
Correct, I don’t yet know how to format the code in this forum, but it is indented correctly I believe. from name to value_template it is indented 2 more spaces
The tank level data is published to the mqtt as a string, “75.00” for example. Is it possible that for the sensor to recognize it I need to convert it back to a float or int, and if so, how?
thanks Tom , sorry I can’t get back to this until sunday, but i think i need to look at the sensor card that i added, maybe something is wrong there. i will post some info about that when i can get back to it. Thanks again.
Hi Tom and others. I managed to get one sensor display to work since yesterday, The available entities in the entities list when I go to add a sensor seem to be completely different to anything I have added in my config.yaml file. Below is the yaml file.
As you can see the unique_id is tank2_pump_state, tank_2_level, tank2_level, tank2_temperature and tank2_humidity.
The list of available entities in the drop down list when adding a new sensor card is sensor.tank_2, sensor.tank_2_2, sensor.temperature and sensor.humidity.
I have added sensors for these and the tank_2 is the only one that works, the tank_2_2 and humidity and temperature do not work. and I have added sensors for sensor.tank_2_level which also does not work.
There seems to be a discrepancy between the unique_id that I have given the sensors in the yaml file and the names available in the drop down list. I have no idea where it has come up with the names tank_2 and tank_2_2, but tank_2 is the only one that works.
Can anyone make some sense out of this and let me know how the system creates the list of available entities from my config.yaml file.
You can see that there are two sensor displays with level of 8%, both with sensor.tank_2 as the entity and all other are “unknown” or “not available”.
The pump control card is working.
BTW, I can control and monitor all mqtt topics in mqtt explorer and mqtt dash from my phone, and also sent and receive with the broker from my ESPnow wifi mesh hardware.
Hi Again,
I have made some good progress. It didn’t seem to like the value_template, and it definitely didn’t like my incorrect spelling in the temperature topic. I still don’t know how to refer to the data value from the broker within the value_template, but that’s another question. Here is my config.yaml
Thanks for the help.
I have created a ESPnow wifi mesh that sends to my router with a ESP32 gateway. All working pretty well, devices auto-detect, Control and monitor, now ready for the next step. I am happy to share my stuff if anyone is interested. It is written in C on arduino with ESP8266 and ESP32.
Regards
Bill