Jatho
(Paul )
February 27, 2020, 3:45pm
1
Hi Guys
I’ve setup a Sonoff 4CH Pro to open / close my garage doors and then have 2 x 433mhz door sensors that detect when the doors are open or closed but I have these as 4 different entities (see image below)
I’d like to just have two icons, 1 for each of the garage doors and when I press to open it changes the icon to mdi: garage-open and mdi: garage-closed.
I know its possible I’ve seen it on the forum somewhere before but cannot seem to find that post again.
Would appreciate a bit of help from someone a little more knowledgeable than me.
Thanks.
My config below
entities:
- entity: switch.sonoff_4ch_p1
icon: 'mdi:garage'
- entity: binary_sensor.garage_door_tamsin
- entity: switch.sonoff_4ch_p3
icon: 'mdi:garage'
- entity: binary_sensor.garage_door_paul
- entity: sensor.sonoff_rf_bridge_dht11_temperature
name: Garage Temperature
show_header_toggle: false
type: entities
My binarysensors.yaml file
- platform: mqtt
name: 'Garage Door Paul'
state_topic: 'tele/sonoff-rf-bridge/RESULT'
value_template: >-
{% if value_json.RfReceived.Data == '6A0103' %}
{{'ON'}}
{% elif value_json.RfReceived.Data == '6A010F' %}
{{'OFF'}}
{% else %}
{{states('binary_sensor.sonoff_rf_bridge_button1') | upper}}
{% endif %}
device_class: door
- platform: mqtt
name: 'Garage Door Tamsin'
state_topic: 'tele/sonoff-rf-bridge/RESULT'
value_template: >-
{% if value_json.RfReceived.Data == 'DB0103' %}
{{'ON'}}
{% elif value_json.RfReceived.Data == 'DB010F' %}
{{'OFF'}}
{% else %}
{{states('binary_sensor.sonoff_rf_bridge_button1') | upper}}
{% endif %}
device_class: door
lolouk44
(lolouk44)
February 27, 2020, 4:00pm
2
what you need is a template switch …
Have a look at the examples on the doc to see how to build one…
ChrLipp
(Christian LIPP)
February 27, 2020, 5:25pm
3
Could you provide a link to your 433mhz door sensors?
Jatho
(Paul )
February 27, 2020, 6:16pm
4
Sure…
I’m using these its important that you get sensors that send two codes, one for on / off (open / closed) some only send 1 code to say its open so when it closes you don’t know. I’m using these in conjunction with the sonoff rf bridge.
Jatho
(Paul )
February 27, 2020, 6:17pm
5
Thanks lolouk44, I’ve been trying to set this up for the last little while and struggling to get it to work but I’ll keep at it.
Markus99
(Mark)
February 27, 2020, 6:19pm
6
Here’s mine:
garage_door_main:
friendly_name: "Main Garage Door Switch"
value_template: "{{ is_state('cover.main_garage_door', 'open') }}"
turn_on:
service: cover.open_cover
data:
entity_id: cover.main_garage_door
turn_off:
service: cover.close_cover
data:
entity_id: cover.main_garage_door
icon_template: >-
{% if is_state('cover.main_garage_door', 'open') %}
mdi:garage-open
{% else %}
mdi:garage
{% endif %}
Jatho
(Paul )
February 27, 2020, 6:35pm
7
Markus99:
Here’s mine:
Copy to clipboard
garage_door_main:
friendly_name: "Main Garage Door Switch"
value_template: "{{ is_state('cover.main_garage_door', 'open') }}"
turn_on:
service: cover.open_cover
data:
entity_id: cover.main_garage_door
turn_off:
service: cover.close_cover
data:
entity_id: cover.main_garage_door
icon_template: >-
{% if is_state('cover.main_garage_door', 'open') %}
mdi:garage-open
{% else %}
mdi:garage
{% endif %}
I’m battling to follow the logic on the way a cover works
Do I need to create a service or something (never worked with service) to create cover.open_cover and also not sure on how the entity is created as cover.main_garage_door?
Markus99
(Mark)
February 27, 2020, 6:37pm
8
These were default entities created in my HA using my ZWave (GoControl I think it is) garage door opener (https://www.amazon.com/GoControl-Linear-GD00Z-4-Z-Wave-Controller/dp/B00M75TEIU ).
I integrate this into SmartThings and then SmartThings into HA via the built-in integration.
If you’re using something different you’ll need to adjust the entities for those that fit your usage. ie. What’s the open/closed sensor. What’s the switch to open/close. Etc.
lolouk44
(lolouk44)
February 27, 2020, 7:31pm
9
Here’s Tamsin’s garage door for you.
This goes in the switch
section of your configuration.yaml
Since you already have a
garage_door_tamsin:
friendly_name: "Garage Door Tamsin"
value_template: "{{ is_state('binary_sensor.garage_door_tamsin', 'open') }}"
turn_on:
service: switch.turn_on
data:
entity_id: switch.sonoff_4ch_p1
turn_off:
service: switch.turn_off
data:
entity_id: switch.sonoff_4ch_p1
icon_template: >-
{% if is_state('binary_sensor.garage_door_tamsin', 'open') %}
mdi:garage-open
{% else %}
mdi:garage
{% endif %}
You need to edit your lovelace card to be like this:
entities:
- entity: switch.garage_door_tamsin
- entity: switch.garage_door_paul
- entity: sensor.sonoff_rf_bridge_dht11_temperature
name: Garage Temperature
show_header_toggle: false
type: entities
I’ve not tested it but it should pretty much be this…
Jatho
(Paul )
February 27, 2020, 8:17pm
10
Thank you I’m starting to see where I went wrong however still not working if I put it under my switch: section my config check is failing, tried a few variations and cant find where I’m going wrong.
switch:
- platform: broadlink
host: 192.168.XXX.XXX
mac: 'C8:F7:42:83:97:4C'
type: rm_mini
timeout: 30
switches:
fan_power:
friendly_name: "Fan Power"
command_on: 'JgAEAScMLAwPKCsMLAwPKBAnECgQJxAnLAwQAAEKKwwsDBAnLAwrDBAnECgQJxAnECgrDBAAAQosDCsMECcsDCsMECcQKBAnECgPKCsMEAABCiwMKwwQKCsMKwwQKBAnECcQKBAnLAwQAAEKKwwrDBAoKwwsDA8oECcQKBAnECcsDBAAAQorDCwMDygsDCsMECcQJxAoECcQKCsMEAABCiwMKwwQJywMKwwQJxAoECcQKA8oKwwQAAEKLAwrDBAnLAwrDBAoDygQKA8oECcsDA8AAQsrDCwLECgrDCwMDygQJxAoECcQKCsMEAABCisMLAwQJywMKwwQJxAoECcQJxAoKwwQAA0FAAAAAA=='
command_off: 'JgAiAScLLAwQJywMKwwQJxAoECcQJxAoECcs7iwMKwwQJywMKwwQKA8oECcQKBAnECcs7ysMKwwQKCsMLAwPKBAnECgPKBAnECgr7ysMLAwPKCsMLAwQJxAnECgQJxAoDygs7iwLLAwQJywMKwwQJxAoECcQJxAoECcs7iwMKwwQJywMKwwQKA8oECcQKBAnECcs7iwMKwwQKCsMLAsQKBAnECgPKBAnECgr7ywLLAwPKCsMLAwQJxAnECgQJxAoDygr7ywMKwwQJywMKwwQJxAoECcQKA8oECcs7iwMKwwQKCsMKwwQKBAnECcQKBAnECgr7ysMLAwPKCsMLAwPKBAnECgQJxAoDygr7ywLLAwQKCsMKwwQJxAoECcQJxAoECcsAA0FAAAAAAAA'
tv:
friendly_name: "Main Bedroom TV Power"
command_on: 'JgBYAAABIJISExETETcSEhISEhQQFBETETcROBESEjcRNhM1EjcTNRMTERISNxEUERMSExE2EjYSNhM2EhIROBE3ETcREhITEgAFGwABH0oSAAwzAAEfShEADQU='
command_off: 'JgBYAAABIJISExETETcSEhISEhQQFBETETcROBESEjcRNhM1EjcTNRMTERISNxEUERMSExE2EjYSNhM2EhIROBE3ETcREhITEgAFGwABH0oSAAwzAAEfShEADQU='
garage_door_tamsin:
friendly_name: "Garage Door Tamsin"
value_template: "{{ is_state('binary_sensor.garage_door_tamsin', 'open') }}"
turn_on:
service: switch.turn_on
data:
entity_id: switch.sonoff_4ch_p1
turn_off:
service: switch.turn_off
data:
entity_id: switch.sonoff_4ch_p1
icon_template: >-
{% if is_state('binary_sensor.garage_door_tamsin', 'open') %}
mdi:garage-open
{% else %}
mdi:garage
{% endif %}
lolouk44
(lolouk44)
February 27, 2020, 8:30pm
11
my bad, I did not give you the full code…
switch:
- platform: broadlink
host: 192.168.XXX.XXX
mac: 'C8:F7:42:83:97:4C'
type: rm_mini
timeout: 30
switches:
fan_power:
friendly_name: "Fan Power"
command_on: 'JgAEAScMLAwPKCsMLAwPKBAnECgQJxAnLAwQAAEKKwwsDBAnLAwrDBAnECgQJxAnECgrDBAAAQosDCsMECcsDCsMECcQKBAnECgPKCsMEAABCiwMKwwQKCsMKwwQKBAnECcQKBAnLAwQAAEKKwwrDBAoKwwsDA8oECcQKBAnECcsDBAAAQorDCwMDygsDCsMECcQJxAoECcQKCsMEAABCiwMKwwQJywMKwwQJxAoECcQKA8oKwwQAAEKLAwrDBAnLAwrDBAoDygQKA8oECcsDA8AAQsrDCwLECgrDCwMDygQJxAoECcQKCsMEAABCisMLAwQJywMKwwQJxAoECcQJxAoKwwQAA0FAAAAAA=='
command_off: 'JgAiAScLLAwQJywMKwwQJxAoECcQJxAoECcs7iwMKwwQJywMKwwQKA8oECcQKBAnECcs7ysMKwwQKCsMLAwPKBAnECgPKBAnECgr7ysMLAwPKCsMLAwQJxAnECgQJxAoDygs7iwLLAwQJywMKwwQJxAoECcQJxAoECcs7iwMKwwQJywMKwwQKA8oECcQKBAnECcs7iwMKwwQKCsMLAsQKBAnECgPKBAnECgr7ywLLAwPKCsMLAwQJxAnECgQJxAoDygr7ywMKwwQJywMKwwQJxAoECcQKA8oECcs7iwMKwwQKCsMKwwQKBAnECcQKBAnECgr7ysMLAwPKCsMLAwPKBAnECgQJxAoDygr7ywLLAwQKCsMKwwQJxAoECcQJxAoECcsAA0FAAAAAAAA'
tv:
friendly_name: "Main Bedroom TV Power"
command_on: 'JgBYAAABIJISExETETcSEhISEhQQFBETETcROBESEjcRNhM1EjcTNRMTERISNxEUERMSExE2EjYSNhM2EhIROBE3ETcREhITEgAFGwABH0oSAAwzAAEfShEADQU='
command_off: 'JgBYAAABIJISExETETcSEhISEhQQFBETETcROBESEjcRNhM1EjcTNRMTERISNxEUERMSExE2EjYSNhM2EhIROBE3ETcREhITEgAFGwABH0oSAAwzAAEfShEADQU='
- platform: template
switches:
garage_door_tamsin:
friendly_name: "Garage Door Tamsin"
value_template: "{{ is_state('binary_sensor.garage_door_tamsin', 'open') }}"
turn_on:
service: switch.turn_on
data:
entity_id: switch.sonoff_4ch_p1
turn_off:
service: switch.turn_off
data:
entity_id: switch.sonoff_4ch_p1
icon_template: >-
{% if is_state('binary_sensor.garage_door_tamsin', 'open') %}
mdi:garage-open
{% else %}
mdi:garage
{% endif %}
Bartem
February 28, 2020, 1:51am
12
You may actually want to look at this… should be pretty much the same setup… but will make actual “cover” entity
1 Like
Jatho
(Paul )
February 28, 2020, 6:48am
13
Thanks @lolouk44 this worked, I just needed to change open to on appreciate your help.
Jatho
(Paul )
February 28, 2020, 7:25am
14
Thanks Bartem, I have looked at this before but struggled to get it to work, I will give it a go again. What benefit would it have over setting it up as a switch?
Jatho
(Paul )
February 28, 2020, 8:13am
15
So a little perseverance and I’ve got the covers working (mostly). Icon changes according to the sensor state (open or closed) but the arrows which I assume should also change on these state changes are not and the down arrow is permanently highlighted.
cover:
- platform: template
covers:
garage_door_tam:
friendly_name: "Tam Garage Door"
position_template: "{{ states('binary_sensor.garage_door_tamsin') }}"
open_cover:
service: switch.turn_on
data:
entity_id: switch.sonoff_4ch_p1
close_cover:
service: switch.turn_off
data:
entity_id: switch.sonoff_4ch_p1
stop_cover:
service: switch.turn_on
data:
entity_id: switch.sonoff_4ch_p1
icon_template: >-
{% if is_state('binary_sensor.garage_door_tamsin', 'on') %}
mdi:garage-open
{% else %}
mdi:garage
{% endif %}
- platform: template
covers:
garage_door_paul:
friendly_name: "Paul Garage Door"
position_template: "{{ states('binary_sensor.garage_door_paul') }}"
open_cover:
service: switch.turn_on
data:
entity_id: switch.sonoff_4ch_p3
close_cover:
service: switch.turn_off
data:
entity_id: switch.sonoff_4ch_p3
stop_cover:
service: switch.turn_on
data:
entity_id: switch.sonoff_4ch_p3
icon_template: >-
{% if is_state('binary_sensor.garage_door_paul', 'on') %}
mdi:garage-open
{% else %}
mdi:garage
{% endif %}
tbhova
(Tyler)
December 24, 2020, 1:31am
16
I know the thread is old. Posting in case it’s relevant to the OP or future readers of this thread.
The reason the down button is permanently highlighted is because position_template
is used instead of value_template
. Position_template is supposed to reported a value [0, 100] of the open-ness of the “cover” (think like a window shade). Value_template instead is open/closed.
Both
value_template: "{{ is_state('binary_sensor.garage_door_sensor', 'on') }}"
and
value_template: "{{ states('binary_sensor.garage_door_sensor') }}"
But the first one is reported to be more reliable if the sensor is in an unknown state during server start up.
Note: the value_template
s above assume your binary sensor is triggered when the door is closed. I am using a Wyze door sensor that comes together when the door is closed.