Hi there,
perhaps I missed something fundamental but I am not able to get a template switch showing the correct state of a LCD display. I try to combine a MQTT binary sensor and a command line switch. Both parts work fine on their own.
The MQTT binary sensor:
Though I could turn the LCD display on and off the state of the LCD display shows always off.
I think that I do something wrong with the value_template of the template switch but I run out of ideas.
Perhaps someone could offer me a hint?
well, your lcdstatus is a binary_sensor, not a sensorā¦ So first thing that comes to mind is that it should be
value_template: "{{ is_state('binary_sensor.lcdstatus.state', 'on') }}"
On top of that, I think you should not use a condition but jsut the template value_template: "{{ states.binary_sensor.lcdstatus.state }}"
Also, from what I understand your command_line switch is just posting something into a MQTT topic, so you could use a mqtt_switch instead.
Thank you very much lambtho for the two hints (ālcdstatus is a binary_sensor, not a sensorā and āyou should not use a condition but just the templateā). All is working now as intended
Please find the revised and working template switch configuration below:
Towards using a command_line switch instead of the mqtt_switch. Well, I tried but I have different command topics for turning the LCD on āā¦/lcd_20x4/ofH/backlight_on/setā and off ālcd_20x4/ofH/backlight_off/setā which I am not able to fit in the mqtt_switch configuration which expects a different payload for turning the LCD on or off.