I have two binary sensors on a NodeMCU and am trying to create an ‘and’ condition that sets a template sensor if, and only if, both binary sensors are on but just can’t get it right.
I think I need a template sensor with lambda but can’t figure out the code so would appreciate any help, please.
Thanks, all, for your responses and @VDRainer for that line. I think I spent too long on it and was over complicating it last night! I have added it as follows:
It now appears in HASS but does not update - it is stuck on ‘on’ and does not reflect the states of the other two sensors as seen by HASS.
I was hoping to do the ‘and-ing’ on the NodeMCU and ESPHome to minimise network traffic and HASS.IO processing but unfortunately can’t do that if it doesn’t update reliably.
In the hope that I need to update the template sensor status in HASS I’ve searched for a command to ‘push’ the template_sensor status to HASS but can’t find anything so maybe I should just use HASS automation to do the AND-ing.
Thank you, @Holdestmade, that works. I had to add another set of brackets to stop compile errors but it now updates in real time on HASS. Once I’m happy with the behaviour of the automation I’ll do as you say and make the two ‘input’ binary sensors local only.