Hi
I'm quite new to the Z-Way stuff. I saw the announcement of the EasyScripting App that I'm very interested in to bind two systems.
So I would like to use the EasyScripting Module to call a web hook of another system via HTTP POST request. The Javascript code to call the request I got from the example documentation of the App.
But how can I integrate the Script within a (automation) rule? I would like to trigger the script only if a sensor value has reached a specific threshold.
Can I use the EasyScript for automation (rules) or do the scripts has to be "selfcontained" including trigger, conditions and actions (if-then-else)?
Thanks!
How to use EasyScripting?
Re: How to use EasyScripting?
Please have a look on the Easy Scripting app - in Chrome it should help you to write the code with a helper.
Re: How to use EasyScripting?
Thanks for your reply!
What I don't understand is WHEN the Script is being triggered/called?
How can I add a Trigger Condition (e.g. Pseudo Code: If (rainSensor.value() > 0))?
What I don't understand is WHEN the Script is being triggered/called?
How can I add a Trigger Condition (e.g. Pseudo Code: If (rainSensor.value() > 0))?
-
- Posts: 155
- Joined: 02 Jan 2016 01:20
Re: How to use EasyScripting?
it is explained in the the app documentation, the script gets triggered on a value update you can specify (even multiple triggers). In you case, it is rainSensor's value. Find the ID of the sensor reading by browsing to in in ZWay and in the browser link you see something like 192.168.0.255:8083/smarthome/#/element/ZWayVDev_zway_50-0-49-1. Take the Device Identifier into your easy scripting app
### ZWayVDev_zway_50-0-49-1
and everytime the value gets updated by ZWay, your script gets called.
### ZWayVDev_zway_50-0-49-1
and everytime the value gets updated by ZWay, your script gets called.
Re: How to use EasyScripting?
Thanks for your hints!
Currently my script looks like this:
The rain rate value has multiple times be over 0.
But the web hooks are not called ...
Am I missing something? How can I debug this? Is there a log file or something?
Currently my script looks like this:
Code: Select all
var req = {method: "POST", async: true}
if (vdev("ZWayVDev_zway_2-0-49-12").value() > 0) {
req.url = "http://<hostname>:<port>/api/webhook/rain"
}
else {
req.url = "http://<hostname>:<port>/api/webhook/norain"
}
http.request(req)
But the web hooks are not called ...
Am I missing something? How can I debug this? Is there a log file or something?
-
- Posts: 155
- Joined: 02 Jan 2016 01:20
Re: How to use EasyScripting?
Because you are missing the event trigger
at the beginning of your script. If your script has multiple values it shall react to you can add additional trigger lines starting with ###.
To simply select those trigger events from all those available on your system, call the easy app code editor from a chrome browser and you see extended support
Code: Select all
//Trigger this script every time that ZWayVDev_zway_2-0-49-12 gets updated
### ZWayVDev_zway_2-0-49-12
var req = {method: "POST", async: true}
if (vdev("ZWayVDev_zway_2-0-49-12").value() > 0) {
req.url = "http://<hostname>:<port>/api/webhook/rain"
}
else {
req.url = "http://<hostname>:<port>/api/webhook/norain"
}
http.request(req)
To simply select those trigger events from all those available on your system, call the easy app code editor from a chrome browser and you see extended support
Re: How to use EasyScripting?
That did the trick! Thanks a lot