I have a binary_sensor called ‘binary_sensor.garage_door_input’. It is the reed swtich on my Shelly1 that tells me whether the garage door is open or not.
By default it’s state would be ‘On’ or ‘Off’.
By over-riding it’s device-class attribute in ‘Customisations’ and setting to ‘garage-door’ I now have it showing the State as either ‘Open’ or ‘Closed’.
It’s default icon is ‘mdi:garage’.
It’s friendly name is ‘Garage Door Status’
To that end it works fine:
What I am trying to do now is simply change the icon based on the sensor state
If the State is ‘On’ /‘Open’ then icon = ‘mdi:garage-open’
if the State is ‘Off’/‘Closed’ then icon = ‘mdi:garage’
I searched this site to find an answer but the info I find is usually a bit old and/or creates a new binary_sensor and/or HA barks at me the format is wrong.
Does anyone have a clear example of the code that will do this for me without creating a new sensor? I assume it will go in ‘customization.yaml’ ?
Not sure if this makes any difference, this is the Shelly native intergration, not ‘ShellyforHACS’ or anything else custom like Shelly Discover. I did not create this binary_sensor in configuration.yaml .
As true/false are valid results for the template as well as open/closed.
The state is not polled. It should update as soon as your garage door binary sensor changes. If that sensor is polled then that is where your delay is.
Thanks that change gave me a better looking card for that cover where the switch and the state icon are on same line.
No change to timing though , still a little delayed. I dont know where to check if it is polled or not, just using the Shelly native intergration. it’s no biggy as this reed switch really only tells me when garage is fully open. Magnet only connects to switch when door is at maximum openess. I need to place another sensor on bottom of door to tell me when it’s ‘not 100% closed’. I’ll use that to drive automations like turning lights on.
I believe I am using ‘core Shelly integration’ yes:
I enabled MQTT and setup the code in configuration.yaml, but it did not change state.
MQTT logs
1626393717: New connection from 172.30.32.1 on port 1883.
1626393717: New client connected from 172.30.32.1 as 2HJjIz4wmU7Z3pJPOwtyud (p2, c1, k60, u'homeassistant').
1626393926: Socket error on client 2HJjIz4wmU7Z3pJPOwtyud, disconnecting.