Philips Hue wall switch automation triggered by events

Hi,

I have a Philips Hue wall switch with a bridge (no ZigbeeMQTT integration). When un push the button, I’ve got this event :

event_type: hue_event
data:
  id: interrupteur_salle_a_manger_button
  device_id: d97dd6db2be4fd865104f55725e4fe84
  unique_id: 4b6ee069-b01e-4b17-a2a4-49c0e7f1bbb7
  type: initial_press
  subtype: 1
origin: LOCAL
time_fired: "2022-12-09T06:30:52.879166+00:00"
context:
  id: 01GKTS8R6FW2NA6QD1JP7V1FZ1
  parent_id: null
  user_id: null

When the button is press, I’d like to switch another light (light.guirlande_entree_switch) according to the status of Philips Hue light. If one Hue light (light.abat_jour_salle_a_manger) or more have status ‘On’ in the room, switch should be turn on, otherwise, switch should be turn off.

I’ve tried the following automation but it doesn’t work…

 id: '21'
  alias: 'Switch Button - 1'
  description: ''
  trigger:
    - device_id: d97dd6db2be4fd865104f55725e4fe84
      domain: hue
      platform: device
      subtype: 1
      type: initial_press

  action:
    - delay:
      secondes: 3
    - service: >
      {% if "{{ states('light.abat_jour_salle_a_manger') == 'on' }}" %}
        switch.turn_on
      {% else %}
        switch.turn_off
      {% endif %}
    entity_id:
      - light.guirlande_entree_switch

Thanks you for your help.

What does the automation trace show?
I only have bulbs from Hue so not sure about this… can’t you just add the Hue integration to HA and then use the generated devices from their on?

You dont state what the problem is, other than it does not work, but the following should work.
If not it would be helpful to post the automations trace.

trigger:
  - platform: event
    event_type: hue_event
    event_data:
      unique_id: 4b6ee069-b01e-4b17-a2a4-49c0e7f1bbb7
      type: initial_press
action:
  - delay:     
      seconds: 3      
  - if:
      - condition: state
        entity_id: light.abat_jour_salle_a_manger
        state: "on"
    then:
      - service: light.turn_on
        data: {}
        target:
          entity_id: light.guirlande_entree_switch
    else:
      - service: light.turn_off
        data: {}
        target:
          entity_id: light.guirlande_entree_switch

It works, thank you very much ! :slight_smile:

1 Like