Linking Xiaomi smart switch to Deconz

I think the reason for this failing is that you do the initial request to a 10.0.x.x adress where as deconz is telling hass that it got the ipaddress 192.168.x.x.

Thst explains the no route to host

Duh. Yes, I can see that now. Thanks for the extra pair of eyes.

I’m using the Deconz ready-made Raspian image from Desden Elektronik, and it comes readily set up as a wifi access point using dnsmasq and hostapd. Among other things it did set 192.168.8.1 as static ip adress on wlan0 in dhcpcd.conf.

I cleaned up all the network settings and now everything seems to be working as expected. Thanks again.

But I do not think it makes much sense to switch to the ip adress reported by the Deconz api. Even with Deconz running in a multi-homed environment, you should probably stick to the ip adress configured in Hass. Since you are talking successfully to the api, you know that this address working fine.

1 Like

I agree. Didn’t see a reason behind not using the one reported. But this is a clear example. Will fix this for next release.

1 Like

I’ve got three Xiaomi Wireless Buttons that doesnt seem to register correctly. Im running Deconz on my rasberry pi that’s also hosting HASS.io.

I’ve got IKEA lights, Philips Dimmer remote and Xiaomi Temperature and Door sensors working.

I’m unable to see any communication in the homeassistant.log when running the deconz component in debug mode. Pressing the button results in nothing.

2018-02-24 13:08:42 DEBUG (MainThread) [pydeconz.websocket] Websocket data: b'\x81t{"e":"changed","id":"21","r":"sensors","state":{"buttonevent":7000,"lastupdated":"2018-02-24T12:08:42"},"t":"event"}'
2018-02-24 13:08:42 DEBUG (MainThread) [pydeconz] Not supported event {'e': 'changed', 'id': '21', 'r': 'sensors', 'state': {'buttonevent': 7000, 

Any ideas on how to solve this?

I’m linking by opening the network in Deconz and pressing the link button until the blue flashes stop. This registers the device in Deconz without a buttonid. When I press the button it registers the buttonevent as 7000.

Have you restarted hass after adding the device? The not supported event can happen when you’ve got a new entity that hasn’t a representation in pydeconz yet, and right now that only happen on start

DId not know that. That error is now, with this new knowledge a non issue. However I’m still not getting any feedback in homeassistant.log from pressing the button on the remote.

Using:

 logger:
   default: critical
   logs:
     homeassistant.components.deconz: debug
     pydeconz: debug

Actually that’s not entirerly true. My hass.io Deconz add-on log says the following:

19:53:33:633 LightNode 1: living_room_floor added
19:53:33:634 device discover rotate, node 0x000b57fffe304102 is in wait state
19:53:33:788 0x000B57FFFE304102 onOff 0 → 1
19:53:34:041 0x000B57FFFE304102 level 0 → 200
19:53:34:109 CTRL restore cached node 0x00158d0001e5a6ac
19:53:34:112 new node - ext: 0x00158d0001e5a6ac, nwk: 0x4550
19:53:34:112 SensorNode 6 set node 0x00158d0001e5a6ac
19:53:52:546 scan skip host .44
19:54:02:849 scan finished
19:54:02:951 ZCL attribute report 0x000B57FFFE304102 for cluster 0x0006
19:54:03:008 ZCL attribute report 0x000B57FFFE304102 for cluster 0x0300
19:54:03:027 ZCL attribute report 0x000B57FFFE304102 for cluster 0x0008
19:54:04:490 Poll APS request to 0x000B57FFFE304102 cluster: 0x0006 dropped, values are fresh enough
19:54:04:680 Poll APS request to 0x000B57FFFE304102 cluster: 0x0008 dropped, values are fresh enough
19:54:04:774 Poll APS request to 0x000B57FFFE304102 cluster: 0x0300 dropped, values are fresh enough
19:54:06:108 no button handler for: lumi.sensor_switch.aq3 cl: 0x0012 cmd: 0x0A pl[0]: 055

That sounds like an issue. Is that out of reach and something that has to do with deconz? If so, then it should effect all Xiaomi Wireless Remotes (square) unless there’s different configurations (regional hw-variations or something).

Unfortunately I don’t know what that error means. But if you see the error in deconz then it has nothing to do with the hass integration.

I recommend you to open an issue on deconz github to resolve that error.

The message above does not seem to matter. I’ve noticed that I get that for my Hue Dimmer Switch which is working as expected.

The Xiaomi Wireless Switch is registered with buttonevent 7000 which I can verify both in the API with Postman and in the HA log. I recieve this message when I double click on the button.

2018-02-26 11:02:57 DEBUG (MainThread) [pydeconz.websocket] Websocket data: b'\x81s{"e":"changed","id":"6","r":"sensors","state":{"buttonevent":7000,"lastupdated":"2018-02-26T10:02:57"},"t":"event"}'
2018-02-26 11:02:57 DEBUG (MainThread) [pydeconz.deconzdevice] switch_a: update buttonevent with 7000
2018-02-26 11:02:57 DEBUG (MainThread) [pydeconz.deconzdevice] switch_a: update lastupdated with 2018-02-26T10:02:57

This automation works:

- alias: 'Toggle lamp from Xiaomi Wireless Remote A'
  # initial_state: 'on'
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      id: switch_a
      event: 7000
  action:
    - service: light.toggle
      entity_id: light.living_room_floor

Buttonevents:

Single: none
Double: 7000
Long: none
Shake: none (read that this device might support that)

Is this handeling something that Deconz needs to update or is there something weird going on with these devices? Would it be the correct place to rise an issue here:

Yeah. Create an issue with that github. Give them as much info as possible

Hey, I am relatively new to home assistant. I installed Hassabian on my Pi3 and integrated a Sonoff Tasmota Switch via MQTT and it looks and works fine.
Now I tried setting up deconz and integrating a Xiaomi Wireless Smart Switch (the round one). But I fail to make it work properly.
For Deconz i added the following to config:

  deconz:
  host: 192.XXX.XXX.XX
  api_key: 41AXXXXXX
  port: 80

In HA log I can see this, when perfoming a single click on the button:

2018-03-24 16:17:58 DEBUG (MainThread) [pydeconz.websocket] Websocket data: b'\x81s{"e":"changed","id":"2","r":"sensors","state":{"buttonevent":1002,"lastupdated":"2018-03-24T15:17:58"},"t":"event"}'
2018-03-24 16:17:58 DEBUG (MainThread) [pydeconz.deconzdevice] Switch 2: update lastupdated with 
2018-03-24T15:17:58
2018-03-24 16:17:58 DEBUG (MainThread) [pydeconz.deconzdevice] Switch 2: update buttonevent with 1002

Which looks good to me. Now I tried to implement it via automations like this:

  - alias: 'Toggle lamp Fenster'
trigger:
  platform: event
  event_type: deconz_event
  event_data:
    id: 'Switch 2'
    event: 1002
action:
    service: homeassistant.toggle
    entity_id: switch.fensterswitch

In HASS I see the automatization and when I trigger it, it works fine. But when I press the xiaomi button nothing happens. What am I doing wrong? @johga can you help? Maybe I just need a second pair of eyes. As said relatively new to all of this.

The id can’t be “Switch 2” it probably is something like switch_2

2 Likes

That was easy. Thank you, it works perfectly now.

1 Like

Hi @Robban i successfully added a Xiaomi Smart Switch and works fine with automations, but this switch shouldn’t expose a long press event? I can see only 2 events in the logs, 1000 when I press and 1002 when I release the button

2018-05-05 12:09:52 DEBUG (MainThread) [pydeconz.websocket] Websocket data: b'\x81s{"e":"changed","id":"5","r":"sensors","state":{"buttonevent":1000,"lastupdated":"2018-05-05T10:09:52"},"t":"event"}'
2018-05-05 12:09:52 DEBUG (MainThread) [pydeconz.deconzdevice] lumi.sensor_switch: update buttonevent with 1000
2018-05-05 12:09:52 DEBUG (MainThread) [pydeconz.deconzdevice] lumi.sensor_switch: update lastupdated with 2018-05-05T10:09:52
2018-05-05 12:09:52 INFO (MainThread) [homeassistant.core] Bus:Handling <Event deconz_event[R]: id=lumisensor_switch, event=1000>
2018-05-05 12:09:53 DEBUG (MainThread) [pydeconz.websocket] Websocket data: b'\x81s{"e":"changed","id":"5","r":"sensors","state":{"buttonevent":1002,"lastupdated":"2018-05-05T10:09:53"},"t":"event"}'
2018-05-05 12:09:53 DEBUG (MainThread) [pydeconz.deconzdevice] lumi.sensor_switch: update buttonevent with 1002
2018-05-05 12:09:53 DEBUG (MainThread) [pydeconz.deconzdevice] lumi.sensor_switch: update lastupdated with 2018-05-05T10:09:53
1 Like

The component doesn’t filter or alter any messages, so if the button should expose long press, etc. then it is something in deconz that needs to be changed.

I suggest put an issue on deconz rest api GitHub.

You’re right, i found in this page https://github.com/dresden-elektronik/deconz-rest-plugin/wiki/Supported-Devices
all the supported device and their events
The Xiaomi Smart switch doesnt have hold but triple and quaduple press!

1 Like

There are two different Xiaomi Smart Switches (or buttons).

The round one (original version) and the square one (new Aqara version). The round one expose long press, the square one does not.

But you have to realize there is no such thing as a “long press” event. There is the “pushed down” event (1000), and the “released” (1002) event. You will have to make the logic to decide when the time difference between “push” and “release” qualify as a “long press”.

If you search the forum you will find example automations for the round switch/button. I use a appdaemon script that works fine for dimming lights up and down.

The square button does not have a “pushed down” event so it can not expose a “long press”.

1 Like

Great that you found that!

Excellent tip!

Great, I have the round one.
Searching in the forum I found this Finally - a cheap WIRELESS switch that dims! Xiaomi Switch Gen1 but in the automation is used long_click_press as click type, I think the that the switch is used with the xiaomi gateway.
Can you post your script @aherbjornsen?

@B1G I use the one referenced here: