OpenHAB integration described
This commit is contained in:
13
openhab2/Readme.md
Normal file
13
openhab2/Readme.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# OpenHAB
|
||||
Some OpenHAB 2 examples
|
||||
|
||||
## Requirements
|
||||
* OpenHAB2
|
||||
* Serial Binding
|
||||
|
||||
## Configuration
|
||||
|
||||
On a raspberry, give the *openhab* user access to the serial interfaces:
|
||||
```bash
|
||||
sudo usermod -a -G dialout openhab
|
||||
```
|
5
openhab2/sideboard.items
Normal file
5
openhab2/sideboard.items
Normal file
@@ -0,0 +1,5 @@
|
||||
// Install the Serial Binding (https://www.openhab.org/addons/bindings/serial1/)
|
||||
|
||||
// Sideboard
|
||||
Color sideboardLed "Sideboard" (LivingRoom) { serial="/dev/ttyUSB0@9600,ON(ollpem\n),OFF(ollpec\n)" }
|
||||
String sideboardLedRaw { serial="/dev/ttyUSB0@9600" }
|
37
openhab2/sideboard.rules
Normal file
37
openhab2/sideboard.rules
Normal file
@@ -0,0 +1,37 @@
|
||||
// Some necessary color convertion
|
||||
rule "Set RGB LEDs from Color item using ColorPicker"
|
||||
when
|
||||
Item sideboardLed received command
|
||||
then
|
||||
if (receivedCommand instanceof HSBType)
|
||||
{
|
||||
val red = receivedCommand.red * 2.55
|
||||
val green = receivedCommand.green * 2.55
|
||||
val blue = receivedCommand.blue * 2.55
|
||||
|
||||
logInfo("Sideboard", "R" + red + " G" + green + " B" + blue)
|
||||
val ledRawCmd = String::format("ollpea%X%X%X\n", red.intValue(), green.intValue(), blue.intValue());
|
||||
//logInfo("SideboardDebug", ledRawCmd)
|
||||
sideboardLedRaw.sendCommand(ledRawCmd)
|
||||
}
|
||||
end
|
||||
|
||||
// Magic, when using kodi
|
||||
rule "Kode stop, light on"
|
||||
when
|
||||
Item Kodi_Stop changed from OFF to ON
|
||||
then
|
||||
sendCommand(sideboardLed, HSBType::BLUE)
|
||||
end
|
||||
rule "Kode start, light off"
|
||||
when
|
||||
Item Kodi_Stop changed from ON to OFF
|
||||
then
|
||||
sendCommand(sideboardLed, OFF)
|
||||
end
|
||||
rule "No Kodi online, no LED"
|
||||
when
|
||||
Item Kodi_Online changed from ON to OFF
|
||||
then
|
||||
sendCommand(sideboardLed, OFF)
|
||||
end
|
Reference in New Issue
Block a user