Plugins/MiPowPlayBulb

From Domoticz
Jump to: navigation, search

MiPow PlayBulb bluetooth LED lamp python plugin for Domoticz

IMPORTANT NOTE: This is Beta software, so you use it at your own risk…

Version 2018-11-02 (first release)

Author: Logread (aka 999LV on Github)

Plugin objective:

Drive MiPow PlayBulb LED lamps (see [1]) from Domoticz rather than with the manufacturer's Android or iOS app.

It is meant to provide an update to the existing plugin that was developed by @Deennoo (see [2] and that did not get updated (to my knowledge) for the breaking changes introduced in early 2018 to Domoticz to improve handling of color lamp devices.

The plugin has for now only be tested with the "Candle" PlayBulb, but should work with the following other PlayBulbs:

  1. RainbowSmart
  2. Spot Mesh
  3. Sphere
  4. Garden
  5. Comet
  6. String
  7. Solar

Please send any feedback on compatibility by private message to user "logread" on the domoticz forum (or please post on the forum thread that will be opened)

Prerequisites:

THE PLUGIN WILL ONLY WORK ON A LINUX SYSTEM (such as a Raspberry Pi) WITH A BLUETOOTH ADAPTER

  1. The Domoticz system on which the plugin runs must be stable version 4.9700 (June 23th 2018) or more recent.
  2. The python plugin system must be installed (see the instructions at https://www.domoticz.com/wiki/Using_Python_plugins ).

Installation:

  1. Open a shell session
  2. Install the "bluepy" python library:
sudo apt-get install python3-pip libglib2.0-dev
pip3 install bluepy
  1. You may need to create some links as bluepy may not be reachable for Domoticz (edit python3.5 below to match whatever version of python your Domoticz installation uses):
sudo ln -s /usr/local/lib/python3.5/dist-packages/bluepy /usr/lib/python3.5/
  1. Navigate to the directory holding your Domoticz installation (typically ~/domoticz)
  2. Perform the following commands within the shell:
cd plugins
mkdir MyPowPlayBulb
sudo apt-get update
sudo apt-get install git
git clone https://github.com/999LV/MiPowPlayBulb.git MiPowPlayBulb
cd MiPowPlayBulb
sudo chmod +x *.py
sudo /etc/init.d/domoticz.sh restart

Before you go back to Domoticz, you need to check the hardware address (MAC) of your PlayBulb lamp... ensure it is on and reachable (and make sure you disconnect it from the smartphone app you might have been using) and do a bluetooth scan:

sudo hcitool lescan   

you should see and note the right bluetooth device in the list (it is a good idea to change the default device name using the smartphone app beforehand), such as:

FF:FF:FF:FF PLAYBULB CANDLE

Now connect to Domoticz with your browser and go to the “Setup/Hardware” page and select the “MiPow PlayBulb Python Plugin” type from the drop-down list and enter the configuration parameters:

  1. Bluetooth interface: choose the relevant bluetooth adapter from the drop down list (e.g. hci0 for the built-in bluetooth adapter on a Raspberry Pi3)
  2. Lamp Bluetooth MAC address: this is the MAC address you obtained in the previous step
  3. Battery poll: choose an interval for the polling of the battery level of the PlayBulb. A short poll interval can drain the battery faster.

After you create the hardware, the plugin will create three new devices to drive the PlayBulb in Domoticz:

MiPowPlayBulb devices.JPG


In case something does not work, enable the “Debug” mode for the plugin in the “Settings/Hardware” page and check the logs for errors and send me a pm @ logread on the Domoticz forum with the description of the error(s) and copy of the relevant log entries

Updating to last version:

  1. Open a shell session
  2. Navigate to the directory holding your Domoticz installation (typically ~/domoticz)
  3. Perform the following commands within the shell:
cd plugins/MiPowPlayBulb
git reset –-hard
git pull --force
sudo chmod +x plugin.py
sudo /etc/init.d/domoticz.sh restart