doudz / zigate

python lib for zigate
MIT License
46 stars 22 forks source link

[New feature]&[Bug] "Permit join" for specific router #186

Open pawelka opened 4 years ago

pawelka commented 4 years ago

According https://github.com/Koenkk/zigbee-herdsman/issues/81 it's possible to permit join for specific router only. This should help in case of some aqara sensors like (door sensor) which rejoin to network in on specific way not compliant with standard, so zigate coordinator doesn't see sensor after few days (after try to rejoin). Probably joining to aqara wall swich (with neutral - act as router) should solve the problem because it's aqara router.

It will be nice to have also button from UI or at least parameter in service with address or entity.

pawelka commented 4 years ago

I successfully force router to permit join by using raw command service, but I face another problem while adding device. Device was added, but ieee address wasn't know at that time, but few second later, which cause a problem to update old entity in home assistant. The new entity was create and two entities for the same ieee exists :-/

Logs from adding:

2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] Received response 0x8102: b'00e1500100000005004200126c756d692e73656e736f725f6d61676e6574' 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] RESPONSE 0x8102 - Individual Attribute Report : sequence:0, addr:e150, endpoint:1, cluster:0, attribute:5, status:0, data_type:66, size:18, data:lumi.sensor_magnet, lqi:189 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] Received response 0x8102: b'01e1500100000001002000010a' 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] RESPONSE 0x8102 - Individual Attribute Report : sequence:1, addr:e150, endpoint:1, cluster:0, attribute:1, status:0, data_type:32, size:1, data:10, lqi:189 2020-05-08 16:53:25 ERROR (ZiGate-Decode data) [zigate] IEEE is missing for e150, please pair it again ! 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] Acquire Lock on device Device (e150) None 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [custom_components.zigate] Add device Device (e150) None 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] Release Lock on device Device (e150) None 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] Acquire Lock on device Device (e150) None 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] Release Lock on device Device (e150) None 2020-05-08 16:53:25 ERROR (ZiGate-Decode data) [zigate] IEEE is missing for e150, please pair it again ! 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] Received response 0x8102: b'02e150010000ff0200420013100021a90b21a80124000000000021c11d2057' 2020-05-08 16:53:25 ERROR (ZiGate-Decode data) [zigate] IEEE is missing for e150, please pair it again ! 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] RESPONSE 0x8102 - Individual Attribute Report : sequence:2, addr:e150, endpoint:1, cluster:0, attribute:65282, status:0, data_type:66, size:19, data:100021a90b21a80124000000000021c11d2057, lqi:189 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] Acquire Lock on device Device (e150) None 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] Acquire Lock on device Device (e150) None 2020-05-08 16:53:25 ERROR (MainThread) [zigate] IEEE is missing for e150, please pair it again ! 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] Release Lock on device Device (e150) None 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] Release Lock on device Device (e150) None 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [custom_components.zigate] Update device Device (e150) None 2020-05-08 16:53:25 ERROR (ZiGate-Decode data) [zigate] IEEE is missing for e150, please pair it again ! 2020-05-08 16:53:25 ERROR (ZiGate-Decode data) [zigate] IEEE is missing for e150, please pair it again ! 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] Acquire Lock on device Device (e150) None 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] discover_device e150 2020-05-08 16:53:25 ERROR (ZiGate-Decode data) [zigate] IEEE is missing for e150, please pair it again ! 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] Release Lock on device Device (e150) None 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] Acquire Lock on device Device (e150) None 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] Msg to send b'01000010a102e15001010000000000000200040005' 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] Received response 0x004d: b'e15000158d000200d57180' 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] Release Lock on device Device (e150) None 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] Encoded Msg to send b'0102110210021010a10212e150021102110210021002100210021002100212021002140210021503' 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] RESPONSE 0x004D - Device announce : addr:e150, ieee:00158d000200d571, mac_capability:10000000, lqi:189 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] Device Announce RESPONSE 0x004D - Device announce : addr:e150, ieee:00158d000200d571, mac_capability:10000000, lqi:189 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [custom_components.zigate] Update device Device (e150) None 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] Acquire Lock on device Device (e150) None 2020-05-08 16:53:25 ERROR (ZiGate-Decode data) [zigate] IEEE is missing for e150, please pair it again ! 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [zigate] Release Lock on device Device (e150) 00158d000200d571 2020-05-08 16:53:25 DEBUG (ZiGate-Decode data) [custom_components.zigate] Update device Device (e150) 00158d000200d571

After restart Home Assistant the entity new one with addr only disappeared and only old one left, which is desynchronized and mark as unavaliable.

pawelka commented 4 years ago

It looks like I restart HA before autosave was trigger, that's the reason of disappearing entity.

pawelka commented 4 years ago

Workaround: In case of paring/reparing device with specific router. HA show duplicated entities, but after waiting 5min after paring (to be sure that autosave happened) and restarting HA duplicates entity disappear and everything looks normal.