Page 1 of 1

Python Plugin: MiPow PlayBulb

Posted: Saturday 03 November 2018 17:51
by Logread
With much delay due to many other things on my plate, I finally publish a replacement to the plugin initially written by @Deennoo (see https://www.domoticz.com/wiki/Plugins/PlayBulb that did not (at least to my knowledge) get updated for the breaking changes introduced in early 2018 to Domoticz to improve handling of color lamp devices.

It provides RGB and White color management as well as manufacturer specific "effects" and "speed" parameters for these inexpensive bluetooth LED lamps (see https://www.mipow.com/collections/playbulb).

I could only test it with the "Candle" PlayBulb model that I own, but it should in principle work with the following other PlayBulb lamps: RainbowSmart, Spot Mesh, Sphere, Garden, Comet, String and Solar.

Bear in mind though that MiPow does not publish its API and although thankfully several developers have reverse-engineered it, each type of lamp has its specifics... do not shoot at me if things do not work out of the box, but please report back with debug logs and we will try to see how to make this plugin compatible with as many models as possible. Also make sure you first have a good bluetooth connectivity with the device before calling for help with the plugin ! In this respect a bit of Linux knowledge helps... "hcitools" and a good search engine should be your first ports of calls.

Description and installation instructions are available on the Domoticz wiki at https://www.domoticz.com/wiki/Plugins/MiPowPlayBulb.

Please note it only works on Linux systems, such as Raspberry Pi, with a bluetooth LE (i.e. >= 4.0) adapter and requires the "bluepy" python library to be installed

For those interested, the code can be found at https://github.com/999LV/MiPowPlayBulb

Re: Python Plugin: MiPow PlayBulb

Posted: Thursday 20 December 2018 23:32
by papazol
Hi.
THX for your software.
For me it works with Candles but with Sphere it doesn't works at all :(
I get this:
2018-12-20 23:12:13.912 Error: (MiPowSphere1) MiPowPlayBulbAPI connection error: Failed to connect to peripheral 49:5C:4B:0F:AC:E6, addr type: public
2018-12-20 23:12:18.263 Status: (MiPowSphere1) Connected to device: Name = 'PLAYBULB SPHERE', Manufacturer = 'Mipow Limited', Serial = 'BTL301W'
2018-12-20 23:12:18.263 Status: (MiPowSphere1) Bluetooth Color Handle = 0x1b
2018-12-20 23:12:18.263 Status: (MiPowSphere1) Bluetooth Effects Handle = 0x19
2018-12-20 23:12:18.652 Error: (MiPowSphere1) MiPowPlayBulbAPI status read error: Bluetooth command failed (code: 2, error: Attribute can't be read)
2018-12-20 23:12:19.383 Error: (MiPowSphere1) MiPowPlayBulbAPI status read error: Bluetooth command failed (code: 2, error: Attribute can't be read)

And hcitool says:
~/domoticz/plugins $ sudo hcitool lescan
LE Scan ...
49:5C:4B:0F:AC:E6 (unknown)
49:5C:4B:0F:AC:E6 PLAYBULB SPHERE
6D:03:F8:D3:0A:47 (unknown)

Re: Python Plugin: MiPow PlayBulb

Posted: Friday 21 December 2018 11:46
by Logread
papazol wrote: Thursday 20 December 2018 23:32 Hi.
THX for your software.
For me it works with Candles but with Sphere it doesn't works at all :(
I get this:
2018-12-20 23:12:18.263 Status: (MiPowSphere1) Connected to device: Name = 'PLAYBULB SPHERE', Manufacturer = 'Mipow Limited', Serial = 'BTL301W'
2018-12-20 23:12:18.263 Status: (MiPowSphere1) Bluetooth Color Handle = 0x1b
2018-12-20 23:12:18.263 Status: (MiPowSphere1) Bluetooth Effects Handle = 0x19
2018-12-20 23:12:18.652 Error: (MiPowSphere1) MiPowPlayBulbAPI status read error: Bluetooth command failed (code: 2, error: Attribute can't be read)
2018-12-20 23:12:19.383 Error: (MiPowSphere1) MiPowPlayBulbAPI status read error: Bluetooth command failed (code: 2, error: Attribute can't be read)
Thanks for the feedback... glad it works for the Candle indeed. Can you help me investigating the Sphere a bit since I do not own one and cannot test it ? If so, using gattool, can you please try to read handles 0x1b and 0x19 and report result/errors ? Also may be provide a list of bluetooth characteristics.

Apologies for not giving you the commands to issue to do this as I am on the move at the moment... hope you can master this on your own...

Re: Python Plugin: MiPow PlayBulb

Posted: Wednesday 02 January 2019 20:07
by elke
I tried to install this plugin to my RP3 & Domoticz with this instructions: https://www.domoticz.com/wiki/Plugins/MiPowPlayBulb.

I can create a new hardware, but I cannot see it under devices. Here is log from Domoticz:

2019-01-02 20:59:34.473 Error: (MiPowPlayBulb) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/MiPowPlayBulb/:/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload'.
2019-01-02 20:59:34.473 Error: (Bulb) Module Import failed, exception: 'ImportError'
2019-01-02 20:59:34.473 Error: (Bulb) Module Import failed: ' Name: bluepy'
2019-01-02 20:59:34.473 Error: (Bulb) Error Line details not available.

What should I do? :roll:

Re: Python Plugin: MiPow PlayBulb

Posted: Wednesday 02 January 2019 22:30
by Logread
elke wrote: Wednesday 02 January 2019 20:07 I tried to install this plugin to my RP3 & Domoticz with this instructions: https://www.domoticz.com/wiki/Plugins/MiPowPlayBulb.

I can create a new hardware, but I cannot see it under devices. Here is log from Domoticz:

2019-01-02 20:59:34.473 Error: (MiPowPlayBulb) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/MiPowPlayBulb/:/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload'.
2019-01-02 20:59:34.473 Error: (Bulb) Module Import failed, exception: 'ImportError'
2019-01-02 20:59:34.473 Error: (Bulb) Module Import failed: ' Name: bluepy'
2019-01-02 20:59:34.473 Error: (Bulb) Error Line details not available.

What should I do? :roll:
Suggest you do some digging about bluepy module installation... clearly the plugin cannot find it upon startup.

Re: Python Plugin: MiPow PlayBulb

Posted: Friday 04 January 2019 16:19
by lukbe
Hello,
I have same error with last version of the raspbian.

2019-01-04 16:17:13.202 Error: (MiPowPlayBulb) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/MiPowPlayBulb/:/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload'.
2019-01-04 16:17:13.202 Error: (Svicka Mipow) Module Import failed, exception: 'ImportError'
2019-01-04 16:17:13.202 Error: (Svicka Mipow) Module Import failed: ' Name: bluepy'
2019-01-04 16:17:13.202 Error: (Svicka Mipow) Error Line details not available.

Solution: sudo ln -s /home/pi/.local/lib/python3.5/site-packages/bluepy /usr/lib/python3.5/

Re: Python Plugin: MiPow PlayBulb

Posted: Friday 04 January 2019 16:27
by Logread
lukbe wrote: Friday 04 January 2019 16:19 Hello,
I have same error with last version of the raspbian.

2019-01-04 16:17:13.202 Error: (MiPowPlayBulb) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/MiPowPlayBulb/:/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload'.
2019-01-04 16:17:13.202 Error: (Svicka Mipow) Module Import failed, exception: 'ImportError'
2019-01-04 16:17:13.202 Error: (Svicka Mipow) Module Import failed: ' Name: bluepy'
2019-01-04 16:17:13.202 Error: (Svicka Mipow) Error Line details not available.
Definitely an issue with the system setup, not with the plugin. Did you create the symlink as instructed in installation section of the wiki page for the plugin ?
Can you please check where bluepy resides in your system (which bluepy) ? May be the above symlink needs to be adjusted... your favorite search engine will be your friend, as this issue is again unrelated to the plugin.

Re: Python Plugin: MiPow PlayBulb

Posted: Friday 04 January 2019 16:33
by lukbe
Solution: sudo ln -s /home/pi/.local/lib/python3.5/site-packages/bluepy /usr/lib/python3.5/



pi@raspberrypi:~/domoticz/plugins/MiPowPlayBulb $ pip3 show bluepy Name: bluepy
Version: 1.3.0
Summary: Python module for interfacing with BLE devices through Bluez
Home-page: https://github.com/IanHarvey/bluepy
Author: Ian Harvey
Author-email: [email protected]
License: UNKNOWN
Location: /home/pi/.local/lib/python3.5/site-packages
Requires:

Re: Python Plugin: MiPow PlayBulb

Posted: Friday 04 January 2019 19:16
by Logread
lukbe wrote: Friday 04 January 2019 16:33 Solution: sudo ln -s /home/pi/.local/lib/python3.5/site-packages/bluepy /usr/lib/python3.5/
Thanks for posting this workout, though my own raspberries pi3 (three systems with Debian Stretch) do work with the link as I described in the wiki (the difference is indeed ".local" vs. "local"... something must have recently changed in the bluepy install process I guess.

Re: Python Plugin: MiPow PlayBulb

Posted: Friday 04 January 2019 21:17
by elke
Logread wrote: Wednesday 02 January 2019 22:30
elke wrote: Wednesday 02 January 2019 20:07 I tried to install this plugin to my RP3 & Domoticz with this instructions: https://www.domoticz.com/wiki/Plugins/MiPowPlayBulb.

I can create a new hardware, but I cannot see it under devices. Here is log from Domoticz:

2019-01-02 20:59:34.473 Error: (MiPowPlayBulb) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/MiPowPlayBulb/:/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload'.
2019-01-02 20:59:34.473 Error: (Bulb) Module Import failed, exception: 'ImportError'
2019-01-02 20:59:34.473 Error: (Bulb) Module Import failed: ' Name: bluepy'
2019-01-02 20:59:34.473 Error: (Bulb) Error Line details not available.

What should I do? :roll:
Suggest you do some digging about bluepy module installation... clearly the plugin cannot find it upon startup.
Thanks - got plugin working by reinstalling bluepy. Actually I do not have any Mipow bulbs, but I have "Giron-C" bt Awox ceiling lights from Eglo: https://www.eglo.com/international/Prod ... nnect)/ECO

Is it possible to also control those lights with this script? :roll:

Re: Python Plugin: MiPow PlayBulb

Posted: Saturday 05 January 2019 10:54
by Logread
elke wrote: Friday 04 January 2019 21:17 Thanks - got plugin working by reinstalling bluepy. Actually I do not have any Mipow bulbs, but I have "Giron-C" bt Awox ceiling lights from Eglo: https://www.eglo.com/international/Prod ... nnect)/ECO

Is it possible to also control those lights with this script? :roll:
No idea... but most likely not as it seems the control protocol of each manufacturer is proprietary (and typically not made public...)

Re: Python Plugin: MiPow PlayBulb

Posted: Saturday 05 January 2019 10:56
by Logread
Pulled new version 2019.01.05 to GitHub:
- change timing of battery poll when lamp is on (faster discharge = more frequent polls)
- reload battery level when the device is reconnected after a disconnect
- change order of switching parameters in _ResetLamp function to correct lamps always switching on when plugin (re)starts

Re: Python Plugin: MiPow PlayBulb

Posted: Saturday 09 February 2019 16:58
by Logread
Pulled new version 2019.02.09 to GitHub:
- improve battery level handling.

Re: Python Plugin: MiPow PlayBulb

Posted: Thursday 21 March 2019 18:25
by Logread
Pulled new version 2019-03-21 on Github.

This is a major improvement that leverages @Dnpwwo's recent implementation of multi-threading in the python plugin framework... Now all calls to the hardware are handled by separate threads. This allows to avoid blocking (and messing with) the plugin framework in situation of connectivity issues with the bluetooth lamp device.