job
(Joachim Boeddeker)
February 15, 2018, 11:47pm
1
I try to find a reason to use a script (openHAB-Xtend-Scripts, not shell scripts). Currently i use many rules and my script folder is totally empty.
the language is the same as the rules language
parameters are not supported
So, if i need the exact same code fragment in two different rules, i can use scripts. But in what kind of use case does this make sense? There maybe some, but i can’t think of any. At best, the scripts could be used as something like scenes, to keep the rules a bit more clean. But is that all?
What are your script examples? I am interested how you use the scripts.
Thanks for any input.
After some time, i discovered some ideas:
This is a simple concept for scene management. I really like it for its simplicity.
The following is needed:
1 item
1 rule
plenty of scripts: one per scene (openHAB flavor, no shell scripts)
1 sitemap
The main concept is simple. Each script defines a special scene. With a specialized mapping in the sitemap you can call the script you like.
Prior to that concept, i had several SwitchITems which each triggered a special rule. This bunch of SwitchItems could be removed.
The item:
String call…
I have a number of Buttons around my house to trigger functions. But which functions at which locations?
That’s so difficult to plan apart from the obvious “turn the local light on”. The scene management provided me the idea how to simplify this.
I use the following keys/buttons, depending on location:
If the key is located near wall switches i use the homematic ones: HM-PB-2-WM55 .
For buttons located e.g. under the table or somewhere else i use the Xiaomi Aqara switches .
Both switche…
After i discovered the magic of scripts, i translated several functions of my smarthome to scripts. Before using scripts, this sunrise was implemented as a complex lambda with 5 parameters. Ugly.
Now it is not reusable anymore, but you can just copy it and adjust the light bulb items. Simplified by large.
This strategy can be reused wherever you need to loop over a longer duration and do not want to use Thread.sleep. With the second script as the loop body you omit the writing of a complex Cre…
spy0r
(Stefan)
February 16, 2018, 6:30am
2
good question… i only have scripts calculating some physics like absolute humidity. Calculations that may never change and don’t belong to your rules code, but indeed, good question
1 Like
hhors
(Harold H)
February 17, 2018, 10:51am
3
I have been struggling with the same question. Not having the possibility to pass parameters is making scripts a bit lame.
The only reason I see for using scripts is when you have different kind of triggers, but the same logic.
And another use case would be when you have different kinds of pre and post-processing around the same block of logic.
1 Like
job
(Joachim Boeddeker)
February 18, 2018, 11:41pm
4
Looks like scripts are rarely used.
If even at all.
Chod
(Jeff Haskel)
April 8, 2018, 1:05am
5
accessing the system that is running openhab / command line code/bash items that provide other tools
job
(Joachim Boeddeker)
September 4, 2018, 3:31pm
6
After some time, i discovered some ideas:
This is a simple concept for scene management. I really like it for its simplicity.
The following is needed:
1 item
1 rule
plenty of scripts: one per scene (openHAB flavor, no shell scripts)
1 sitemap
The main concept is simple. Each script defines a special scene. With a specialized mapping in the sitemap you can call the script you like.
Prior to that concept, i had several SwitchITems which each triggered a special rule. This bunch of SwitchItems could be removed.
The item:
String call…
I have a number of Buttons around my house to trigger functions. But which functions at which locations?
That’s so difficult to plan apart from the obvious “turn the local light on”. The scene management provided me the idea how to simplify this.
I use the following keys/buttons, depending on location:
If the key is located near wall switches i use the homematic ones: HM-PB-2-WM55 .
For buttons located e.g. under the table or somewhere else i use the Xiaomi Aqara switches .
Both switche…
After i discovered the magic of scripts, i translated several functions of my smarthome to scripts. Before using scripts, this sunrise was implemented as a complex lambda with 5 parameters. Ugly.
Now it is not reusable anymore, but you can just copy it and adjust the light bulb items. Simplified by large.
This strategy can be reused wherever you need to loop over a longer duration and do not want to use Thread.sleep. With the second script as the loop body you omit the writing of a complex Cre…