Xiaomi Aqara Smart Wireless Switch with Deconz

Thanks for the detailed breakdown, mihalski, this made my life a lot easier. Appreciate this community so much!

If you’re up to creating a custom_component by modifying the existing Deconz integration you could follow this:

Hi all,

I have the same problem here with my IKEA Switch. It’s set up through deConz (on Conbee II) - not ZHA - and it was working perfectly until a couple of days ago. Home assistant was recognizing 2 entities for this device: one as Switch and one as Sensor-battery level).

I set up my automation very easily using Device->Turn On button pressed, and the action would simply turn on my light bulb. All was working perfectly.
Switch%20OK

All of a sudden, the switch has disappeared as entity from HA, and I can only see the battery sensor. The switch does not appear in any device list. I checked in Developer Tools-> States and it’s not there either. The only thing I see is the battery sensor, nothing else:

Anyone has any idea what could have caused this and how it could be fixed?

I have the same issue with an Xiaomi Switch (firmware 09-27-2017) that only shows as a battery level sensor. When I try to listen to deconz_event nothing is fired in HA. Any clues?

Seems like it’s normal…
I solved this problem by using deconz_event as trigger. See below:

- id: '1576874566498'
  alias: Switch ON-OFF
  description: ''
  trigger:
  - platform: event
    event_type: deconz_event
    event_data:
      event: 1002
      id: your_switch_name #this is the name used in your Conbee (in the Phoscon web app)
  condition: []
  action:
  - service: light.toggle
    entity_id: light.name_of_your_light

Let me know if it works for you.

-nik

Got it working, had to re add the device to deconz / phoscon for it to work. All good now!

Thank you for your answer, it is working in my setup too. Unfortunately I’m not completely satisfied with the solution, because until I added th last round of updates it was much easier, because I could just choose the button in the GUI when setting up an automation. Now I have to code anything by hand ???
Unfortunately I did the updates for hass.io and deconz at the same time. So I’m not able to say which of the components broke the interoperability :frowning:

You don’t have to code everything manually.
You only need to enter your switch’s ID & event in the additional data code box inside the GUI’s automation set up menu. It’s just 2 lines:
Capture

You can trigger different events based on different pushes. For example, I toggle my lights with a normal push (1002), I toggle the room’s motion sensor automation with a long push (1001), and I cycle through the room’s scenes using double-push (1004). It’s working fine, and it’s not difficult to set the triggers. You can easily copy past the code from one automation to another and simply change the ID and event as needed.

Until the last updates I was able to select anything from lists. Now I have to enter at least three things (Event type, event and id) manually. This isn’t very comfortable, at least when it was functioning well before…

That is true, yes, you are right. I don’t know why they did this. Surely, it’s much easier to set up everything without any code but, overall, the deconz_event set up is not that complicated.

Hey Martin, I don’t know if you managed to make this work.
In any case from version 0.105 on, you now have the switches normally appearing in the device drop down again. So you don’t have to use deconz_event and code anymore. Hope it helps.

Hello I also struggeling to get a Xiaomi smart switch working as a doorbell.
I did listen to deconz_event and it is showing up:

{
    "event_type": "deconz_event",
    "data": {
        "id": "deurbel_xiaomi",
        "unique_id": "00:15:8d:00:04:01:91:cc",
        "event": 1002
    },
    "origin": "LOCAL",
    "time_fired": "2020-03-07T14:50:17.065551+00:00",
    "context": {
        "id": "7b33e82521dc4f538331e9e95d008700",
        "parent_id": null,
        "user_id": null
    }
}

So there is some activity registred by pushing the button.
But I still not know how to use this information as a trigger in node RED to activate a que ringing a doorbell.
Any help please?

EDIT:
I did found out and is working:

Knipsel2

I just caught your post about how you cycle your scenes with the same “long press toggle”. Can you explain the automation to have it cycle?

The easiest way to create an automation with an aqara smart switch is in the Phoscon integration in configuration/integrations/. Double click there on the device you want to use and then, in the new screen, on + in automations in order to create a new automation. The resulting automation appears in automations.yaml similar to what [mihalski] showed here above.

1 Like

How can I create an Aqara Smart Switch automation trigger for any type of event?

Using ‘trigger.event.data.event’ I found the following trigger type numbers:

“Turn on” button pressed 1000 remote_button_short_press
“Turn on” button released 1002 remote_button_short_release
“Turn on” button double clicked 1004 remote_button_double_press
“Turn on” button triple clicked 1005 remote_button_triple_press
“Turn on” button quadruple clicked 1006 remote_button_quadruple_press
“Turn on” button quintuple clicked 1010 remote_button_quintuple_press
“Turn on” button continuously pressed 1001 remote_button_long_press
“Turn on” button released after long press 1003 remote_button_long_release

I would like to have a general trigger, independent of the type (called “event” in the data), for use in an automation. Then, in the action part, I want to have actions depending on the type number. Otherwise you would have to create separate automations for the various “Turn on” options.

Does anybody have a solution for a trigger that works without a specification of the “Turn on” option?

@mhh I always look right at this but for some reason, I never use it. I need to start doing this more because this was the simplest way. Thanks.