Add beamer/chromecast items and rules

master
slopjong 2019-04-11 22:25:05 +02:00
parent f361ffc565
commit 40e77b1fed
4 changed files with 54 additions and 1 deletions

View File

@ -14,4 +14,19 @@ Switch entrance_ceiling_lamps "Ceiling Lamps" <lightbulb> (entrance)
Switch chill_zone_lamps "Lamps" <lightbulb> (chill_zone) { channel="mqtt:topic:chill_zone_lamps:power" }
Switch engineering_table_lamps "Table Lamps" <lightbulb> (engineering) { channel="mqtt:topic:engineering_table_lamps:power" }
Switch engineering_ceiling_lamps "Ceiling Lamps" <lightbulb> (engineering) { channel="mqtt:topic:engineering_ceiling_lamps:power" }
Switch engineering_status_lamp "Status Lamp" <lightbulb> (engineering) { channel="mqtt:topic:engineering_status_lamp:power" }
Switch engineering_status_lamp "Status Lamp" <lightbulb> (engineering) { channel="mqtt:topic:engineering_status_lamp:power" }
// If ChromeCast doesn't work you have to link this item with the Chromecast channel manually
String chill_zone_chromecast_appid
"Chromecast AppId [%s]"
{ channel="chromecast:chromecast:b000d809ccb35a409a3dd3d14e0fbf08:appId" }
// If ChromeCast doesn't work you have to link this item with the Chromecast channel manually
String chill_zone_chromecast_status
"Chromecast Status [%s]"
{ channel="chromecast:chromecast:b000d809ccb35a409a3dd3d14e0fbf08:statustext" }
Switch chill_zone_beamer
"Beamer"
(chill_zone)

33
rules/level2.rules Normal file
View File

@ -0,0 +1,33 @@
rule "Beamer Power"
when
Item chill_zone_beamer received command
then
val state = chill_zone_beamer.state.toString
var beamerResponse
if (state == 'ON') {
// turn the beamer on
beamerResponse = sendHttpGetRequest("http://10.2.113.7/tgi/return.tgi?command=2a3101fe0660")
} else {
// turn the beamer off
beamerResponse = sendHttpGetRequest("http://10.2.113.7/tgi/return.tgi?command=2a3102fd0660")
}
val beamerStatus = transform("XPATH", "/return/text()", beamerResponse).replace("\n", '')
logInfo("beamer", "Beamer state: {}", beamerStatus)
end
rule "Chromecast changed"
when
Item chill_zone_chromecast_status changed
then
chill_zone_beamer.sendCommand("ON")
val app = chill_zone_chromecast_status.state.toString
if (app === null || app == UNDEF || app == 'UNDEF' || app == '' ) {
// set input to DVI - hackerspace video
sendHttpGetRequest("http://10.2.113.7/tgi/return.tgi?command=2a3109f6070566")
} else {
// set input to HDMI2 - chromecast
sendHttpGetRequest("http://10.2.113.7/tgi/return.tgi?command=2a3109f6071576")
}
end

2
services/chromecast.cfg Normal file
View File

@ -0,0 +1,2 @@
// When the callback URL matters, see https://github.com/openhab/openhab2-addons/issues/1984#issuecomment-285320106
binding.chromecast:callbackUrl=http://10.2.113.102:8080

View File

@ -44,3 +44,6 @@ Bridge mqtt:broker:mosquitto "Mosquitto" [
}
}
// See services/chromecast.cfg for the callback URL
Thing chromecast:chromecast:b000d809ccb35a409a3dd3d14e0fbf08 [ipAddress="10.2.113.120", port=8009]