Skip to content

Instantly share code, notes, and snippets.

@fvoges
Created November 3, 2015 18:53
Show Gist options
  • Select an option

  • Save fvoges/7d0db1f5cabb50c08031 to your computer and use it in GitHub Desktop.

Select an option

Save fvoges/7d0db1f5cabb50c08031 to your computer and use it in GitHub Desktop.
Initialize all Values which are still Uninitialized after startup
// Imports
import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
rule "Initialize all items"
when
System started
then
logInfo( "Initializer", "Started Timer ...")
//Wir warten x Sekunden, dann initalisieren wir alle die nicht aus der Datenbank befüllt wurden
createTimer(now.plusSeconds(60)) [|
logInfo( "Initializer", "... initializing!")
//Null
gInitializeZero.allMembers.filter( x | x.state == Uninitialized || x.state == Undefined).forEach[ item |
item.postUpdate( 0)
]
//On/Off für Schalter
gInitializeOn.allMembers.filter( x | x.state == Uninitialized || x.state == Undefined).forEach[ item |
item.postUpdate( ON)
]
gInitializeOff.allMembers.filter( x | x.state == Uninitialized || x.state == Undefined).forEach[ item |
item.postUpdate( OFF)
]
]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment