Thanks, but Im hoping you can help me more.
I have the time picker in my sitemap by the following line
Frame label="heating Example" {
Webview url="/static/time-line-picker/index.html?ip=192.168.0.143:8080&transferItem=TransferItem&states=OFF,1,2,3,4&yAxisLabel=1,2,3,4,5,6,7" height=13
}
when i use http://192.168.0.143:8080/static/time-line-picker/index.html it doesn’t load the picker.
if i just use /static/time-line-picker/index.html it works
And it loads fine, I can select everything and then click accept and sure.
But when i reset the page, the timepicker is back to normal. with the selections not there.
Also, I am running logs in the rule. And the log shows that TransferItem.state is set to NULL.
This is my items file
Group gTimepicker (All)
//*********************************
//Time PIcker
//***********
String TransferItem "[%s]" (gTimepicker)
String SprinklerZone "[%s]"
This is my rules
import org.eclipse.smarthome.model.script.ScriptServiceUtil
import java.util.HashMap
import java.util.ArrayList
// timeline/ timepicker control
// version 0.4
// ToSe
//
// init values & customize for you own enviroment
// -----------------------------------------------------------------------------------------------------------
//
//
// requirements: MapDB
// -----------------------------------------------------------------------------------------------------------
// String xxxSwitchPoints "xxxxxx [%s]" (gTimepicker)
//
// Group gTimepicker (All)
//
//
//
// data structure
// -----------------------------------------------------------------------------------------------------------
// val HashMap<String, ArrayList<String>> timePicker = newHashMap(
// "TransferItem1" -> newArrayList('item1','item2',...) // enum all to control
// "TransferItem2" -> newArrayList('item3')
// ... // enum all TransferItems and his
// )
//
//
val HashMap<String,ArrayList<String>> timePicker = newHashMap(
"transferItem" -> newArrayList('SprinklerZone'))
rule "check switchpoints 1"
when
// Time cron "0 0/15 * 1/1 * ? *"
Time cron "0/5 * * ? * * *" // for debug, trigger eatch 15 seconds
then
var Number currTimeInterval = ((now.getMinuteOfDay() / 15) + 1).intValue
var Number currDay = now.getDayOfWeek()
logInfo("Rule","Running Rule")
gTimepicker.members.forEach[ currSwitchPlan |
logInfo("Rule",currSwitchPlan.state.toString)
if (currSwitchPlan.state !== NULL) {
var String switchPlan = (currSwitchPlan.state as StringType).toString
var String currKey = currDay.toString
// check the differnt week plans 15,17,67; e.g mo-fr, ...
if (switchPlan.contains('"key":"17"')) currKey = "17"
if (switchPlan.contains('"key":"15"') && (currDay > 0 && currDay < 6)) currKey = "15"
if (switchPlan.contains('"key":"67"') && (currDay > 5 )) currKey = "67"
// determine the scale number in transfer string
var Number countScale = 1
var Boolean stopLoop = false
while ((countScale < 9) && (!stopLoop)) {
if (switchPlan.contains(countScale.toString + '":')) {
if (transform("JSONPATH", "$." + countScale.toString + ".key", switchPlan) == currKey) {
countScale = countScale -1
stopLoop = true
}
countScale = countScale + 1
} else {
// error in transfer string
logError("timepicker","error in transfer string")
countScale = (-1)
stopLoop = true
}
}
if (countScale != (-1)) {
var String[] switchPoints = (transform("JSONPATH", "$." + currKey + ".value", switchPlan)).split(',')
var String[] switchStates = (transform("JSONPATH", "$." + "99", switchPlan)).split(',')
var ArrayList<String> itemToSwitch = new ArrayList(timePicker.get(currSwitchPlan.name))
if (!(itemToSwitch.size() == 1 && "".equals(itemToSwitch.get(0)))) {
itemToSwitch.forEach [ iTS |
var currItem = ScriptServiceUtil.getItemRegistry.getItem(iTS) as GenericItem
var newState = switchStates.get(Integer::parseInt(switchPoints.get(currTimeInterval)))
// send only commands when current state differenced from new state
if (currItem.state.toString != newState) currItem.sendCommand(newState.toString)
]
}
}
}
]
end
//*************************************************************************
rule "manipulate sprinckler"
when
Item SprinklerZone changed
then
// deactivate all sprinckler zones
switch ((spricklerZone.type).toString) {
case "1" : {
// activate zone 1
logInfo("Zone1","Turning on Zone 1")
}
case "2" : {
// activate zone 2
logInfo("Zone2","Turning on Zone 2")
}
case "3" : {
// activate zone 3
logInfo("Zone3","Turning on Zone 3")
}
case "4" : {
// activate zone 4
logInfo("Zone4","Turning on Zone 4")
}
case "0" : {
// turn off zones
logInfo("Zone","Turning off Zones")
}
}
end
I have the HTML Files placed in
openhab2-conf/html/time-line-picker
please tell me what im doing wrong