Automation: Broadlink TC2 Switch Turn On / Off

Hi,

Anyone know how to automate turning on Broadlink TC2 switch?

I have this working in HA user interface but need to automate based on presence detection.

I have the following in configuration.yaml:

switch:
  - platform: broadlink
    host: 192.168.xxx.xxx
    mac: xx.xx.xx.xx.xx
    timeout: 30
    friendly_name: "RM2"
    switches:
      lounge_light:
        friendly_name: "Lounge Light"
        command_on: '6RRGAN8JCRYJFhYJCRYJFhYJFgkWCQkWCRYJFgkWCRYWCQkWCRYWCQkWFgkWCQkWCRYWCQkWFgkJFgkWCRYWCQkWFgkJFgkAAUg='
        command_off: '6RRGAN8JFgkWCQkWCRYWCQkWFgkJFhYJFgkJFgkWCRYWCQkWCRYJFgkWFgkJFgkWFgkJFgkWCRYWCQkWFgkWCQkWCRYWCQkAAUg='

    automation:
      - alias: 'I'm Home' 
        trigger:
          platform: state  
          entity_id: device_tracker.mobilephone
          from: 'not_home'
          to: 'home'  
        action:
          - service: switch.turn_on
            entity_id: switch.1_lounge_light

There is automation toggle on the HA user interface but it does not do anything. Is the yaml code wrong?

Try it like this

   action:
          - service: broadlink.send_packet_192_168_50_238
            data:
              packet:
                - "JgBQAAABJpUUERI5EjgSExIUERQSExI4FDcRORQ2EjkTNxI5ETkTNxQ3EzcSExQ3ETkSExITEhQTEhITEjgSFBMSETkSOBI5EwAEowABKEkRAA0FAAAAAAAAAAA="

use …

entity_id: switch.lounge_light

instead :slight_smile: