Skip to content

jbfuzier/timeboxmini

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

timeboxmini

Python mqtt daemon to talk with timebox mini

Most of the code comes from the work of derHeinz/divoom-adapter, DaveDavenport/timebox, MarcG046/timebox.

What works :

  • Display scrolling text
  • Display static image (gif, bmp, png) by file path or from a b64 data blob
  • Display animated image (gif) by file path or from a b64 data blob
  • Display clock & change clock color

0. Requirements

Bluetooth installed & configured with a bluetoth dongle. On debian : apt-get install bluetooth

To check that the dongle is working properly : blescan

Python requirements (see requirements.txt) : pip install -r requirements.txt. A C compiler & bluetooth dev headers are required, on debian : apt install libbluetooth-dev build-essential

apt-get install libboost-thread1.62.0 build-essential libbluetooth-dev libglib2.0-dev glibc-dev bluez bluez-tools bluetooth libbluetooth3 libboost-python-dev 

1. Quick start

Copy config.py.sample to config.py and edit it accordingly (put yours timebox mac address, blescan can help you getting it).

You can run timebox.py to test that communication with the timebox is working.

timebox_mqtt_daemon.py is a daemon that listens for command on a mqtt topic and send commands to the timebox mini accordingly.

2. Integration with jeedom

I use a daemon instead of a simple script, because when the script ends, connection to the timebox is closed and as a result the bluetooth icon on the timebox keeps blinking during several seconds...

You need the MQTT plugin configured and enabled. And config.py configured with the IP of the jeedom.

Launch timebox_mqtt_daemon.py

Run timebox_mqtt_client.py, it will send some command to the daemon through the mqtt server. The timebox should react.

Go in the Mqtt config on jeedom, you should get a new device :

image

Enable it :

image

Go to commands :

image

Then add some actions :

image image

Here are some examples of actions :

Name Subtype topic Payload
show_clock default timebox/in {'action': 'show_clock'}
show_clock_color color timebox/in {'action': 'show_clock', 'color': '#color#'}
show_text Message timebox/in {'action': 'show_text', 'speed': 20, 'text': [('#message#', '#title#')]}

Example of show_text on the widget :

image

Those actions can then be used on scenarios ex :

image

Commands accepted by the mqtt daemon :

	{'action': 'show_clock', 'color': 'red'}
	{'action': 'show_text', 'speed': 10, 'text': [('Hello', 'blue'),(' World','red')]}
	{'action': 'show_static_image', 'path': '../testdata/color.png'}
	{'action': 'show_animated_image', 'path': '../testdata/exp.gif'}
	{'action': 'show_static_image', 'data': 'iVBORw0KGgoAAAANSUhEUgAAAAsAAAALCAYAAACprHcmAAAACXBIWXMAAA4mAAAN/wHwU+XzAAAAXElEQVQYlc2PQQ6AQAgDB1/en48HdjVr9qA3IQRKS1IQNKiMVBpqYoz26MGHOAAqz3XtxQWYvabSRNVNaBCGZ+4yWTBOYgq1Md1jH1wPXjZkGRw2+n48+DZ+Ij4BeddPVF7LZ+sAAAAASUVORK5CYII='}
	{'action': 'show_animated_image', 'data': 'R0lGODlhCwALAKECAAAAAP8AAP///////yH/C05FVFNDQVBFMi4wAwEAAAAh/hFDcmVhdGVkIHdpdGggR0lNUAAh+QQBCgACACwAAAAACwALAAACCoSPqcvtGZ6c1BUAIfkEAQoAAwAsAAAAAAsACwAAAg+Ej6nLFv2ekoCiCJverAAAIfkEAQoAAwAsAAAAAAsACwAAAg+Ej6kaC22gY0lOJC2+XBUAIfkEAQoAAwAsAAAAAAsACwAAAg+Ejwmhm9yihE9aRU0++xYAIfkEAQoAAwAsAAAAAAsACwAAAg+EHXep2A9jZJDKi4FdbxcAIfkEAQoAAwAsAAAAAAsACwAAAgwMjmjJ7Q+jnJQuFwoAIfkEAQoAAwAsAAAAAAsACwAAAgqEj6nL7Q+jnKAAACH5BAEKAAMALAAAAAALAAsAAAIKhI+py+0Po5ygAAA7'}
Color name : http://pillow.readthedocs.io/en/3.1.x/reference/ImageColor.html#module-PIL.ImageColor
Hexadecimal color specifiers, given as #rgb or #rrggbb. For example, #ff0000 specifies pure red.
Common HTML color names
4 LSB bits are dropped for each color channel 

Cron

The following cron job, ensure that the daemon is running :

# Check is daemon is running, if not, run it
*/10 * * *  DIR="/root/timeboxmini/package/";PY="${DIR}/timebox_mqtt_daemon.py";APP="/usr/bin/python $PY";test -e "$PY"&&cd $DIR&&(pgrep -f "$APP">/dev/null||${APP}>/dev/null 2>&1)

About

Python mqtt daemon to talk with timebox mini

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages