diff --git a/features/distro-resources/src/main/resources/items/demo.items b/features/distro-resources/src/main/resources/items/demo.items index 3f5f11e6ef..10b58df7d8 100644 --- a/features/distro-resources/src/main/resources/items/demo.items +++ b/features/distro-resources/src/main/resources/items/demo.items @@ -25,7 +25,7 @@ Group:Number:AVG Temperature "Avg. Room Temperature [%.1f °C]" Group:Contact:OR(OPEN, CLOSED) Windows "Open windows [(%d)]" /* Lights */ -Dimmer Light_GF_Living_Table "Table" (GF_Living, Lights) ["Lighting"] +Dimmer Light_GF_Living_Table "Table" (GF_Living, Lights) ["Lighting"] Switch Light_GF_Corridor_Ceiling "Ceiling" (GF_Corridor, Lights) Switch Light_GF_Kitchen_Ceiling "Ceiling" (GF_Kitchen, Lights) Switch Light_GF_Kitchen_Table "Table" (GF_Kitchen, Lights) @@ -43,21 +43,21 @@ Switch Light_FF_Bed_Ceiling "Ceiling" (FF_Bed, Lights) Switch Light_C_Corridor_Ceiling "Ceiling" (gC, Lights) Switch Light_C_Staircase "Staircase" (gC, Lights) Switch Light_C_Washing_Ceiling "Washing" (gC, Lights) -Switch Light_C_Workshop "Workshop" (gC, Lights) ["Lighting"] +Switch Light_C_Workshop "Workshop" (gC, Lights) ["Lighting"] -Switch Light_Garden_Garage "Garage" (Garden, Lights) ["Lighting"] +Switch Light_Garden_Garage "Garage" (Garden, Lights) ["Lighting"] Switch Light_Garden_Terrace "Terrace" (Garden, Lights) /* Heating */ -Switch Heating_GF_Corridor "Corridor" (GF_Corridor, Heating) -Switch Heating_GF_Toilet "Toilet" (GF_Toilet, Heating) -Switch Heating_GF_Living "Livingroom" (GF_Living, Heating) -Switch Heating_GF_Kitchen "Kitchen" (GF_Kitchen, Heating) +Switch Heating_GF_Corridor "Corridor" (GF_Corridor, Heating) +Switch Heating_GF_Toilet "Toilet" (GF_Toilet, Heating) +Switch Heating_GF_Living "Livingroom" (GF_Living, Heating) +Switch Heating_GF_Kitchen "Kitchen" (GF_Kitchen, Heating) -Switch Heating_FF_Bath "Bath" (FF_Bath, Heating) -Switch Heating_FF_Office "Office" (FF_Office, Heating) -Switch Heating_FF_Child "Child's Room" (FF_Child, Heating) -Switch Heating_FF_Bed "Bedroom" (FF_Bed, Heating) +Switch Heating_FF_Bath "Bath" (FF_Bath, Heating) +Switch Heating_FF_Office "Office" (FF_Office, Heating) +Switch Heating_FF_Child "Child's Room" (FF_Child, Heating) +Switch Heating_FF_Bed "Bedroom" (FF_Bed, Heating) /* Rollershutters */ Rollershutter Shutter_GF_Toilet "Toilet" (GF_Toilet, Shutters) @@ -111,15 +111,15 @@ String Moon_Phase "Moon Phase" { ch /* Demo items */ DateTime CurrentDate "Date [%1$tA, %1$td.%1$tm.%1$tY]" { channel="ntp:ntp:demo:dateTime" } Switch DemoSwitch "Switch" -Dimmer DimmedLight "Dimmer [%d %%]" -Color RGBLight "RGB Light" +Dimmer DimmedLight "Dimmer [%d %%]" +Color RGBLight "RGB Light" Rollershutter DemoShutter "Roller Shutter" -Dimmer DemoBlinds "Blinds [%d %%]" -Number Scene_General "Scene" -Number Radio_Station "Radio" +Dimmer DemoBlinds "Blinds [%d %%]" +Number Scene_General "Scene" +Number Radio_Station "Radio" Dimmer Volume "Volume [%.1f %%]" Location DemoLocation "Brandenburg Gate Berlin" -Number Wifi_Level "Wifi Level [%d/4]" (FF_Office) +Number Wifi_Level "Wifi Level [%d/4]" (FF_Office) String ImageURL "Image URL [%s]" Group Thermostat "Thermostat" ["Thermostat"] diff --git a/features/distro-resources/src/main/resources/persistence/rrd4j.persist b/features/distro-resources/src/main/resources/persistence/rrd4j.persist index b97f4ede60..9fd2c9fe63 100644 --- a/features/distro-resources/src/main/resources/persistence/rrd4j.persist +++ b/features/distro-resources/src/main/resources/persistence/rrd4j.persist @@ -1,14 +1,14 @@ // persistence strategies have a name and a definition and are referred to in the "Items" section Strategies { - // for rrd charts, we need a cron strategy - everyMinute : "0 * * * * ?" + // for rrd charts, we need a cron strategy + everyMinute : "0 * * * * ?" } Items { - DemoSwitch,NoOfLights,Window_GF_Toilet,Heating* : strategy = everyChange, everyMinute, restoreOnStartup - - // let's only store temperature values in rrd - Temperature*,Weather_Chart* : strategy = everyMinute, restoreOnStartup + DemoSwitch, NoOfLights, Window_GF_Toilet, Heating* : strategy = everyChange, everyMinute, restoreOnStartup + + // let's only store temperature values in rrd + Temperature*, Weather_Chart* : strategy = everyMinute, restoreOnStartup } // vim: syntax=Xtend \ No newline at end of file diff --git a/features/distro-resources/src/main/resources/rules/demo.rules b/features/distro-resources/src/main/resources/rules/demo.rules index 6bf8f183f2..bda27fb971 100644 --- a/features/distro-resources/src/main/resources/rules/demo.rules +++ b/features/distro-resources/src/main/resources/rules/demo.rules @@ -11,28 +11,28 @@ val Random random = new Random() * and posting an updated state on the bus */ rule "Dimmed Light" - when - Item DimmedLight received command - then - if ((receivedCommand==INCREASE) || (receivedCommand==DECREASE)) { - var Number percent = 0 - if(DimmedLight.state instanceof DecimalType) percent = DimmedLight.state as DecimalType - - if(receivedCommand==INCREASE) percent = percent + 5 - if(receivedCommand==DECREASE) percent = percent - 5 - - if(percent<0) percent = 0 - if(percent>100) percent = 100 - postUpdate(DimmedLight, percent); - } +when + Item DimmedLight received command +then + if ((receivedCommand == INCREASE) || (receivedCommand == DECREASE)) { + var Number percent = 0 + if (DimmedLight.state instanceof DecimalType) percent = DimmedLight.state as DecimalType + + if (receivedCommand == INCREASE) percent = percent + 5 + if (receivedCommand == DECREASE) percent = percent - 5 + + if (percent < 0) percent = 0 + if (percent > 100) percent = 100 + postUpdate(DimmedLight, percent); + } end rule "Timer Demo" when Item Light_GF_Corridor_Ceiling received command then - if(receivedCommand==ON) { - if(timer===null) { + if (receivedCommand == ON) { + if (timer === null) { // first ON command, so create a timer to turn the light off again timer = createTimer(now.plusSeconds(10)) [| sendCommand(Light_GF_Corridor_Ceiling, OFF) @@ -41,9 +41,9 @@ then // subsequent ON command, so reschedule the existing timer timer.reschedule(now.plusSeconds(10)) } - } else if(receivedCommand==OFF) { + } else if (receivedCommand == OFF) { // remove any previously scheduled timer - if(timer!==null) { + if (timer !== null) { timer.cancel timer = null } @@ -54,113 +54,113 @@ end * The following rules help initializing the demo items with some helpful states. */ rule "Initialize light states" - when - System started - then - Lights?.members.forEach(light| - postUpdate(light, if(Math::random > 0.7) ON else OFF) - ) +when + System started +then + Lights?.members.forEach(light| + postUpdate(light, if (Math::random > 0.7) ON else OFF) + ) end rule "Initialize heating states" - when - System started - then - Heating?.members.forEach(heating| - postUpdate(heating, if(Math::random > 0.8) ON else OFF) - ) - postUpdate(Temperature_Setpoint, 22) +when + System started +then + Heating?.members.forEach(heating| + postUpdate(heating, if (Math::random > 0.8) ON else OFF) + ) + postUpdate(Temperature_Setpoint, 22) end rule "Initialize contact states" - when - System started - then - Windows?.members.forEach(window| - postUpdate(window, if(Math::random > 0.5) OPEN else CLOSED) - ) +when + System started +then + Windows?.members.forEach(window| + postUpdate(window, if (Math::random > 0.5) OPEN else CLOSED) + ) end rule "Initialize Location" - when - System started - then - DemoLocation.postUpdate(new PointType("52.5200066,13.4049540")) +when + System started +then + DemoLocation.postUpdate(new PointType("52.5200066,13.4049540")) end rule "Set random room temperatures" - when - System started or - Time cron "0 0/5 * * * ?" - then - Temperature?.members.forEach(temperature| - postUpdate(temperature, 20.0 + (25.0 - (Math::random * 50.0).intValue) / 10.0) - ) +when + System started or + Time cron "0 0/5 * * * ?" +then + Temperature?.members.forEach(temperature| + postUpdate(temperature, 20.0 + (25.0 - (Math::random * 50.0).intValue) / 10.0) + ) end rule "Set daily max and min temperature" when - Item Weather_Temperature changed or - Time cron "0 0 0 * * ?" or - System started + Item Weather_Temperature changed or + Time cron "0 0 0 * * ?" or + System started then - val max = Weather_Temperature.maximumSince(now.withTimeAtStartOfDay) - val min = Weather_Temperature.minimumSince(now.withTimeAtStartOfDay) - if( max !== null && min !== null) { - postUpdate(Weather_Temp_Max, max.state) - postUpdate(Weather_Temp_Min, min.state) - } + val max = Weather_Temperature.maximumSince(now.withTimeAtStartOfDay) + val min = Weather_Temperature.minimumSince(now.withTimeAtStartOfDay) + if (max !== null && min !== null) { + postUpdate(Weather_Temp_Max, max.state) + postUpdate(Weather_Temp_Min, min.state) + } end // Creates an item that stores the last update time of this item rule "Records last weather update time" when - Item Weather_Temperature received update + Item Weather_Temperature received update then - postUpdate(Weather_LastUpdate, new DateTimeType()) + postUpdate(Weather_LastUpdate, new DateTimeType()) end rule "Set random wifi variations" - when - System started or - Time cron "/20 * * * * ?" - then - postUpdate(Wifi_Level, (Math::random * 4.0).intValue) +when + System started or + Time cron "/20 * * * * ?" +then + postUpdate(Wifi_Level, (Math::random * 4.0).intValue) end rule "Set random image URLs" - when - Time cron "/10 * * * * ?" - then - val url = urlList.get(random.nextInt(urlList.length)) - val res = resList.get(random.nextInt(resList.length)) +when + Time cron "/10 * * * * ?" +then + val url = urlList.get(random.nextInt(urlList.length)) + val res = resList.get(random.nextInt(resList.length)) - postUpdate(ImageURL, url + "/" + res) + postUpdate(ImageURL, url + "/" + res) end rule "Volume" - when - Item Volume received command - then - if(receivedCommand instanceof PercentType) { - setMasterVolume(receivedCommand) - } else { - if(receivedCommand==INCREASE) increaseMasterVolume(20) - if(receivedCommand==DECREASE) decreaseMasterVolume(20) - } +when + Item Volume received command +then + if (receivedCommand instanceof PercentType) { + setMasterVolume(receivedCommand) + } else { + if (receivedCommand == INCREASE) increaseMasterVolume(20) + if (receivedCommand == DECREASE) decreaseMasterVolume(20) + } end rule "Select Radio Station" - when - Item Radio_Station received command - then - switch(receivedCommand) { - case 0 : playStream(null) - case 1 : playStream("http://metafiles.gl-systemhaus.de/hr/hr3_2.m3u") - case 2 : playStream("http://mp3-live.swr3.de/swr3_m.m3u") - case 3 : playStream("http://edge.live.mp3.mdn.newmedia.nacamar.net/radioffh/livestream.mp3.m3u") - case 4 : playStream("http://stream.laut.fm/club93") - } +when + Item Radio_Station received command +then + switch(receivedCommand) { + case 0 : playStream(null) + case 1 : playStream("http://metafiles.gl-systemhaus.de/hr/hr3_2.m3u") + case 2 : playStream("http://mp3-live.swr3.de/swr3_m.m3u") + case 3 : playStream("http://edge.live.mp3.mdn.newmedia.nacamar.net/radioffh/livestream.mp3.m3u") + case 4 : playStream("http://stream.laut.fm/club93") + } end // vim: syntax=Xtend diff --git a/features/distro-resources/src/main/resources/things/demo.things b/features/distro-resources/src/main/resources/things/demo.things index f0b3573281..e43e9cc4c1 100644 --- a/features/distro-resources/src/main/resources/things/demo.things +++ b/features/distro-resources/src/main/resources/things/demo.things @@ -1,6 +1,8 @@ yahooweather:weather:berlin [ location=638242 ] -astro:sun:home [ geolocation="52.5200066,13.4049540", interval=60 ] -astro:moon:home [ geolocation="52.5200066,13.4049540", interval=60 ] -ntp:ntp:demo [ hostname="nl.pool.ntp.org", refreshInterval=60, refreshNtp=30 ] + +astro:sun:home [ geolocation="52.5200066,13.4049540", interval=60 ] +astro:moon:home [ geolocation="52.5200066,13.4049540", interval=60 ] + +ntp:ntp:demo [ hostname="nl.pool.ntp.org", refreshInterval=60, refreshNtp=30 ] // vim: syntax=Xtend \ No newline at end of file