Page 1 of 3

Python Plugin : Xiaomi Philips LED Ball Lamp

Posted: Tuesday 13 November 2018 22:50
by deennoo
Hello There

I'm starting a new plugin, for some Xiaomi Philips Wifi Device.

All main work come from Kofec and his plugin for Xiaomi Air Purifier : https://github.com/kofec/domoticz-AirPurifier

I just spend some time to adapt it for the E27 Bulb aka Xiaomi Philips LED Ball Lamp aka Philips ZhiRui E27 bulb.

That a first version, With 3 Widgets

ON/OFF
Brightness
White Temp
Capture.PNG
Capture.PNG (28.17 KiB) Viewed 9077 times

You Can drive the Bulb directly from Domoticz and from MiHome APP (set refresh to 1 minute to have best update)

Know Issue :
- Restarting the plugin create a segmention Fault, you need to restart your domoticz
- Plugin doesn't know if your bulb are Online or not

Next evolutions are :

Using Native Domoticz CCCW Widget
Using set_brightness_and_color_temperature(brightness, cct) command avaiable on Python-miio

You can Grab it : https://github.com/deennoo/domoticz-Xia ... ree/master

Re: Python Plugin : Xiaomi Philips LED Ball Lamp

Posted: Thursday 15 November 2018 23:29
by deennoo
v0.1.1 is out

Adding ability to use 4 Scenes already present In the Bulb
Capture.PNG
Capture.PNG (41.45 KiB) Viewed 9044 times

Re: Python Plugin : Xiaomi Philips LED Ball Lamp

Posted: Saturday 17 November 2018 15:48
by deennoo
switching to beta branch allow you to use cccw widget

https://github.com/deennoo/domoticz-Xia ... /MyBulb.py
Capture.PNG
Capture.PNG (31.41 KiB) Viewed 9024 times
just missing now :
on/off from this widget
refresh this widget from bulb status
using native python-miio module to by pass MyBulb.py

Re: Python Plugin : Xiaomi Philips LED Ball Lamp

Posted: Sunday 18 November 2018 17:53
by arek156
Hello
Great script, just how to generate a token?

Re: Python Plugin : Xiaomi Philips LED Ball Lamp

Posted: Saturday 08 December 2018 23:16
by N1co
arek156 wrote: Sunday 18 November 2018 17:53 Hello
Great script, just how to generate a token?
I cannot get this to work.
I checked the miio2.db on my android phone but the token of the light bulb is empty.

Re: Python Plugin : Xiaomi Philips LED Ball Lamp

Posted: Monday 24 December 2018 0:27
by vuko
@N1co, it's not a place for this info but here's how it worked on my devices:
If you have android phone, install older version of MiHome - 5.0.19 for example from appkmirror. Then follow the guide from there for non-rooted android: https://github.com/jghaanstra/com.xiaom ... n_token.md
(newer versions of android MiHome, doesn't store device tokens)

Re: Python Plugin : Xiaomi Philips LED Ball Lamp

Posted: Monday 24 December 2018 12:39
by tontze
Just bought few of these bulbs, works very nice with android app. Havent tried this plugin yet, as i understood its not ready yet. Waiting to try it out when its ready :)

Re: Python Plugin : Xiaomi Philips LED Ball Lamp

Posted: Tuesday 25 December 2018 18:03
by fecus
Thank you your efforts!
It is almost working.
In the CCCW widget the color is not variable. Only the dimmer work.

And, can I define new scene? If yes, how?

Re: Python Plugin : Xiaomi Philips LED Ball Lamp

Posted: Thursday 27 December 2018 9:20
by N1co
vuko wrote: Monday 24 December 2018 0:27 @N1co, it's not a place for this info but here's how it worked on my devices:
If you have android phone, install older version of MiHome - 5.0.19 for example from appkmirror. Then follow the guide from there for non-rooted android: https://github.com/jghaanstra/com.xiaom ... n_token.md
(newer versions of android MiHome, doesn't store device tokens)
Thanks. In the end I used the packet sender method to get the token. Plugin works great now!

Re: Python Plugin : Xiaomi Philips LED Ball Lamp

Posted: Friday 04 January 2019 17:17
by qwerk
Hi, I bought two of these lamps and I am trying to use them using this plugin.
I keep getting this error:

2019-01-04 16:59:06.981 Error: (XiaomiPhilipsLEDBallLamp) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/xiaomi_led_bulb/:/usr/lib/python3.4/:/usr/lib/python3.4/plat-arm-linux-gnueabihf:/usr/lib/python3.4/lib-dynload'.
2019-01-04 16:59:06.981 Error: (xiaomi lamp 02) Module Import failed, exception: 'ImportError'
2019-01-04 16:59:06.981 Error: (xiaomi lamp 02) Module Import failed: ' Name: typing'
2019-01-04 16:59:06.981 Error: (xiaomi lamp 02) Error Line details not available.

I tried to update python3 that did not help. now running 3.7.2
I am missing something, but I dont know what.

can you advice where to look?

Re: Python Plugin : Xiaomi Philips LED Ball Lamp

Posted: Monday 14 January 2019 16:31
by izmirkubiak
Hello,

Have you been able to advance on integration xiaomi philips? Because I just acquired the spot zhirui and I am very happy, remains to integrate correctly.
Thank you for all the work already done, and in advance for the future.

Re: Python Plugin : Xiaomi Philips LED Ball Lamp

Posted: Wednesday 16 January 2019 21:39
by Samael
Hi!

I managed to get this plugin working under Windows. I am ready to help in finalizing the plugin to a full state. deennoo, could you add me to the Collaborators?

Code: Select all

2019-01-17 00:57:41.928 Status: (test5) Started.
2019-01-17 00:57:42.309 (test5) 'Author':'Deennoo'
2019-01-17 00:57:42.309 (test5) 'Name':'test5'
2019-01-17 00:57:42.309 (test5) 'Address':'192.168.10.102'
2019-01-17 00:57:42.309 (test5) 'Port':'0'
2019-01-17 00:57:42.309 (test5) 'Key':'XiaomiPhilipsLEDBallLamp'
2019-01-17 00:57:42.309 (test5) 'Mode1':'89bedfa9123841a44030fd4ae2a0db09'
2019-01-17 00:57:42.309 (test5) 'Mode3':'1'
2019-01-17 00:57:42.309 (test5) 'Mode6':'Debug'
2019-01-17 00:57:42.310 (test5) 'DomoticzVersion':'4.9701'
2019-01-17 00:57:42.310 (test5) 'DomoticzHash':'98723b7d'
2019-01-17 00:57:42.310 (test5) 'DomoticzBuildTime':'2018-06-28 09:00:58'
2019-01-17 00:57:42.310 (test5) Device count: 2
2019-01-17 00:57:42.310 (test5) Device: 1 - ID: 45, Name: 'PhLamp - Scenes', nValue: 1, sValue: '40'
2019-01-17 00:57:42.310 (test5) Device ID: '45'
2019-01-17 00:57:42.310 (test5) Device Name: 'PhLamp - Scenes'
2019-01-17 00:57:42.310 (test5) Device nValue: 1
2019-01-17 00:57:42.310 (test5) Device sValue: '40'
2019-01-17 00:57:42.310 (test5) Device LastLevel: 40
2019-01-17 00:57:42.310 (test5) Device: 2 - ID: 46, Name: 'PhLamp - CCCW', nValue: 1, sValue: '10'
2019-01-17 00:57:42.310 (test5) Device ID: '46'
2019-01-17 00:57:42.310 (test5) Device Name: 'PhLamp - CCCW'
2019-01-17 00:57:42.310 (test5) Device nValue: 1
2019-01-17 00:57:42.310 (test5) Device sValue: '10'
2019-01-17 00:57:42.310 (test5) Device LastLevel: 10
2019-01-17 00:57:42.310 (test5) Pushing 'PollIntervalDirective' on to queue
2019-01-17 00:57:42.311 (test5) Device UNIT_SCENES with id 1 exist
2019-01-17 00:57:42.311 (test5) Device UNIT_CCCW with id 2 exist
2019-01-17 00:57:42.311 (test5) onHeartbeat called
2019-01-17 00:57:42.307 Status: (test5) Entering work loop.
2019-01-17 00:57:42.308 Status: (test5) Initialized version 0.1.2, author 'Deennoo'
2019-01-17 00:57:43.088 (test5) <PhilipsBulbStatus power=on, b .... ne=4, delay_off_countdown=0>
2019-01-17 00:57:43.088 (test5) power => on
2019-01-17 00:57:43.088 (test5) brightness => 10
2019-01-17 00:57:43.088 (test5) color_temperature => 1
2019-01-17 00:57:43.088 (test5) scene => 4
2019-01-17 00:57:43.088 (test5) delay_off_countdown => 0>
2019-01-17 00:57:43.088 (test5) Starting device update
2019-01-17 00:57:43.089 (test5) onHeartbeat finished
2019-01-17 00:57:43.089 (test5) Processing 'PollIntervalDirective' message
2019-01-17 00:57:43.089 (test5) Heartbeat interval set to: 20.
2019-01-17 00:57:51.831 (test5) Pushing 'onHeartbeatCallback' on to queue
2019-01-17 00:57:51.872 (test5) Processing 'onHeartbeatCallback' message
2019-01-17 00:57:51.872 (test5) Calling message handler 'onHeartbeat'.
2019-01-17 00:57:51.872 (test5) onHeartbeat called
2019-01-17 00:57:51.872 (test5) Awaiting next pool: 2019-01-17 00:58:42.311525
2019-01-17 00:57:53.737 (test5) Pushing 'onCommandCallback' on to queue
2019-01-17 00:57:53.759 (test5) Processing 'onCommandCallback' message
2019-01-17 00:57:53.759 (test5) Calling message handler 'onCommand'.
2019-01-17 00:57:53.759 (test5) onCommand called for Unit 2: Parameter 'Off', Level: '10', Color:
2019-01-17 00:57:53.759 (test5) settings: 192.168.10.102 89bedfa9123841a44030fd4ae2a0db09
2019-01-17 00:57:53.759 (test5) Call command: ['python', './MyBulb.py', '192.168.10.102', '89bedfa9123841a44030fd4ae2a0db09', '--power', 'OFF']
2019-01-17 00:57:54.720 (test5) <PhilipsBulbStatus power=off, brightness=10, color_temperature=1, scene=4, delay_off_countdown=0>
2019-01-17 00:57:54.720 (test5) onHeartbeat called
2019-01-17 00:58:00.229 (test5) <PhilipsBulbStatus power=off, .... ne=4, delay_off_countdown=0>
2019-01-17 00:58:00.229 (test5) power => off
2019-01-17 00:58:00.229 (test5) brightness => 10
2019-01-17 00:58:00.229 (test5) color_temperature => 1
2019-01-17 00:58:00.229 (test5) scene => 4
2019-01-17 00:58:00.229 (test5) delay_off_countdown => 0>
2019-01-17 00:58:00.246 (test5) Update 0:'10' (PhLamp - CCCW)
2019-01-17 00:58:00.264 (test5) Update 0:'40' (PhLamp - Scenes)
2019-01-17 00:58:00.264 (test5) Starting device update
2019-01-17 00:58:00.264 (test5) onHeartbeat finished
2019-01-17 00:58:11.851 (test5) Pushing 'onHeartbeatCallback' on to queue
2019-01-17 00:58:11.864 (test5) Processing 'onHeartbeatCallback' message
2019-01-17 00:58:11.864 (test5) Calling message handler 'onHeartbeat'.
2019-01-17 00:58:11.864 (test5) onHeartbeat called
PS: Windows Server 2012R2 Essentials, Python 3.6.8

Re: Python Plugin : Xiaomi Philips LED Ball Lamp

Posted: Wednesday 23 January 2019 20:31
by yezzer
Hello Nicolas,

Many thanks for this great work to integrate the Xiaomi Zhirui Led E27 ball bulb into Domoticz!
I was looking for thist feature about more than a year!
I also want to thank you in advance for all the excellent work you have done, and will do in future to improve the script.

about the integration in my version of domoticz (bèta V4.10363 with python 3.5.3):
I only get two tabs, namely the tab with the predefined 4 scènes and the tab with CCCW
the other tabs are missing...

furthermore, I wonder if the newest Xiaomi Aqara ZNLDP12LM LED Smart Bulb (zigbee) can also be implemented in future?

Thanks!

Re: Python Plugin : Xiaomi Philips LED Ball Lamp

Posted: Saturday 26 January 2019 0:34
by deennoo
izmirkubiak wrote: Monday 14 January 2019 16:31 Hello,

Have you been able to advance on integration xiaomi philips? Because I just acquired the spot zhirui and I am very happy, remains to integrate correctly.
Thank you for all the work already done, and in advance for the future.
has i don't plan to buy this spot, sorry i can't help, but maybe you can check if Python lib that i use already have something for you and then you can adapt my plugin :

https://python-miio.readthedocs.io/en/l ... ilips_bulb

Re: Python Plugin : Xiaomi Philips LED Ball Lamp

Posted: Saturday 26 January 2019 0:41
by deennoo
Samael wrote: Wednesday 16 January 2019 21:39 Hi!

I managed to get this plugin working under Windows. I am ready to help in finalizing the plugin to a full state. deennoo, could you add me to the Collaborators?
Done,

Feel free to add some stability on this plugin !

Re: Python Plugin : Xiaomi Philips LED Ball Lamp

Posted: Saturday 26 January 2019 0:42
by deennoo
yezzer wrote: Wednesday 23 January 2019 20:31
about the integration in my version of domoticz (bèta V4.10363 with python 3.5.3):
I only get two tabs, namely the tab with the predefined 4 scènes and the tab with CCCW
the other tabs are missing...
Other tab was created for beta, but removed because not needed as i manage to create and use a cccw widget

Re: Python Plugin : Xiaomi Philips LED Ball Lamp

Posted: Saturday 26 January 2019 15:09
by Samael
Hi folks!

I fixed some bugs and added support for Windows to the plugin.
You can test it here: https://github.com/deennoo/domoticz-Xia ... ee/win-fix

Re: Python Plugin : Xiaomi Philips LED Ball Lamp

Posted: Monday 28 January 2019 5:34
by deennoo
Samael wrote: Saturday 26 January 2019 15:09 Hi folks!

I fixed some bugs and added support for Windows to the plugin.
You can test it here: https://github.com/deennoo/domoticz-Xia ... ee/win-fix
I've just merge it, good job

Re: Python Plugin : Xiaomi Philips LED Ball Lamp

Posted: Friday 01 February 2019 18:29
by mgabor
Dear All,
I have tried to install the Xiaomi Philips bulb and it was almost successful, but the Domoticz does not recognize the bulb. Int error status I hav found this: 2019-02-01 18:07:32.235 Error: (Light1) Call command failed: Command '['bash', '-c', './MyBulb.py', 'here the IP, I deleted it', 'here the token, I deleted it', '--power', 'OFF']' returned non-zero exit status 2

What can I do?

I have found this error in Python:
=== RESTART: /home/pi/domoticz/plugins/domoticz-Xiaomi-Led-Lamp/MyBulb.py ===
usage: MyBulb.py [-h]
[--level {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99}]
[--temp {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99}]
[--power {ON,OFF}] [--debug] [--scene {1,2,3,4}]
[--brightemp BRIGHTEMP]
IPaddress token
MyBulb.py: error: the following arguments are required: IPaddress, token

Where is the problem?

Re: Python Plugin : Xiaomi Philips LED Ball Lamp

Posted: Saturday 02 February 2019 18:52
by mgabor
deennoo wrote: Tuesday 13 November 2018 22:50 Hello There

I'm starting a new plugin, for some Xiaomi Philips Wifi Device.

All main work come from Kofec and his plugin for Xiaomi Air Purifier : https://github.com/kofec/domoticz-AirPurifier

I just spend some time to adapt it for the E27 Bulb aka Xiaomi Philips LED Ball Lamp aka Philips ZhiRui E27 bulb.

That a first version, With 3 Widgets

ON/OFF
Brightness
White Temp

Capture.PNG


You Can drive the Bulb directly from Domoticz and from MiHome APP (set refresh to 1 minute to have best update)

Know Issue :
- Restarting the plugin create a segmention Fault, you need to restart your domoticz
- Plugin doesn't know if your bulb are Online or not

Next evolutions are :

Using Native Domoticz CCCW Widget
Using set_brightness_and_color_temperature(brightness, cct) command avaiable on Python-miio

You can Grab it : https://github.com/deennoo/domoticz-Xia ... ree/master
Dear Deennoo,
I have tried to install the Xiaomi Philips bulb and it was almost successful, but the Domoticz does not recognize the bulb. Int error status I hav found this: 2019-02-01 18:07:32.235 Error: (Light1) Call command failed: Command '['bash', '-c', './MyBulb.py', 'here the IP, I deleted it', 'here the token, I deleted it', '--power', 'OFF']' returned non-zero exit status 2

What can I do?

I have found this error in Python:
=== RESTART: /home/pi/domoticz/plugins/domoticz-Xiaomi-Led-Lamp/MyBulb.py ===
usage: MyBulb.py [-h]
[--level {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99}]
[--temp {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99}]
[--power {ON,OFF}] [--debug] [--scene {1,2,3,4}]
[--brightemp BRIGHTEMP]
IPaddress token
MyBulb.py: error: the following arguments are required: IPaddress, token

Where is the problem?