I am quite new to this ESPHome and Home Assistant world, and definately NOT a YAML programmer…
I have managed to get HA and ESPHome running, and with great help form examples on this forum gotten an ESP32 to talk to my heatpump, and give back variuos information.
One of the things I get back is the compressor status, in the form of a 0-10 numerical value. I would like to present this status on my dashboard in text form, but I can’t get it to work.
I have seen and tried several examples found on the forums on how to convert these numbers into text, but I can’t get any of them to work on my environment…
once the value is showing up in HA (use Developer Tools / States to see it) then you can use a template sensor to create what ever you want …as a completely different example I have shows (i copied and pasted from somebody else but have learnt how to use templates with scripts
I have the numerical value of the original sensor showing up just fine, but putting your suggestion into configuration.yaml, imidiately throws these errors (using the Visual Studio Code plugin)
@Spangsberg. I am really sorry but I have confused everything . The yaml I posted was not an answer for you. It will not work for you; as it is using two sensors from my esp which measure wind strength 15 knots) and wind bearing ( 195 degrees). The template converts those numbers into text, for example “Bft: 4, Moderate breeze, 15knts, WSW”which is then displayed on a display card on my dashboard.
I however posted it to see whether it is what you are trying to achieve. The best place to start is YouTube video tutorials on HA template and script. I used this to help me understand how to write the script. Sorry for confusion, but let me know if there is a specific question I can help with
@JulianDH Your script actually does exactly what I am trying to achieve, just with wind in stead of status.
My sensor also returns a number that I would like to display as text on card on the dashboard.
I am aware that I need to modify your script to read my sensors in stead of yours etc. but should the script put in configuration.yaml or in a custom card, or where do I start?
add a on_value: tag to the modbus sensor and in that on_value: use the text_sensor.template.publish: action to publish with the help of a lambda the right text value.
Having just taken a look, I see that the code I pasted is legacy and not recommended, but there are many recommended up to date examples on the page. This has made me realise I need to update my code! I strongly recommend Developers Tools / Template editor to test all you script first.
I also recommend a video; something like this … I got me going!