Switch status and changing its value from another switch

I’m a total noob in Home Assistant and hope you can help me. I’ve got three switches for an air con - ‘Aircon Heat 24’, ‘Aircon Cool 20’ and ‘Air Con Power Off’ all controlled by a Broadlink remote.

  - platform: broadlink
    mac: <mac>
    switches:
      - name: Aircon Power
        command_off: 'JgB2...'
      - name: Aircon Cool 20
        command_on: 'JgAG...'
        command_off: 'JgB2...'
      - name: Aircon Heat 24
        command_on: 'JgAG...'
        command_off: 'JgB2...'

They are working as expected. The problem is - I want to change the status of a switch from another switch. Say I pressed ‘Aircon Cool 20’, aircon starts, switch status is on. Now if I press ‘Aircon Heat 24’, then aircon obviously turns to heating, but both ‘Aircon Cool 20’ and ‘Aircon Heat 24’ will be on. And if I press ‘Aircon Power’ twice (turn it on then turn it off) it will turn off the aircon, but both ‘Aircon Cool 20’ and ‘Aircon Heat 24’ will be still on. So I want to change the status for ‘Aircon Cool 20’ to off if I press ‘Aircon Heat 24’ and vice versa. And also want to change ‘Aircon Power’ to on if I press either ‘Aircon Cool 20’ or ‘Aircon Heat 24’ to on. etc. I know that in that particular case it’s overcomplicated and in reality I need only two switches, but I will need all three switches later so let’s say we do need three switches. So how to change the status of one or two switches from another switch?

With automations. For example:

alias: "Cool switch off when heat switch on"
trigger:
  - platform: state
    entity_id: switch.aircon_heat_24
    to: 'on'
action:
  - service: switch.turn_off
    entity_id: switch.aircon_cool_20

alias: "Power switch on when heat/cool switch on"
trigger:
  - platform: state
    entity_id:
      - switch.aircon_heat_24
      - switch.aircon_cool_20
    to: 'on'
action:
  - service: switch.turn_on
    entity_id: switch.aircon_power
1 Like

Thanks a lot, Troon! I’ll try that. Looks like this is exactly what I need.
Every day you learn something new. :slight_smile:

Start here:

The two automations I included above are in YAML because that’s how I roll, but you could create those using the UI editor also.

1 Like

[grumpy old man mode ON] I’ve found that Home Assistant doco (and that applies pretty much to all open source products) is useful when you know what you are doing. If you are new and don’t have a clue then you would never find what to do unless you study all doco. How on Earth I would find that I need to go to Automation section to change status of a switch unless I know Automation. Chicken and egg. Back in mid-80s when I was learning Fortran & Pascal we did everything with simple examples (like “Hello World!”) from a documentation. But this doco is like… Why not creating something like for beginners - you’ve got Sun sensor already - how about creating an automation for sending an email when Sun rises. I know nobody needs that but that would give beginners a good understanding on what automation scrips are and how to use them. [grumpy old man mode OFF] :slight_smile:

Anyway, the above automation works (in a certain way)! BUT! Is it possible to changing state of a switch without an actual action? Like in the above example - when I’m turning ‘Heat 24’ switch on I do not need to send ‘Cool 20’ IR command to a remote control as it will switch AitCon off - I’m sending ‘Heat 24’ command. I only need to change the state of a switch without executing it’s action.

So while the automation works and it does changes the state of a switch it also executes the command associated with that switch and if the AirCon was in Cool 20 mode and I turned Heat 24 then at first it switches to Heat 24 and then turns it off by sending Cool 20 off command. Don’t need that. Need to change only internal status of a switch. Is that possible?

My previous post was meant to be helpful next steps for you, not a remonstration that you should have looked at the docs first.

Sounds to me like you need a “proxy switch” that has no actions attached to it, loosely linked to the “real” switches by automations. You’ll have to figure out the logic though :slight_smile:

Totally understand. No complaints about your comment. It was more like “to keep the conversation going”. :slight_smile:

Anyway… Looks like I have almost found the solution.There are two similar scrips people already developed for exactly the same problem I’ve got:

  1. GitHub - pmazz/ps_hassio_entities: Python script to handle state and attributes of existing sensors and entities

  2. Change Switch state without performing action - #18 by Oligarch

They are very similar, but do pretty much the same thing - changing the status of a switch without performing an action. I tested both and they both work.

I still need to figure out how to stop the sequence of automation running (as it creates the series of status changes and then basically everything goes to ‘off’), but maybe I can combine that with the solution from here: Only changing state of switch, no action - #4 by DvD77

Like turn off all subsequent automations that can be affected by a particular automation, change the status and then turn these automations back.

Still working on it, but I almost can see the light at the end of the tunnel. :slight_smile: