Timeline picker to setup heating, light and so on

Tags: #<Tag:0x00007f0147e41c28>

(torsten) #43

It’s possible to control more when one item.
But in your usecase its not a good solution. Every controlled item will received the same command.

See item1, item2 and so on

// val HashMap<String, ArrayList> timePicker = newHashMap(
// “TransferItem1” -> newArrayList(‘item1’,‘item2’,…) // enum all item to control
// “TransferItem2” -> newArrayList(‘item3’)

For you; each zone need his one timepicker but you can use the example.rules file and send the command ON/OFF or whatever your sprinkler needed. Then is the second rule and the second proxy item obsolet.

So I’m gonna write this down and see if there’s a way.

(Christopher Hemmings) #44

thanks for that. Just tested and it works great.
Just to tweak the display

Thanks again for the time in this.

(Christopher Hemmings) #45

in regards to the each switchpoint on at the same time,
You could have the different colours, and the time entry would highlight the whole square for one item, half the square each if you have 2 items and so on. but i dont know enough about the coding just yet to determine what the rule would do.
I would have to look at that.

(Christopher Hemmings) #46

one other question, how can i change the colours of the background.
I use Dark mode in basic UI, it would be good to have that option.
where in switchpointset.js do i change this

(torsten) #47

Give me a little time. The Darkmode is a issue for the next version.

(Christopher Hemmings) #49

This is the command that is sent when the calendar looks like this


From what i can gather. The blanks are not being defaulted to 0, they are being defaulted to OFF and when i go through and set something to OFF, it then changes to 0, which is what ive done for the rest of tuesday.

After manually turning everything to OFF using the picker, i get the following


As you can see, the first entry for most days is still off. I dont know why.
But everything else is set to 0.

What can we do to fix this?

There is also an issue with key value # 2


This is what i get when this is selected, you can see there is a blank spot at the first entry then a “,” then the number starts.

(Jürgen Baginski) #50

I got it working now, however observed the CORS problematic when using the IP in the webview, changing it to the name made it working.
Additionally I had to use the “states=OFF,ON” although this was written to be the default.
Also VSCode complains about:
Cannot refer to the non-final variable XX inside a lambda expression
for CurrDay, SwitchStates,SwitchPoints and CurrTimeIntervall although it is working.

Used Weview:

Webview url="/static/time-line-picker/index.html?ip=myOHpi:8080&amp;transferItem=TransferItem&amp;states=OFF,ON&amp;yAxisLabel=1,2,3,4,5,6,7" height=10

I’m ready to install the Xmas-Lights. :+1:

(torsten) #51

You may want to try a single lamp or a sprinckler that you just turn on and off. It’s running.

>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) {
    **log here**

Then you can log the transferd command here.

(torsten) #52

You have observed the CORS problematic.
Are you calling the BasicUI from a internal device or from remote?
The name


Where is this name set?
I will look the state defaults.

(Jürgen Baginski) #53

MyOHpi is the local name of my Raspi3, and yes I’m using it in the local net.

(torsten) #54

CORS is a security mechanism from modern browsers and i dosent find a simple solution for this.
I think a Proxy server is to much overhead.

Maybe someone has find a working solution in conjunction with the REST interface here?

To prevent trouble in the webview, the calling ip from openhab server and the ip from the REST interface must be equal. Or the notation from @opus is right.

(Christopher Hemmings) #55


It works fine, The issue seems to be some small bugs.

The Transfer item is being defaulted to whatever the first item is in grey, not 0.

in my case it defaults to 0. When i turn on zones, it then changes from OFF to 1,2,3 or 4. but the defaults are still OFF.

Yesterday i went through and selected each square with a zone, then again with OFF.

Now they are all set to 0.

My current Transfer item string is


Which is correct, But for some reason, in the string you can see the first value for each day is OFF, and the rest are 0.

There just seems some small bugs.

Also after setting the transfer item to use mapdb, this is restored on startup. so that works fine also.

Also, the issue is still there for the key value 2.

This is what key value 1 looks like, starts with OFF


and this is key value 2, starts with a blank entry


This would only be a problem if you have something to turn on or off from Midnight to 00:15 which i dont, but i thought you may know what this problem is.

(torsten) #56

I’m not in a position to reproduce that behavior. Perhaps you have an older version from switchPointSet.js?
But dont worry, the first entry in transferItem is never used.

In the new development version i have added an new url parameter (lang=en). So the label of y-axis is in english. :slightly_smiling_face:
Feel free to test it. https://gitlab.com/RNTs_3/openhab-timeline-picker/tree/develop
note: you must replace the index.html and the SwitchPointSet.js

For over languages of label y-axis i need help. :face_with_raised_eyebrow:

(Christopher Hemmings) #57

as i said, its not an issue now, but its what was happening on my system. I was able to get around it by selecting all the off timeslots as well as the on timeslots.

I have also adjusted my file to be in english.

Full example for a time based light control system
(Olivier) #58

Hi, it looks to work fine for a lot of you guys but I have some problem to get rid of the message “error in transfer string” in the log. I guess my items file is probably not correcty configured and I do not see from the above example what I need to define exactly. Do I need to add (gTimepicker) for each item defined in the TransfertItem of the HashMap?
This may sound trivial for question but I’m new in the OpneHab world (sorry for that).
Thank you in advance for your time in answering me.

Next to my question I just have a remark:
In the example.sitemap I noticed that at the end of the URL a " is missing (between the yAxisLabel and the height which breaks openHABpanel on iOS (and not android).

(torsten) #59

please show your sitemap (only the webview element) and the releated item entrys.
The group gTimepickerYou must assign only the item TransferString. When you this widget more when one times used, then you will define a second and third item TransferString1, TransferString2, … . This Items must you assign gTimepicker.

Thanks for the hint.

(Olivier) #60

Hi Torsen,
My sitemap looks like this
Frame label=“Terrarium”
Switch item=Terrarium1
Switch item=Terrarium2
Webview url=“,ON&yAxisLabel=17” height=13

and in the log i got the following:
Item ‘TransferItem’ received command {“1”:{“key”:“17”,“value”:“OFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0”},“99”:“OFF,ON”}

My items has the following entries:
Group gTimepicker (All)
String TransferItem “[%s]” (gTimepicker)
Switch Terrarium1 “Terrarium Lamp1” [ “Switchable” ] {
channel=“zwave:device:9344abd1:node6:switch_binary1” }
Switch Terrarium2 “Terrarium Lamp2” [ “Switchable” ] {
channel=“zwave:device:9344abd1:node6:switch_binary2” }

and finaly my rules contains:
val HashMap<String,ArrayList> timePicker = newHashMap(
“TransferItem” -> newArrayList(‘Terrarium1’,‘Terrarium2’))

Do you see the culprit (me of course but in the config files)?

(torsten) #61

Hi Oliver,
i mean you have an older development version and this brakes.
Please download the current development brunch on Gitlab https://gitlab.com/RNTs_3/openhab-timeline-picker/tree/develop and copy all files one more time. (index.html, switchPointSet.css, switchPointSet.js) Unfortunally you must also insert the new example.rules file an customize with your HasMap.

After this reinstall you must change the webview url one time to url=“,ON,1&yAxisLabel=17”
and accept the next question. Then save the timeline.
Now you can call your previous webviewurl (without the addional 1) and it’s dosen’t throw an error - i hope.
The last procedure clears the old data in transfer string.

(torsten) #62

In this version you can add an addional url parameter


for english y axis label.

(Olivier) #63

Hi Torsten, Thanks for your reply. I have uploaded the latest version of index.html, switchPointSet.js, switchPointSet.css, vue-resource.js and vue.js.
I have updated my rules with your new v0.5 version but I still have the “error in transfer string”.

The logs give
Item ‘TransferItem’ received command {“1”:{“key”:“17”,“value”:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,0,0,0]},“99”:“OFF,ON”}

Other thought?