Synch ac with switch

this blueprint is use to link a switch (i use unwired wall switch) to air conditioner.

→ for this to work you will need a switch connected to home assiassistant and an air conditioner connceted to home assiassistant

if you have a smart ac, and smart switch, yo’ll be able to link them together, so you can turn on and off the ac using the wall smart switch.

also, the smart switch will show if the ac [HVAC] is on or off.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

blueprint:
  name: button_with_ac
  description: synch switch with ac
  domain: automation
  source_url: https://github.com/MosheRW/homeAsistantBlueprints/blob/d85a9be8268477a8ef216d02462b2c2019d670bf/sync_ac_with_switch.yaml
  author: Moshe Winberg

  input:

    switch_entity:
      name: switch
      selector:
        entity:
          filter:
            device_class: switch
            domain: switch

    ac_entity:
      name: ac
      selector:
         entity:
          filter:
            domain: climate

mode: single

trigger:
  - platform: state
    entity_id: !input switch_entity
    from: "on"
    to: "off"
    id: switch off
    alias: the switch turned off

  - platform: state
    entity_id: !input switch_entity
    from: "off"
    to: "on"
    id: switch on
    alias: the switch turned on

  - platform: state
    entity_id: !input ac_entity
    from: "off"
    to: null
    id: ac on
    alias: the ac turned on
  
  - platform: state
    entity_id: !input ac_entity
    from: null
    to: "off"
    id: ac off
    alias: the switch turned off





condition:
  - alias: if one of the cons is true
    condition: or
    conditions:
      - alias: if the ac is on
        condition: and
        conditions:        
          - condition: trigger
            id:
              - switch off
          - condition: not
            conditions:
              - condition: state
                entity_id: 
                  - !input ac_entity
                state: "off"
                
      - alias: if the ac is off
        condition: and
        conditions:        
          - condition: trigger
            id:
              - switch on
          - condition: state
            entity_id: !input ac_entity
            state: "off"
                
      - alias: if the switch is on
        condition: and
        conditions:        
          - condition: trigger
            id:
              - ac off
          - condition: not
            conditions:
              - condition: state
                entity_id: !input ac_entity
                state: "on"
                
      - alias: if the switch is off
        condition: and
        conditions:        
          - condition: trigger
            id:
              - ac on
          - condition: not
            conditions:
              - condition: state
                entity_id: !input ac_entity
                state: "off"
  

action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - switch off
        sequence:
          - service: climate.set_hvac_mode
            target:
              entity_id:  !input ac_entity               
            data:
              hvac_mode: "off"         
        alias: ac power off
      - conditions:
          - condition: trigger
            id:
              - switch on
        sequence:
          - service: climate.set_hvac_mode
            target:
              entity_id:  !input ac_entity               
            data:
              hvac_mode: "cool"         

        alias: ac power on
      - conditions:
          - condition: trigger
            id:
              - ac on
        sequence:
          - service: switch.turn_on
            target:
              entity_id: !input switch_entity            
        alias: הפעלת הכפתור

      - conditions:
          - condition: trigger
            id:
              - ac off
        sequence:
          - service: switch.turn_off
            target:
              entity_id: !input switch_entity
            alias: switch power off
        alias: switch power off
 
1 Like

hi there, can you explain more on what is the use-case here?

I have just updated the OG. (I also fixed the documentation, and one bug)