Aqara remote not toggling light

Hello!

I have an aqara T1 switch and an aqara switch H1 (remote) . I want to use the H1 to toggle the T1. The automation is setup as:

alias: Halllampa
description: ''
trigger:
  - platform: event
    event_type: deconz_event
    event_data:
      event_type: deconz_event
      data:
        id: switch
        unique_id: 54:ef:44:10:00:1b:0e:d6
        event: 1002
        device_id: f7778b11f497260a1008c462f8acb4da
      context:
        id: fe6447b19ace9c0950b5efed0e9cb2e5
        parent_id: null
        user_id: null
condition: []
action:
  - type: toggle
    device_id: 682345f900a2ef77734648bcd674b75d
    entity_id: switch.on_off_light_18
    domain: switch
mode: single

I use deconz and in phoscon, when i look in the api i get this:

{
    "16:35:16:767": {
        "e": "changed",
        "id": "18",
        "r": "lights",
        "state": {
            "alert": null,
            "on": false,
            "reachable": true
        },
        "t": "event",
        "uniqueid": "54:ef:44:10:00:07:6c:e0-01"
    }
} 

So i have something happen. The thing is that the light does not toggle. Is there sonething i am doing wrong or could do in another way to get it working?

@lunt I’d check the events using developer tools event tab listening to ‘deconz_event’ to be sure your HA is seeing the same naming as you are seeing.

My triggers look much simpler…

- alias: movie_toggle
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      id: scene_setter
      event: 1002
  action:

I set the name (scene_setter) of the switch in phoscon and then rebooted HA to get it sync’d.

this is the trigger in dev tools:

{
    "event_type": "deconz_event",
    "data": {
        "id": "switch",
        "unique_id": "54:ef:44:10:00:1b:0e:d6",
        "event": 1002,
        "device_id": "f7778b11f497260a1008c462f8acb4da"
    },
    "origin": "LOCAL",
    "time_fired": "2022-01-14T10:25:04.715131+00:00",
    "context": {
        "id": "87d1be8f7ed501386787f82d47e3587d",
        "parent_id": null,
        "user_id": null
    }
}

I find the light in entities looking like


and from here i can toggle it. But i cant get it working in the automation

Ok, I’d ignore the switch entity for now.

Try this to talk to the device you want switched

- id: dining
  alias: one click Dining
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      id: switch
      event: 1002    
  action:
    service: light.toggle
    data:
      entity_id: light.dining
      brightness: 254
      transition: 1

However, if you want to continue to explore process of getting one switch to flick another the syntax you have is wrong.
Try this:

action:
  - service: switch.toggle
    entity_id: switch.on_off_light_18

Thanks! this is how the automation looks now, it still does not toggle the switch though.

alias: Halllampa
description: ''
trigger:
  - platform: event
    event_type: deconz_event
    event_data:
      event_type: deconz_event
      data:
        id: switch
        unique_id: 54:ef:44:10:00:1b:0e:d6
        event: 1002
        device_id: f7778b11f497260a1008c462f8acb4da
action:
  - service: switch.toggle
    target:
      entity_id: switch.on_off_light_18
mode: single

This is how it looks in services in dev tools and when i run “call service” there it toggles the switch for the light.

service: switch.toggle
target:
  entity_id: switch.on_off_light_18

The action part looks the same but does not work for some reason.

It seems like my automation dont want to trigger “call service” I added “call service: turn off” to the other button on the remote where i also have “turn off” on some other lamps. The turn off for the lights works but not the call service.

@lunt how about you put something else in the action to prove your trigger works. Note that I don’t use unique_id nor device_id in my automations. Did you try without those? Did you try my exact trigger ? Yours still looks wrong to me.

In dev tools ‘call service’ calls the action service ignoring the trigger.

I tried using this:

alias: Släck tak
description: Släck alla taklampor
trigger:
  - platform: event
    event_type: ''
    event_data:
      event_type: deconz_event
      data:
        id: switch
        unique_id: 54:ef:44:10:00:1b:0e:d6
        event: 2002
        device_id: f7778b11f497260a1008c462f8acb4da
condition: []
action:
  - type: turn_off
    device_id: 2868aefd11e5b330e94daaf9ac6505db
    entity_id: light.bedroom
    domain: light
  - type: turn_off
    device_id: 09607ce5039191937fa0d2175cdff7df
    entity_id: light.dimmable_light_2
    domain: light
  - type: turn_off
    device_id: 9714c981620286c02eb9697fc8dcdfd8
    entity_id: switch.on_off_light_15
    domain: switch
  - type: turn_off
    device_id: f989dbabf5e5f3facdd7ce191716b3ec
    entity_id: light.group_9
    domain: light
  - type: turn_off
    device_id: 98d189aa2be2859a0e02965c8cda6031
    entity_id: switch.on_off_light_13
    domain: switch
  - type: turn_off
    device_id: 98d189aa2be2859a0e02965c8cda6031
    entity_id: switch.on_off_light_14
    domain: switch
  - service: switch.turn_off
    target:
      entity_id:
        - switch.on_off_light_13
        - switch.on_off_light_14
        - switch.on_off_light_18
mode: single

Everything with type “turn_off” works as it should, but everything with “service” is not triggered.
It works both with and without “unique_id” and “entity_id” as well.

i tried your exact trigger and got the error

Message malformed: required key not provided @ data['trigger'][0]['platform']

Our timezones don’t see to match too well, I am in Sydney Australia…

On the basis that your examples have no leading spaces nor ‘-’ indents I am wondering where you are entering this?

Have you explored the automation debug facility?
To use this your automation must have an id. So put

id: test

directly under the alias: line.

Then reload your automation and go to ‘automations & scenes’ under the configuration section.

There you will see a list of your automations. Click on the icon that sort of looks like a clock face.

Then look at the flow it shows and click on each circle to explore what goes on.

NB the data and time at the top allows you to select which version/triggering of the automation you are looking at, so beware of looking at older ones.

The error you got with my trigger will be due to alignment of my text not matching yours, eg if your automations start with trigger: with no leading spaces and mine has ‘- trigger:’ you need to remove that and adjust the spacing of the subsequent rows.

when i copy it entirely and just change parts to fit my setup:

- id: hallampa
  alias: hallampa
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      id: switch
      event: 1002    
  action:
    service: switch.toggle
    data:
      entity_id: switch.on_off_light_18

i get error

Message malformed: expected dictionary

I am not familiar with the debugger, but when i run it i see this. The version is updated just a few minutes ago so it is the latest one.


top circle, with a star is selected.

debug2

bottom circlle with an arrow is selected.

Ok, I copied your automation and tweaked it for my devices. I get the same automation information you did - once I pressed ‘run actions’ which ignores the trigger and just runs the actions.
So, it is clear to me that your trigger code is where the problem is.

Go back to my simple trigger code (with your id and event) and ensure that the indents(leading spaces) line up with any other code in your yaml file.

Using the simple trigger code with action added looks like this. completly copied, only tweaked the ids.

- id: hall
  alias: hallampa
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      id: switch
      event: 1002    
  action:
    service: switch.toggle
    data:
      entity_id: switch.on_off_light_18

it gives this error message

Message malformed: expected dictionary

The indents are 1, 2 and 3 tabs respectively.