Yoda-x / ha-zha-new

update of the zha component
56 stars 10 forks source link

Support of Aqara devices needs different device names #6

Closed ChristianHackAMS closed 6 years ago

ChristianHackAMS commented 6 years ago
zha_new:
    usb_path: /dev/ttyUSB1
    database_path: /config/zigbee.db
    device_config: 
# HT sensor    
      "00:15:8d:00:01:9f:df:de-1":
        type: sensor
        in_cluster: [0x0000, 0x0001, 0x0003, 0x0009, 0xff01, 0xffff]
        config_report:
          - [ 0x0405, 0, 1, 120, 5]
          - [ 0x0403, 0, 1, 120, 5]
          - [ 0x0402, 0, 1, 120, 5]
# Door sensor
      "00:15:8d:00:01:e4:4d:d3-1":
        type: binary_sensor
        in_cluster: [ 0, 25, 3,  0xffff ]
        out_cluster: [ 0, 3, 4, 5, 8, 6, 25]
        config_report:
          - [ 1, 20, 1, 1200, 10]
          - [ 6, 0, 1, 120, '01']
# Motion sensor
      "00:15:8d:00:01:65:78:d6-1":
        type: binary_sensor
        in_cluster: [ 0, 1, 25, 3,  0xffff ]
        out_cluster: [ 0,1, 3, 4, 5, 8, 6, 25]
        config_report:
          - [ 1, 20, 1, 1200, 10]
          - [ 0x406, 0, 1, 1200, '01']

Have these three Aqara sensors working but need devices symlinks (pressure received but not working) :

lrwxrwxrwx 1 root root   21 Jan  7 18:18 lumi_sensor_magnet_aq2.py -> lumi_sensor_magnet.py
lrwxrwxrwx 1 root root   21 Jan  7 18:19 lumi_sensor_motion_aq2.py -> lumi_sensor_magnet.py

This at least gets them working initially

Still having some problems with devices leaving the network though.

ChristianHackAMS commented 6 years ago

And also

lrwxrwxrwx 1 root root   21 Jan  7 18:19 lumi_weather.py -> lumi_sensor_magnet.py
Yoda-x commented 6 years ago

Thanks for testing. I will add the links to my next dev tree update. Coming changes will be: -support for pressure sensor -aquara symlinks -tradfri wireless dimmer support -tradfri dimmable bulb support -autodectection of xiaomi sensors -template support in configuration yaml for devices

The problem with leaving devices is on my list, I'm currently unsure how to remove devices from HASS and track the related entities for a device. Also some devices not leave the network in a proper way., e.g the tradfri bulbs just join the network again without leaving first, which the underlaying bellows API don't like. And the last bellows update was in october with many patches outstanding.

Thanks

Yoda-x commented 6 years ago

please give my dev-loader branch a try. it has all the changes noted above

ChristianHackAMS commented 6 years ago

Thanks

I've been running it today and it's working OK (weather, door switch and motion - all Aqara). That said I had been running your master overnight and that seemed to work OK too. In total about 14 hours now. Extra data like battery voltage is working too.

I had the pressure sensor working on mine already with basically the same code as you've added. I note on the pressure sensor though there's a secondary attribute 16 that reports hPa/mbar in units of 0.1 as compared to attribute 0 which is whole units. Not sure why - the data seems reasonable and not noisy. The attribute 0 value seems truncated rather than rounded too i.e 16=1010.9 would show 0=1010 although that really only shifts the value by 0.5.

My problem with devices leaving was because I wasn't running your version of bellows. The master branch of it has a couple of typos in bellows bellows\bellows\zigbee\zcl\clusters\manufacturer_specific.py that won't even parse properly preventing the component from running at all.

Yoda-x commented 6 years ago

Hello, thanks for your feedback, I moved the the dev-loader branch to master. I don't think it makes sense to look for attribute 16, The pressure measurement will not be that exact. I will receive this week also some aqara sensors, then I can check if they provide more or different information. Also some power plugs are on the way from a different vendor to my place.

Please let me know if you run in problems.

ChristianHackAMS commented 6 years ago

The problem with the pressure reading is that it only leaves about 20-30 valid readings if whole mbar/hPa are used in a normal environment (say 985-1015 hPa). e.g. my 2 sensors have only reported 1009, 1010, 1011, 1012, and 1013 in the past 24 hours or so.

I have two humidity, temp, pressure, two motion sensors and one door sensor all seemingly working ok now.

I added one motion and one weather sensor this morning but didn't add anything to the configuration.yaml file. They seem to be working fine and reporting the same data. Is the configuration.yaml with the EUI etc still required?

Yoda-x commented 6 years ago

You don't need to define the sensors inside the configuration.yaml anymore. For the xiaomi sensors the model name can be read during the init phase. And then zha uses the settings from the device file,

It seems, the sensors report only a value, when something changes. Even if they shoud send an update every hour, but they just ignore this. Btw, did you re-paired your sensors or just restarted HA? I'm asking because, the attribute report config gets written only during the paring, only then the sensor is not sleeping and accepts write requests. Your may also change inside the lumi_sensor_magnet.py [ 0x0403, 0, 10, 3600, 5], to [ 0x0403, 0, 10, 3600, 1], to increase sensitivty

ChristianHackAMS commented 6 years ago

I didn't re-pair, no for my first 3. For my additional PIR and weather sensor they were only paired after the big update. I'm happy enough with the current reporting rate and yes they only seem to report on a large enough change which is fair enough (my test for the weather sensor was to blow on it).

The one thing I would like to work a bit better is the PIR range. Not sure if there's any ability to adjust that. Currently I only get about 3-4 meters best case which is about half the claimed range and sometimes they don't seem to trigger right away. In the dark seem slightly worse again. I wanted to set up a couple of automations light hallway lights. I have ordered their gateway as it's cheap and I can use it independently in HA so I'll try them on it and see if they're any better there.

Would that sensitivity change affect the PIR do you think?

Should I see cards for the senors? I only get the little icons at the top in blue/red

image

Aside from that, it all seems to be working quite well.

Yoda-x commented 6 years ago

The icons are normal. If you create groups with sensors you get the cards, like the one I posted in the bellows issue forum . I also set some entiies to hidden, if they are empty, they have no state attribute or never change. Currently I get an entity for any endpoint, plus the entities for the sensors. The sensitivity of the PIR sensor may changeble with a write to an attribute, but not sure if it exists for Xiaomi. Let me know if you see options with the xiaomi gateway. I'm working currently to add attribute discovery, This would help to identify what options are available. I got my Aqura magnet and weather sensors and will add some code to cover them better in future. Also on my list is to report battery_level as state value for these empty sensors, then at least something meaninful shows up. I will push an update with changes and improvements in a few days.