I use a transform from the germany openhab forum to read a ICAL calender from internet or locally and extract events.
String GlobalHolidayICAL {http="<[https://www.schulferien.org/media/ical/deutschland/ferien_bayern_%1$tY.ics?k=yRn5ZxhHnEGLS-Q5moUjssrrewdJotK0vjDSiUqnIO0Ld_cm5-wcNJkUNXBBMtWB5j6Van10h4KxggpP2xQPcAGDYJkKP25S6zec7oXmtg:7200000:JS(ical_holiday.js)]"}
String TrashBiomuellICAL {http="<[http://localhost:8080/static/Abfallkalender-Lindenstr-50-xxx_%1$tY.ics:7200000:JS(ical_biomuell.js)]"}
It is working perfect. I just have to manually download a ICAL-File once a year or use the direct link to the file at the internet. Both are in the example. A js-transform-script picks out the ICAL entry of the current day, if there is one.
But the ICAL file does not change over the year and it is enough to start the item calculation once a day to get the needed informations. Yes, I know, i can use the interval and set it to 1 day. But I cannot control at what time the item will updated thsi is why I use 2h at the moment (7200000)
Is there a way to do it a little bit different? To migrate this to a js-script which works with the ICAL-file instead of use it inside of the http-transform?
It will be enough to start the ical_biomuell.js with the ICAL-file as parameter. Similiar to the holiday.js from the forum here. But I’m not so familiar with js-coding and as I understand I must move the script from transform folder to scripts folder and have to change a lot inside of the file. Puh, will be a lot of work.
And a second thing I want to do is to send more parameters to the js-script. In the ICAL-File there are more calenders, for paper trash, plastic trash and so on. At the moment I use different js-transform file to pick out the right value. Will be more flexible to use parameters.
Any hints are welcome.
Current js-transform skeleton is
(function(i)
{
... code
icalParser.parseIcal(input);
... code
})(input);
I think I must do something to get the parameter (input) in another way and get more then one parameter to work with.
my idea is something like:
rule "somehting"
when
Time cron "0 0 1 * * ?"
then
callScript("ical_biomuell", "path to ICAL", "other parameters")
end
Is this possible, I do not find a good documenation for the script part of OH.
Can someone lead me to some js-script examples which work in OH, maybe I can learn from them and solve this problem by myself.