I’m not new to HA but struggled to go beyond the basics. I’m racking my head trying to work out what I need to do.
I have a gate that I have set up as an entity script called (script.momentary_front_gate) which by clicking I can open/close - it literally tells me nothing as its effectively a toggle.
I then have a seperate sensor that shows me if the gate is open or closed (binary_sensor.shellydw2_483fda81e506_door).
I ideally want them set up as one lovelace item where I can see the icon open or closed.
I have no knowledge of templates but hope that in the four years since this was originally created a more practical solution may be available.
No templates are needed.
Put the binary_sensor in an entities card with a tap action that calls the script.
type: entities
entities:
- entity: binary_sensor.shellydw2_483fda81e506_door
name: Front Gate
tap_action:
action: call-service
service: script.momentary_front_gate
This can all be done via the UI too.
You can change the ‘display as’ for the binary sensor to garage or gate to change the icon and state translations.
You should make a template cover to combine them.
Thanks that seems to work but cant quite understand last sentence - I would like to change the symbol to an open gate when open, vice versa
click on the entity, go to it’s configuration and change display as
or maybe it’s called show as
There is no “gate” device class for binary sensors. There is for covers.
cover:
- platform: template
covers:
front_gate:
device_class: gate # gives you a changing icon
friendly_name: "Front Gate"
value_template: "{{ is_state('binary_sensor.shellydw2_483fda81e506_door', 'on') }}"
open_cover:
- condition: state
entity_id: binary_sensor.shellydw2_483fda81e506_door
state: 'off'
- service: script.momentary_front_gate
close_cover:
- condition: state
entity_id: binary_sensor.shellydw2_483fda81e506_door
state: 'on'
- service: script.momentary_front_gate
You can then use cover.front_gate
directly in your dashboard cards.
seems like that will need to be added for binary_sensors then. In regards to the cover template, there’s no reason for those conditions. By default, the UI will take care of those conditions.
cover:
- platform: template
covers:
front_gate:
device_class: gate # gives you a changing icon
friendly_name: "Front Gate"
value_template: "{{ is_state('binary_sensor.shellydw2_483fda81e506_door', 'on') }}"
open_cover:
- service: script.momentary_front_gate
close_cover:
- service: script.momentary_front_gate
THanks thats useful, following I set up the cover - the entity cover.front_gate now gives me this when clicking it:
What does this return in Developer Tools → Templates
{{ is_state('binary_sensor.shellydw2_483fda81e506_door', 'on') }}
Result type: boolean
true
This template listens for the following state changed events:
- Entity: binary_sensor.shellydw2_483fda81e506_door
Good. Check that your configuration matches what petro wrote above, exactly. Including indentation.
Thank you Gents! That works a treat - Really appreciated. I never had the confidence to get near Templates.