Skip to content

Commit

Permalink
Add git files and vim modeline to demo resources (#272)
Browse files Browse the repository at this point in the history
* Add .gitignore and .gitattributes
* Add vim modeline to demo files

Signed-off-by: Thomas Dietrich <[email protected]>
  • Loading branch information
Thomas Dietrich authored and kaikreuzer committed Sep 2, 2016
1 parent 94d59e5 commit 4581949
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.items linguist-language=Xtend
*.persist linguist-language=Xtend
*.sitemap linguist-language=Xtend
*.things linguist-language=Xtend
*.map linguist-language=Xtend
*.cfg linguist-language=INI
6 changes: 6 additions & 0 deletions features/openhab-demo-resources/src/main/resources/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file is only relevant, if you decide to track your configuration in a git repository.
# If you are going to upload your configuration to GitHub or another public place, be sure to
# hide your sensitive data, examples may be:

#services/pushover.cfg # may contain your login credentials
#things/astro.things # may contain your physical location
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Group gC "Cellar" <cellar>
Group Garden "Garden" <garden>
Group Weather "Weather" <sun>

Group Status
Group Status
Group Shutters

Group GF_Living "Living Room" <video> (gGF)
Expand Down Expand Up @@ -121,3 +121,5 @@ Dimmer Volume "Volume [%.1f %%]"
Number Temperature_Setpoint "Temperature [%.1f °C]" <temperature>
Location DemoLocation "Brandenburg Gate Berlin"
Number Wifi_Level "Wifi Level [%d/4]" <signal> (FF_Office)

// vim: syntax=Xtend syntax=openhab
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Strategies {
default = everyChange
}

/*
/*
* Each line in this section defines for which item(s) which strategy(ies) should be applied.
* You can list single items, use "*" for all items or "groupitem*" for all members of a group
* item (excl. the group item itself).
Expand All @@ -13,3 +13,5 @@ Items {
// log all temperatures on every change
Temperature* -> "temperatures" : strategy=everyChange
}

// vim: syntax=Xtend syntax=openhab
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ Items {
// let's only store temperature values in rrd
Temperature*,Weather_Chart* : strategy = everyMinute, restoreOnStartup
}

// vim: syntax=Xtend syntax=openhab
24 changes: 13 additions & 11 deletions features/openhab-demo-resources/src/main/resources/rules/demo.rules
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
var Timer timer = null

/**
* This is a demo rule which simulates a real dimmer by reacting to increase/decrease commands
* and posting an updated state on the bus
* This is a demo rule which simulates a real dimmer by reacting to increase/decrease commands
* 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(DimmedLight.state instanceof DecimalType) percent = DimmedLight.state as DecimalType

if(receivedCommand==INCREASE) percent = percent + 5
if(receivedCommand==DECREASE) percent = percent - 5
Expand Down Expand Up @@ -40,7 +40,7 @@ then
if(timer!=null) {
timer.cancel
timer = null
}
}
}
end

Expand All @@ -57,7 +57,7 @@ rule "Initialize light states"
end

rule "Initialize heating states"
when
when
System started
then
Heating?.members.forEach(heating|
Expand All @@ -67,7 +67,7 @@ rule "Initialize heating states"
end

rule "Initialize contact states"
when
when
System started
then
Windows?.members.forEach(window|
Expand All @@ -76,14 +76,14 @@ rule "Initialize contact states"
end

rule "Initialize Location"
when
when
System started
then
DemoLocation.postUpdate(new PointType("52.5200066,13.4049540"))
end

rule "Set random room temperatures"
when
when
System started or
Time cron "0 0/5 * * * ?"
then
Expand All @@ -97,7 +97,7 @@ when
Item Weather_Temperature changed or
Time cron "0 0 0 * * ?" or
System started
then
then
postUpdate(Weather_Temp_Max, Weather_Temperature.maximumSince(now.withTimeAtStartOfDay).state)
postUpdate(Weather_Temp_Min, Weather_Temperature.minimumSince(now.withTimeAtStartOfDay).state)
end
Expand All @@ -111,9 +111,11 @@ then
end

rule "Set random wifi variations"
when
when
System started or
Time cron "/20 * * * * ?"
then
postUpdate(Wifi_Level, (Math::random * 4.0).intValue)
end
end

// vim: syntax=Xtend syntax=openhab
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
say("Demo script has been called!")

// vim: syntax=Xtend syntax=openhab
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ sitemap demo label="Main Menu"
Frame {
Group item=gFF label="First Floor" icon="firstfloor"
Group item=gGF label="Ground Floor" icon="groundfloor"
Group item=gC label="Cellar" icon="cellar"
Group item=Garden icon="garden"
Group item=gC label="Cellar" icon="cellar"
Group item=Garden icon="garden"
}
Frame label="Weather" {
Text item=Weather_Temperature valuecolor=[Weather_LastUpdate=="NULL"="lightgray",Weather_LastUpdate>90="lightgray",>25="orange",>15="green",>5="orange",<=5="blue"] {
Expand Down Expand Up @@ -73,3 +73,5 @@ sitemap demo label="Main Menu"
}
}
}

// vim: syntax=Xtend syntax=openhab
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ 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 ]

// vim: syntax=Xtend syntax=openhab

0 comments on commit 4581949

Please sign in to comment.