Garage door switch and window sensor as one line in Lovelace

Hi there,

my garage door opens or closes with a switching impulse (always the opposite of the current state). I do this via a Zigbee relay module, this always switches off again 2 seconds after switching on. In order to be able to recognize the status of the gate, I use a door sensor.
The aim is to show the garage door switch in the Lovelace, the symbol (when the gate is open) should be colored. So I don’t need the second line for the door sensor.

Now I’ve tried the following code (configuration.yaml):

switch:
 - platform: template
   switches:
     blind:
       friendly_name: "Garage"
       value_template: "{{ is_state_attr('binary_sensor.lumi_lumi_sensor_magnet_aq2_af8cff06_on_off', 'sensor_state', 'on') }}"
       turn_on:
         service: switch.ss02_on_off
         target:
           entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_af8cff06_on_off
       turn_off:
         service: switch.ss02_on_off
         target:
           entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_af8cff06_on_off

Unfortunately that doesn’t work.
I hope someone can help me.

Greetings Werner

Hallo,

mein Garantentor fährt mit einem Schaltimpuls auf oder zu (immer das Gegenteil von aktuellen Zustand). Dies realisiere ich über ein Zigbee Relais-Modul, dieses schaltet immer, 2 sec. nach dem einschalten, wieder aus. Um den Zustand vom Tor erkennen zu können verwende ich einen Türsensor.
Ziel ist es im Lovelace den Garagentorschalter abzubilden, dabei soll sich das Symbol (wenn Tor geöffnet) einfärben. So brauche ich die zweite Zeile für den Türsenor nicht.

Nun habe ich folgenden Code versucht:

switch:
  - platform: template
    switches:
      blind:
        friendly_name: "Garage"
        value_template: "{{ is_state_attr('binary_sensor.lumi_lumi_sensor_magnet_aq2_af8cff06_on_off', 'sensor_state', 'on') }}"
        turn_on:
          service: switch.ss02_on_off
          target:
            entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_af8cff06_on_off
        turn_off:
          service: switch.ss02_on_off
          target:
            entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_af8cff06_on_off

Leider funktioniert das nicht.
Ich hoffe mir kann jemand helfen.

Grüße Werner

If you have not figure it out, consider using-

cover:
  - platform: template
    covers:
      garage_door:
        friendly_name: "Garage Door"
        device_class: garage
        value_template: "{{ is_state('binary_sensor.lumi_lumi_sensor_magnet_aq2_af8cff06_on_off', 'on') }}"
        open_cover:
          service: switch.toggle
          entity_id: switch.ss02_on_off
        close_cover:
          service: switch.toggle
          entity_id: switch.ss02_on_off
        stop_cover:
          service: switch.toggle
          entity_id: switch.ss02_on_off

However, if you still want to have a switch instead of a cover, you can try-

switch:
  - platform: template
    switches:
      garage_door:
        friendly_name: "Garage Door"
        value_template: "{{ is_state('binary_sensor.lumi_lumi_sensor_magnet_aq2_af8cff06_on_off', 'on') }}"
        turn_on:
          service: switch.toggle
          entity_id: switch.ss02_on_off
        turn_off:
          service: switch.toggle
          entity_id: switch.ss02_on_off
        icon_template: >-
          {{ 'mdi:garage' if is_state('binary_sensor.lumi_lumi_sensor_magnet_aq2_af8cff06_on_off','off') else 'mdi:garage-open' }}
1 Like

Hi there,

Once again, thank you very much for your help.
I like the two variants. The status of the garage door is also displayed correctly.
Only the gate does not react to the switches.

In the meantime I had changed the equipment.
Here is my current configuration with two lines, this is how it works:

type: entities
entities:
  - entity: light.ewelink_zb_sw01_1e1c6b22_on_off
  - entity: binary_sensor.tk04_sonoff_turkontakt_ias_zone
title: TOR
state_color: true

And here are the two new variants, but the switch does not work there:

# Test Garagentor Cover
cover:
  - platform: template
    covers:
      garage_door:
        friendly_name: "Garagentor mit Pfeilen"
        device_class: garage
        value_template: "{{ is_state('binary_sensor.tk04_sonoff_turkontakt_ias_zone', 'on') }}"
        open_cover:
          service: switch.toggle
          entity_id: light.ewelink_zb_sw01_1e1c6b22_on_off
        close_cover:
          service: switch.toggle
          entity_id: light.ewelink_zb_sw01_1e1c6b22_on_off
        stop_cover:
          service: switch.toggle
          entity_id: light.ewelink_zb_sw01_1e1c6b22_on_off
# Entitäten verbinden Gargentor (Test)
switch:
  - platform: template
    switches:
      garage_door:
        friendly_name: "Garagentorschalter"
        value_template: "{{ is_state('binary_sensor.tk04_sonoff_turkontakt_ias_zone', 'on') }}"
        turn_on:
          service: switch.toggle
          entity_id: light.ewelink_zb_sw01_1e1c6b22_on_off
        turn_off:
          service: switch.toggle
          entity_id: light.ewelink_zb_sw01_1e1c6b22_on_off
        icon_template: >-
          {{ 'mdi:garage' if is_state('binary_sensor.tk04_sonoff_turkontakt_ias_zone','off') else 'mdi:garage-open' }}

What can it be?

Greetings Werner

1 Like

I think, switch.toggle won’t work with a light entity.

1 Like

For light, use light.toggle

For switch, use switch.toggle

1 Like

Thank you again.
That was the mistake.

Greetings Werner

Werner,

Could you tell me what hardware you used, I want to do the same :grinning:

I was thinking about using a Shelly 1 in combination with one Aqara doorsensor…

Thanks !

Hello,

Sorry for the late reply.
I used this module instead of a Shellys:

An Aqara is also used as a sensor.

Greeting Werner

Hello Herbert,

But it should work with Shelly 1 too I presume ?

Just to be sure, could I have your last working code ?

Thanks !

Yes, that’s definitely possible. Which code do you mean?

I see (configuration.yaml):

The following code is for an arrow view (but I don’t use it):

# Garagentor Cover mit Pfeilen
cover:
  - platform: template
    covers:
      garage_door:
        friendly_name: "Garagentor mit Pfeilen"
        device_class: garage
        value_template: "{{ is_state('binary_sensor.tk04_sonoff_turkontakt_ias_zone', 'on') }}"
        open_cover:
          service: light.toggle
          entity_id: light.ewelink_zb_sw01_1e1c6b22_on_off
        close_cover:
          service: light.toggle
          entity_id: light.ewelink_zb_sw01_1e1c6b22_on_off
        stop_cover:
          service: light.toggle
          entity_id: light.ewelink_zb_sw01_1e1c6b22_on_off

I use this code:

# Gargentorschalter
switch:
  - platform: template
    switches:
      garage_door:
        friendly_name: "Garagentorschalter"
        value_template: "{{ is_state('binary_sensor.tk04_sonoff_turkontakt_ias_zone', 'on') }}"
        turn_on:
          service: light.toggle
          entity_id: light.ewelink_zb_sw01_1e1c6b22_on_off
        turn_off:
          service: light.toggle
          entity_id: light.ewelink_zb_sw01_1e1c6b22_on_off
        icon_template: >-
          {{ 'mdi:garage-variant' if is_state('binary_sensor.tk04_sonoff_turkontakt_ias_zone','off') else 'mdi:garage-open-variant' }}

Greeting Werner

Now I remember something else.
I don’t know Shellys, but with the module I’m using it’s possible that there’s only a one-second pulse when switching. This may not be possible with the Shelly. With my garage door, however, only one impulse is allowed.
What I mean by this is that when I click on the dedicated switch on the dashboard, the wires for the garage door motor are bypassed for 1 second and then automatically opened again.

https://www.youtube.com/results?search_query=MHCOZY

Greeting Werner

Thanks Werner, but…

I also will not use the cover template, because when putting this cover on my dashboard, I see f.e. this :

Schermafbeelding 2022-09-06 144951

There seems no possiblity to mention when a button may be enabled or not ? In my case I want the stop button only be enabled when the garagedoor is moving. I also want the arrows up and down both enabled, except when the door is completely open or closed (I would use 2 door sensors for this).

So meanwhile I did it myself :wink:

Schermafbeelding 2022-09-08 085706

Nevertheless, thanks for the cooperation!

FYI : Shelly does that too.

Great. Write your code here, it might be of interest to other users.

Greeting Werner

First wait that my Shelly arrives :wink:

And did it work?