Introduction to Automation with Deconz and Hass.io

switch
xiaomi
automation
Tags: #<Tag:0x00007fd07cdbb0d8> #<Tag:0x00007fd07cdbaa70> #<Tag:0x00007fd07cdba368>

#1

Hi all,

please excuse my very noob question. After some initial struggling I have setup hass io and Deconz on my raspberry pi, it seems to be working flawlessly.

The next goal would be to automatically switch on my hallway light when the door opens. For that purpose I have connected a Xiaomi Door Sensor to the Deconz extension. It is shown there corrrectly, with its current status, e.g. door open / closed, and my Hue bulb in the hallway is connected to HA.

Now, I’ve read through the deconz documentation, but it’s too advanced for me. And no matter what I search for, I cannot seem to ‘find’ a guide in how to ‘code’ or a beginner’s introduction to Home Assisstant.
I am familiar with Data Science-y Coding, Java, R, Python, but still can’t seem to get the hang of it.

Therefore: I am more than willing to learn, but would appreciate if someone could point me to some beginning resources. Especially regarding:

  • High Level Introduction, e.g. how is ‘automation’, ‘trigger’, ‘action’ defined in the context of home assistant,
  • Maybe even ‘best-practice’ coding
  • In the context of DeConz, how can I read the status of my sensor? This link should probably help me understand it, but I am missing background information to actually make sense of what it’s telling me

I hope I’ve shown I am trying to do my own research, and am willing to code the scripts myself, but am also running out of ways I can think of to help me here.

Thanks already!


#2

I have almost the exact “problem”. After a few years using a BeagleBone with 433mhz, it died last week. Now I have a fresh raspberry pi 3 b+ with the raspbee from Deconz. Every hue bulb and motion sensor and ikea bulb is coupled. The first Xiaomi aqara sensors are on their way… But I have no clue how to rewrite my 45 automations based on the 433mhz motion sensor and hue bridge… I really need some examples.

The old ones look like this:

- id: automation 44
  alias: badkamer aan ochtend
  trigger:
    - platform: state
      entity_id: binary_sensor.bewegingbadkamer
      to: 'on'
  condition:
    - condition: time
      before: '09:00:00'
      after: '06:00:00'
  action:
    service: homeassistant.turn_on
    entity_id: script.timed_lamp13

- id: automation 45
  alias: badkamer aan overdag
  trigger:
    - platform: state
      entity_id: binary_sensor.bewegingbadkamer
      to: 'on'
  condition:
      - condition: time
        before: '23:30:00'
        after: '09:00:01'
  action:
    service: homeassistant.turn_on
    entity_id: script.timed_lamp14


- id: automation 46
  alias: badkamer aan nacht
  trigger:
    - platform: state
      entity_id: binary_sensor.bewegingbadkamer
      to: 'on'
  condition:
    - condition: time
      before: '05:59:55'
      after: '23:30:05'
  action:
    service: homeassistant.turn_on
    entity_id: script.timed_lamp15

with these scripts :

timed_lamp13:
  alias: "badkamer ochtend"
  sequence:
    # Cancel ev. old timers
    - service: script.turn_off
      data:
        entity_id: script.timer_off13
    - service: light.turn_on
      data:
        entity_id: light.badkamer
        brightness: 254
        color_temp: 156
        #rgb_color: [255, 230, 192]
    # Set new timer
    - service: script.turn_on
      data:
        entity_id: script.timer_off13

timed_lamp14:
  alias: "badkamer overdag"
  sequence:
    # Cancel ev. old timers
    - service: script.turn_off
      data:
        entity_id: script.timer_off14
    - service: light.turn_on
      data:
        entity_id: light.badkamer
        brightness: 240
        color_temp: 346
        #rgb_color: [255, 204, 127]
    # Set new timer
    - service: script.turn_on
      data:
        entity_id: script.timer_off13

timer_off13:
  alias: "lamp uit na 10 minuten"
  sequence:
    - delay:
        minutes: 10
    - service: light.turn_off
      data:
        entity_id: light.badkamer

Is there someone who can give a few hints? Thanks a lot!


#3

Tonight I found out how to get it working… And it is actually quite simple…

I only needed to update the names of sensors and bulbs (because I gave them just a little different names when I coupled them to raspbee) . Everything works just like it did.
conclusion: Great add-on!


#4

Great news!
What name did you actually end up using? Because if I use binary_sensor.Main_Door (that’s the name I gave the sensor in Deconz) it doesn’t work. What else am I doing wrong?


#5

I use the name the sensor has according to home-assistant. You find it in the http://hassio.local:8123/dev-state . (the menu with < > )
Maybe home-assistant made another name?


#6

Hm… I can’t see the sensor there. It shows my Hue lights and the sun, but no Binary Aqara sensor.

I seem to have a different issue. Even though I can see the sensor (and see it change its state) in the phoscon extension, communication with Hass.io seems to be flawed. If I check the Deconz Log this is what I see:

06:30:18:743 no button map for: lumi.sensor_magnet.aq2 ep: 0x01 cl: 0x0000 cmd: 0x0A pl[0]: 001
06:30:18:743 ZCL attribute report 0x00158D000276C361 for cluster 0x0000, ep 0x01
06:30:18:743 0x00158D000276C361 extract Xiaomi special attribute 0xFF01
06:30:18:743 	01 battery 3015 (0x0BC7)
06:30:18:743 	03 temperature 21 °C
06:30:18:743 	04 unknown 5032 (0x13A8)
06:30:18:743 	05 RSSI dB (?) 77 (0x004D)
06:30:18:743 	06 LQI (?) 4294967296 (0x0100000000)
06:30:18:743 	0a unknown 0 (0x0000)
06:30:18:743 	64 on/off 0
06:30:22:829 Current channel 25
06:30:22:851 Device TTL 3464 s
06:30:28:825 dev /dev/ttyAMA0
06:30:28:825 GW firmware version: 0x262f0500
06:30:28:825 GW firmware version is up to date: 0x262f0500

There seem to be two problems:

  • The device (entity? Still shaky on the terms) I thought was called binary_sensor.Main_Door (since that’s its name in Deconz) gets communicated to Hass.Io as lumi.sensor_magnet.aq2
  • There is ‘no button map found’ for this device (which I can’t interpret)

Can anyone help on this? Extensive googling showed no solution, people seem to simply have updated their phoscon gateway (mine is already up to date).

Thanks!


#7

Ok. I think that if home-assistant can’t see the sensor, you can’t use it.
I don’t know (jet) how to fix this. My hue motion sensor shows up good.
I ordered two Aqara motion sensors. Receive them in two weeks.


#8

Thanks anyways, I’ll keep at it!