Config two remote buttons to one entity switch

Hi all,

I have a SonoFF 433Mhz bridge which I can use to controlle my sunscreen. I’ve set two options on it, one to lower the sunscreen and one to pull it up obviously.

Now I have two entities in HA called.

  • button.sunscreen_up
  • button.sunscreen_down

They work fine seperately but I would like to intergrate them into 1 switch

  • switch.sunscreen_kitchen

So when I click it and it is up it will go down and viceversa. So it will do the opposite action of the last performed action if this makes sense.

How in the world do I do this, I have no programming experience so I’m a bit clueless how to start something like this.

Thanks!

I think you are looking to use a Template Switch:

# Example configuration.yaml entry
switch:
  - platform: template
    switches:
      skylight:
        value_template: "{{ is_state('sensor.skylight', 'on') }}"
        turn_on:
          service: switch.turn_on
          target:
            entity_id: switch.skylight_open
        turn_off:
          service: switch.turn_off
          target:
            entity_id: switch.skylight_close

And then you can use switch.toggle in your automation’s.

1 Like

Do you have a way to know the state of the sunscreen, up or down?

With a template switch…

switch:
  - platform: template
    switches:
      sunscreen_kitchen:
        friendly_name: Kitchen Sunscreen
        # remove value_template if you don't have a binary_sensor (reed switch) on your sunscreen
        # note: ha will assume all commands are successful 
        value_template: "{{ is_state('binary_sensor.sunscreen_kitchen', 'on') }}"
        turn_on:
          - service: button.press
            target:
              entity_id: button.sunscreen_up
        turn_off:
          - service: button.press
            target:
              entity_id: button.sunscreen_down
1 Like

Unfortunatly not.

Both thanks for the reply! I’ll get into this tomorrow! Thanks!