- Notifications
You must be signed in to change notification settings - Fork0
OpenHAB command script for PixelIt
License
miccgn/openhab-pixelit
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This script handles communication betweenOpenHAB and the PixelIt device (seeo0shojo0o/PixelIt andhttps://www.bastelbunker.de/pixel-it/).
It allows both sending messages to PixelIt for immediate display and also managing a playlist with screen definitions, thus making OpenHAB become a PixelIt controller.
In order to display content on your PixelIt device, you have to send ascreen definition
. Ascreen definition
is a piece of JSON code describing what to display next:
{"switchAnimation":{"aktiv":true,"animation":"fade" },"bitmap":{"data":[0,32799,63519,43029,43029,43029,0,0,0,32799,63519,0,0,0,63504,0,0,32799,63519,0,0,0,63504,0,0,32799,63519,0,0,0,63504,0,0,32799,63519,43029,43029,43029,0,0,0,32799,63519,0,0,0,0,0,0,32799,63519,0,0,0,0,0,0,32799,63519,0,0,0,0,0],"position":{"x":0,"y":0 },"size":{"width":8,"height":8 } },"text":{"textString":"10","bigFont":false,"centerText":true,"hexColor":"#FFFFFF" }}
This tells PixelIt to...
- ... fade the current screen out and the new screen in
- ... show a bitmap described by the
data
section (actually, that's the PixelIt logo) - ... show the text
"10"
next to it, centered, in white color
There are more commands to use. See the fullAPI specification.
Basically, the "controller" helps you to manage screen definitions like described before. It stores them in a single playlist and plays them out to your PixelIt one after another.
The "controller" consists of
- an OpenHAB String item receiving commands
- a script being triggered by comamnds sent to this item, manipulating playlist items.
Create a String Item which will receive your commands. Choose any name that fits your naming convention for this item:
StringPixelItCommand"Commands for PixelIt controller"
(Of course you can also use the Main GUI to create the String Item.)
Create a rule to handle commands that are posted to the item.
- Create a new rule. Pick any name and description you like.
- From the first screen, select the
Code
tab and paste the content of the YAML-file from this repository. - Make sure to insert the name you chose for the item and the proper IP address of your PixelIt at the places indicated:
That's it! Now start sending commands to your PixelIt controller:
PixelItCommand.sendCommand("message Hello World!")
The following commands are supported:
add SCREENNAME SCREENDEFupdate SCREENNAME SCREENDEF
whereSCREENNAME
is any name you want to give that screen for managing it in your playlist, andSCREENDEF
is a screen definition like describedabove.add
andupdate
are completely interchangeable: if the screen namedSCREENNAME
already exists, it will be updated, otherwise it will be created.
Example:
add welcome {"switchAnimation":{"aktiv":true,"animation":"fade"},"bitmap":{"data":[0,32799,63519,43029,43029,43029,0,0,0,32799,63519,0,0,0,63504,0,0,32799,63519,0,0,0,63504,0,0,32799,63519,0,0,0,63504,0,0,32799,63519,43029,43029,43029,0,0,0,32799,63519,0,0,0,0,0,0,32799,63519,0,0,0,0,0,0,32799,63519,0,0,0,0,0],"position":{"x":0,"y":0},"size":{"width":8,"height":8}},"text":{"textString":"Welcome!","bigFont":false,"centerText":true,"hexColor":"#FFFFFF"}}
As soon as the first screen has been added, a timer will play the playlist.
By default, each screen will be displayed for 7 seconds before going on with the next item in the playlist. You can define this team per screen with an additional item in your screen definiton:
... "displayTime": SECONDS, ...
Example:
add welcome {"displayTime": 10, "switchAnimation":{"aktiv":true,"animation":"fade"},"bitmap":{"data":[0,32799,63519,43029,43029,43029,0,0,0,32799,63519,0,0,0,63504,0,0,32799,63519,0,0,0,63504,0,0,32799,63519,0,0,0,63504,0,0,32799,63519,43029,43029,43029,0,0,0,32799,63519,0,0,0,0,0,0,32799,63519,0,0,0,0,0,0,32799,63519,0,0,0,0,0],"position":{"x":0,"y":0},"size":{"width":8,"height":8}},"text":{"textString":"Welcome!","bigFont":false,"centerText":true,"hexColor":"#FFFFFF"}}
This will display the screen namedwelcome
for 10 seconds before advancing to the next one.
delete SCREENNAME
Removes the screen defined with the nameSCREENNAME
from your playlist.
message SCREENDEF
Shows the screen defined bySCREENDEF
, then goes on with the next regular screen in your playlist. This is intended to be used for one-time messages from your rules.
error TEXTwarning TEXT
These two commands go without a full screen definition. Instead, they just take any text as parameter, wrap it with a default screen definition and use the technique for themessage
command to display it.
About
OpenHAB command script for PixelIt