sbidy / pywizlight

A python connector for WiZ devices
MIT License
463 stars 79 forks source link

Fix KeyError when sceneId is missing #114

Closed bdraco closed 2 years ago

bdraco commented 2 years ago

I just had some more devices show up so I'm going to see if I can add motion sensor support

codecov-commenter commented 2 years ago

Codecov Report

Merging #114 (54f930c) into master (f345bdc) will increase coverage by 0.19%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #114      +/-   ##
==========================================
+ Coverage   75.32%   75.52%   +0.19%     
==========================================
  Files          12       12              
  Lines         762      764       +2     
==========================================
+ Hits          574      577       +3     
+ Misses        188      187       -1     
Impacted Files Coverage Δ
pywizlight/bulb.py 78.78% <100.00%> (+0.39%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update f345bdc...54f930c. Read the comment docs.

sbidy commented 2 years ago

I'm not sure, but I think the motion sensor is a BLE device and doesn't communicate via Wi-Fi. Do you have one?

bdraco commented 2 years ago

Just got one. Unboxing it now

bdraco commented 2 years ago

Looks like its detectable on the light with src pir

2022-02-09 14:51:58 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.209.205', 49155): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb5087933b","rssi":-60,"src":"pir","state":false,"sceneId":0,"temp":2762,"dimming":100}}'
2022-02-09 14:51:58 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.212.173', 49154): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb509c1599","rssi":-70,"src":"pir","state":false,"sceneId":0}}'
bdraco commented 2 years ago
2022-02-09 14:51:58 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.212.173', 49154): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb509c1599","rssi":-70,"src":"pir","state":false,"sceneId":0}}'
2022-02-09 14:52:08 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.212.173', 49154): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb509c1599","rssi":-68,"src":"pir","state":false,"sceneId":0}}'
2022-02-09 14:52:09 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.212.173', 49154): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb509c1599","rssi":-70,"src":"pir","state":false,"sceneId":0}}'
2022-02-09 14:52:28 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.212.173', 49154): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb509c1599","rssi":-67,"src":"pir","state":false,"sceneId":0}}'
2022-02-09 14:52:29 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.212.173', 49154): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb509c1599","rssi":-68,"src":"pir","state":false,"sceneId":0}}'
2022-02-09 14:52:49 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.212.173', 49154): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb509c1599","rssi":-68,"src":"pir","state":false,"sceneId":0}}'
2022-02-09 14:52:49 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.212.173', 49154): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb509c1599","rssi":-68,"src":"pir","state":false,"sceneId":0}}'
2022-02-09 14:53:08 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.212.173', 49154): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb509c1599","rssi":-68,"src":"pir","state":false,"sceneId":0}}'
2022-02-09 14:53:09 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.212.173', 49154): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb509c1599","rssi":-68,"src":"pir","state":false,"sceneId":0}}'
2022-02-09 14:53:28 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.212.173', 49154): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb509c1599","rssi":-67,"src":"pir","state":false,"sceneId":0}}'
2022-02-09 14:53:29 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.212.173', 49154): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb509c1599","rssi":-68,"src":"pir","state":false,"sceneId":0}}'
2022-02-09 14:53:40 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.214.216', 64299): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb50d46a1c","rssi":-48,"src":"pir","state":true,"sceneId":27,"speed":100,"dimming":100}}'
2022-02-09 14:53:40 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.212.68', 52195): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"6c2990f7743e","rssi":-45,"src":"pir","state":true,"sceneId":27,"speed":100,"dimming":100}}'
2022-02-09 14:53:40 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.211.79', 49156): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb50818e7c","rssi":-57,"src":"pir","state":true,"sceneId":27,"speed":100,"dimming":100}}'
2022-02-09 14:53:40 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.210.189', 49156): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb509c0e96","rssi":-71,"src":"pir","state":true,"sceneId":0}}'
2022-02-09 14:53:40 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.212.173', 49154): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb509c1599","rssi":-69,"src":"pir","state":true,"sceneId":0}}'
2022-02-09 14:53:48 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.212.68', 52195): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"6c2990f7743e","rssi":-44,"src":"pir","state":true,"sceneId":27,"speed":100,"dimming":100}}'
2022-02-09 14:53:48 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.212.173', 49154): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb509c1599","rssi":-71,"src":"pir","state":true,"sceneId":0}}'
2022-02-09 14:53:48 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.211.79', 49156): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb50818e7c","rssi":-59,"src":"pir","state":true,"sceneId":27,"speed":100,"dimming":100}}'
2022-02-09 14:53:48 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.210.189', 49156): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb509c0e96","rssi":-72,"src":"pir","state":true,"sceneId":0}}'
2022-02-09 14:53:49 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.212.173', 49154): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb509c1599","rssi":-71,"src":"pir","state":true,"sceneId":0}}'
2022-02-09 14:53:49 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.212.68', 52195): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"6c2990f7743e","rssi":-44,"src":"pir","state":true,"sceneId":27,"speed":100,"dimming":100}}'
2022-02-09 14:53:49 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.211.79', 49156): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb50818e7c","rssi":-57,"src":"pir","state":true,"sceneId":27,"speed":100,"dimming":100}}'
2022-02-09 14:53:49 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.210.189', 49156): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb509c0e96","rssi":-72,"src":"pir","state":true,"sceneId":0}}'
2022-02-09 14:53:51 DEBUG (MainThread) [pywizlight.push_manager] ('192.168.214.216', 64299): PUSH << b'{"method":"syncPilot","env":"pro","params":{"mac":"a8bb50d46a1c","rssi":-48,"src":"pir","state":true,"sceneId":27,"speed":100,"dimming":100}}'
sbidy commented 2 years ago

Does the motion sensor provide a UDP interface?

bdraco commented 2 years ago

The motion sensor is BLE only so we have to get the state from the light

sbidy commented 2 years ago

Ah, ok. But the state change at the bulb property should be fast enough to avoid a latency gap.