-
-
Save solars/0eff2aa8af3ea91e6e600b45d7106c76 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Date | |
import java.text.SimpleDateFormat | |
var Timer timer = null | |
rule "set alarm" | |
when Item alarmtime received update | |
then | |
var sdf = new SimpleDateFormat("yyyy-M-d HH:mm") | |
if(alarmtime.state != null) { | |
var DateTime mydate = sdf.parse(alarmtime.state.toString) | |
logInfo("test", mydate.toString) | |
if(timer == null) { | |
timer = createTimer(mydate) [| | |
EGSZDimmerTuere_1_Level.sendCommand(ON) | |
] | |
} | |
} | |
end | |
# error: | |
2017-02-09 08:47:30.714 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'set alarm': An error occured during the script execution: Could not invoke method: org.joda.time.base.AbstractDateTime.toString() on instance: Fri Feb 10 08:27:00 CET 2017 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Date | |
import java.text.SimpleDateFormat | |
var Timer timer = null | |
var actual_format = new SimpleDateFormat("yyyy-M-d HH:mm") // 2017-1-2 7:30 | |
var iso = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ") // for intermediary conversion | |
rule "set alarm" | |
when Item alarmtime received update | |
then | |
if(alarmtime.state != null) { | |
var DateTime mydate = parse(iso.format(actual_format.parse(alarmtime.state.toString))) | |
logInfo("test", mydate.toString) | |
if(timer == null) { | |
timer = createTimer(mydate) [| | |
EGSZDimmerTuere_1_Level.sendCommand(ON) | |
] | |
} | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment