Good morning,
First of all, I am new to HA and probably don’t understand Cover well…
My issue:
I am using Shelly 1 to control garage door with connected magnetic door sensor - both works in HA. I can see senzor (changing state) and button in entities.
I created cover in configuration.yaml :
cover:
platform: template
covers:
garage_door:
device_class: garage
friendly_name: “Garage Door”
value_template: >-
{% if is_state(‘binary_sensor.garage_door_sensor’,‘on’) %}
Open
{% else %}
Closed
{% endif %}
open_cover:
service: switch.turn_on
data:
entity_id: switch.shelly1_garage_door
close_cover:
service: switch.turn_on
data:
entity_id: switch.shelly1_garage_door
stop_cover:
service: switch.turn_on
data:
entity_id: switch.shelly1_garage_door
icon_template: >-
{% if is_state(‘binary_sensor.garage_door_sensor’,‘on’) %}
mdi:garage-open
{% else %}
mdi:garage
{% endif %}
and put this code to costumise.yaml:
cover.garage_door:
device_class: garage
My goal is to reach similiar dashboard changin icon of garage door(closed/open) based on door sensor. Like its on this pict:
Thjank you for any advice how to reach it.
I have the same setup with a Shelly 1 and a magnetic contact sensor (reed switch) for my garage door.
This should get you there:
cover:
- platform: template
covers:
garage_door:
device_class: garage
unique_id: "garage"
friendly_name: "Garage Door"
value_template: '{{ is_state("binary_sensor.garage_input", "off") }}'
open_cover:
- condition: state
entity_id: cover. garage_door
state: closed
- service: switch.turn_on
data: {}
target:
entity_id: switch.garage
close_cover:
- condition: state
entity_id: cover. garage_door
state: open
- service: switch.turn_on
data: {}
target:
entity_id: switch.garage
stop_cover:
service: switch.turn_on
data:
entity_id: switch.garage
You might want to add checking for closing
and opening
too:
- if:
- condition: or
conditions:
- condition: state
entity_id: cover.garage_door
state: closed
- condition: state
entity_id: cover.garage_door
state: closing
then:
- service: switch.turn_on
data: {}
target:
entity_id: switch.garage
2 Likes
acme64
June 18, 2023, 5:50am
3
sorry for digging up old post, i’m doing the same thing however, my sensor is backwards. when the reed switch is together it reports open, when it seperates it reports closed, how do i flip it?
Hi, do you have one reed switch connected to the Shelly? And you can get both opening
and closing
states from the one reed switch?
acme
December 17, 2023, 12:08pm
5
Hi acme64, this is acme.
In case you haven’t figured it out already, you can reverse the input state from the shelly page.
And btw, below is my template:
- platform: template
switches:
garage_door:
friendly_name: "Garage Door"
value_template: "{{ is_state('binary_sensor.shelly_garage_door_switch', 'on') }}"
turn_on:
service: switch.turn_on
data:
entity_id: switch.shelly_garage_door
turn_off:
service: switch.turn_on
data:
entity_id: switch.shelly_garage_door
icon_template: >-
{% if is_state('binary_sensor.shelly_garage_door_switch', 'on') %}
mdi:garage-open
{% else %}
mdi:garage
{% endif %}
And I have a timer in shelly app to turn off the shelly switch after 1 sec whenever it is on.
2 Likes
FilipeOS
(Filipe Os)
December 29, 2023, 1:01am
6
can you provide the full code please? I can’t make it work no matter what… it’s inverted too, only say open when garage is fully open (in shelly, in HA don’t even work)
acme
December 29, 2023, 8:42am
7
That is the full code I use. It is in my switch.yaml file.
1 Like
FilipeOS
(Filipe Os)
December 29, 2023, 10:07am
8
I tried this but don’t work at all.
cover:
- platform: template
covers:
garage_gate:
device_class: garage
friendly_name: "Garage Gate"
value_template: "{{ states('sensor.garage_gate') }}"
open_cover:
- condition: state
entity_id: sensor.garage_gate
state: "closed"
- service: switch.toggle
target:
entity_id: switch.garage_gate
close_cover:
- condition: state
entity_id: sensor.garage_gate
state: "open"
- service: switch.toggle
target:
entity_id: switch.shelly1_e8db84d730af
stop_cover:
service: switch.toggle
target:
entity_id: switch.shelly1_e8db84d730af
icon_template: >-
{% if is_state('cover.garage_gate', 'opening') or is_state('cover.garage_gate', 'closing') %}
mdi:garage-alert-variant
{% elif is_state('cover.garage_gate', 'open') %}
mdi:garage-open-variant
{% else %}
mdi:garage-variant
{% endif %}
tempate:
- sensor:
- name: "Garage Gate"
state: >
{% if is_state('binary_sensor.garage_sensor', 'on') and is_state('switch.shelly1_e8db84d730af', 'on') %}
opening
{% elif is_state('binary_sensor.garage_sensor', 'off') and is_state('switch.shelly1_e8db84d730af', 'on') %}
closing
{% elif is_state('binary_sensor.garage_sensor', 'off') %}
open
{% else %}
closed
{% endif %}
in your code is missing something before platform? -switch or what?
acme
December 29, 2023, 10:26am
9
Try it as switch instead of cover. I can’t check your code with detail atm.
FilipeOS
(Filipe Os)
December 30, 2023, 11:00pm
10
I tried, no luck. In Shelly what type of button you have selected? both toggle or detached switch don’t work
1 Like
FilipeOS
(Filipe Os)
December 30, 2023, 11:54pm
12
yup, like that and your code, don’t work
switch:
- platform: template
switches:
garage_door:
friendly_name: "Garage Door"
value_template: "{{ is_state('binary_sensor.shelly1_e8db84d730af_switch', 'on') }}"
turn_on:
service: switch.turn_on
data:
entity_id: switch.shelly1_e8db84d730af
turn_off:
service: switch.turn_on
data:
entity_id: switch.shelly1_e8db84d730af
icon_template: >-
{% if is_state('binary_sensor.shelly1_e8db84d730af_switch', 'on') %}
mdi:garage-open-variant
{% else %}
mdi:garage-variant
{% endif %}
is this binary_sensor.shelly1_e8db84d730af_switch
made up? because don’t exist,
the ones coming from shelly always unavailable are binary_sensor.shelly1_e8db84d730af_input
and binary_sensor.shelly1_e8db84d730af_external_input
…
In my Shelly1, there’s an option to reverse the polarity on the input to the Shelly1 (you may need to update firmware to get this option):
Note that if you are getting “unavailable” for your shelly1_xxxxx_input binary_sensor, then most likely the shelly1 is not properly connected to your network? I have seen this when my wifi signal was weak.
FilipeOS
(Filipe Os)
February 7, 2024, 7:02pm
14
I found that the external input was disabled in HA. After I enable that and put Shelly to detached switch, all worked fine
Yep this fixed it for me as well. Here is an image of where to enable it (on mine at least)