diff --git a/items/level2.items b/items/level2.items index 007a185..11630ed 100644 --- a/items/level2.items +++ b/items/level2.items @@ -14,4 +14,19 @@ Switch entrance_ceiling_lamps "Ceiling Lamps" (entrance) Switch chill_zone_lamps "Lamps" (chill_zone) { channel="mqtt:topic:chill_zone_lamps:power" } Switch engineering_table_lamps "Table Lamps" (engineering) { channel="mqtt:topic:engineering_table_lamps:power" } Switch engineering_ceiling_lamps "Ceiling Lamps" (engineering) { channel="mqtt:topic:engineering_ceiling_lamps:power" } -Switch engineering_status_lamp "Status Lamp" (engineering) { channel="mqtt:topic:engineering_status_lamp:power" } \ No newline at end of file +Switch engineering_status_lamp "Status Lamp" (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) diff --git a/rules/level2.rules b/rules/level2.rules new file mode 100644 index 0000000..73a68cb --- /dev/null +++ b/rules/level2.rules @@ -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 diff --git a/services/chromecast.cfg b/services/chromecast.cfg new file mode 100644 index 0000000..158726c --- /dev/null +++ b/services/chromecast.cfg @@ -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 \ No newline at end of file diff --git a/things/level2.things b/things/level2.things index 83f29e5..62b513e 100644 --- a/things/level2.things +++ b/things/level2.things @@ -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]