From 25d85c1a514d2ff874d4b614079944f67245f3a9 Mon Sep 17 00:00:00 2001 From: slopjong Date: Fri, 12 Apr 2019 20:28:43 +0200 Subject: [PATCH] Add a door status and control the lights, beamer and screen --- items/level2.items | 2 ++ rules/level2.rules | 34 ++++++++++++++++++++++++++++++++++ things/level2.things | 7 +++++++ 3 files changed, 43 insertions(+) diff --git a/items/level2.items b/items/level2.items index 0c0ab1f..4d24f36 100644 --- a/items/level2.items +++ b/items/level2.items @@ -10,6 +10,8 @@ Group entrance "Entrance" (main_floor) //------------------------------------------------------------------------------- +Switch entrance_door_status "Door Status" { channel="mqtt:topic:entrance_door_status:status" } + Switch entrance_ceiling_lamps "Ceiling Lamps" (entrance) { channel="mqtt:topic:entrance_ceiling_lamps:power" } 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" } diff --git a/rules/level2.rules b/rules/level2.rules index 18bc631..f158b12 100644 --- a/rules/level2.rules +++ b/rules/level2.rules @@ -1,4 +1,38 @@ +rule "Door Status" +when + Item entrance_door_status changed +then + val state = entrance_door_status.state.toString + + // the sensor state is inverted: + // OFF means opened + // ON means opened + if (state == 'OFF') { + logInfo('door', 'opened') + entrance_ceiling_lamps.sendCommand("ON") + chill_zone_lamps.sendCommand("ON") + engineering_table_lamps.sendCommand("ON") + engineering_ceiling_lamps.sendCommand("ON") + engineering_status_lamp.sendCommand("ON") + } else { + logInfo('door', 'closed') + // turn the beamer off + sendHttpGetRequest("http://10.2.113.7/tgi/return.tgi?command=2a3102fd0660") + chill_zone_screen_button_up.sendCommand("ON") + entrance_ceiling_lamps.sendCommand("OFF") + chill_zone_lamps.sendCommand("OFF") + engineering_table_lamps.sendCommand("OFF") + engineering_ceiling_lamps.sendCommand("OFF") + engineering_status_lamp.sendCommand("OFF") + } + + + logInfo("door", "Space state: {}", state) +end + +// ---------------------------------------------------------------------------- + rule "Beamer Power" when Item chill_zone_beamer received command diff --git a/things/level2.things b/things/level2.things index 555c8e2..17d24c5 100644 --- a/things/level2.things +++ b/things/level2.things @@ -8,6 +8,13 @@ Bridge mqtt:broker:mosquitto "Mosquitto" [ clientID="openHAB2" ]{ + Thing topic entrance_door_status "Entrance Door Status" @ "Entrance" { + Channels: + Type switch : status "Status" [ + stateTopic="stat/entrance/door_status/POWER" + ] + } + Thing topic entrance_ceiling_lamps "Entrance Ceiling Lamps" @ "Entrance" { Channels: Type switch : power "Power" [