Send Z-Wave command in script?
Moderator: leecollings
- Ben0it
- Posts: 17
- Joined: Sunday 31 January 2016 21:22
- Target OS: Linux
- Domoticz version: 3.6745
- Location: France
- Contact:
Send Z-Wave command in script?
Hello,
Is it possible to send a Z-Wave command to a device in LUA?
For instance, I would like to change the ring color of a Fibaro wall plug (FGWPE). Using the OpenZWave control panel (as shown in the picture below) I can do this, but using a LUA script, is it possible also?
Best Regards,
Is it possible to send a Z-Wave command to a device in LUA?
For instance, I would like to change the ring color of a Fibaro wall plug (FGWPE). Using the OpenZWave control panel (as shown in the picture below) I can do this, but using a LUA script, is it possible also?
Best Regards,
Last edited by Ben0it on Thursday 11 February 2016 20:49, edited 1 time in total.
-
Benoît.
Benoît.
- Egregius
- Posts: 2589
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Send Z-Wave command in script?
Don't know about lua, but possible in PHP:
What to post can be looked up in developer view of your browser. The example above sets the illumination to green of node 85.
The first file_get_contents is just for authentication.
Code: Select all
<?php
$domoticzurl='http://127.0.0.1:8080/';
$zwaveidx=7;
file_get_contents($domoticzurl.'json.htm?type=openzwavenodes&idx='.$zwaveidx);
function ValuePost($command) {
global $domoticzurl;
$zwaveurl=$domoticzurl.'ozwcp/valuepost.html';
$zwaveoptions = array('http'=>array('header'=>'Content-Type: application/x-www-form-urlencoded\r\n','method'=>'POST','content'=>$command,),);
$zwavecontext=stream_context_create($zwaveoptions);
$result=file_get_contents($zwaveurl,false,$zwavecontext);
return $result;
}
echo ValuePost('85-CONFIGURATION-config-list-1-62=Green illumination');
The first file_get_contents is just for authentication.
- Ben0it
- Posts: 17
- Joined: Sunday 31 January 2016 21:22
- Target OS: Linux
- Domoticz version: 3.6745
- Location: France
- Contact:
Re: Send Z-Wave command in script?
Thanks for the code, I will try it and report about the result here.
-
Benoît.
Benoît.
- Ben0it
- Posts: 17
- Joined: Sunday 31 January 2016 21:22
- Target OS: Linux
- Domoticz version: 3.6745
- Location: France
- Contact:
Re: Send Z-Wave command in script?
Good evening,
Finally, I could find some spare time to play with these commands...it works!
Thanks a lot for the hint.
Best Regards,
Finally, I could find some spare time to play with these commands...it works!
Thanks a lot for the hint.
Best Regards,
-
Benoît.
Benoît.
- Egregius
- Posts: 2589
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Send Z-Wave command in script?
You're sure the 3th line is still in the code?
Without that line the second url fails after some time.
Code: Select all
file_get_contents($domoticzurl.'json.htm?type=openzwavenodes&idx='.$zwaveidx);
- Ben0it
- Posts: 17
- Joined: Sunday 31 January 2016 21:22
- Target OS: Linux
- Domoticz version: 3.6745
- Location: France
- Contact:
Re: Send Z-Wave command in script?
Hi,
Here is my code, I invoque from BASH interpreter with arguments:
Invocation from shell is performed as follows:
2016-03-28 - Actually, it seems to fail after a while. Once it fails, if I manually change a parameter from Domoticz' web interface in the OZW control panel, my script works again.
Best Regards,
Here is my code, I invoque from BASH interpreter with arguments:
Code: Select all
$domoticzURL = 'http://127.0.0.1:8080/';
if (count($argv) != 4)
{
$command = basename($argv[0]);
echo "Usage: {$command} node function value\n";
exit(0);
}
$zwaveNodeID = $argv[1];
$nodeFunction = $argv[2];
$nodeFunctionValue = $argv[3];
function Authenticate($domoticzURL, $zwaveIDX)
{
$result = json_decode(file_get_contents($domoticzURL.'json.htm?type=openzwavenodes&idx='.$zwaveIDX, false, NULL), true);
if (strtoupper($result['status']) == "OK")
{
return true;
}
return $result;
}
function SetNodeValue($domoticzURL, $zwaveNodeID, $functionNumber, $functionValue)
{
$zwaveURL = $domoticzURL.'ozwcp/valuepost.html';
$zwaveCommand = "{$zwaveNodeID}-CONFIGURATION-config-list-1-{$functionNumber}={$functionValue}";
$zwaveOptions = array('http'=>array('header'=>'Content-Type: application/x-www-form-urlencoded\r\n','method'=>'POST','content'=>$zwaveCommand,),);
$zwaveContext = stream_context_create($zwaveOptions);
$result = file_get_contents($zwaveURL, false, $zwaveContext);
if (strtoupper($result) == "OK")
{
return true;
}
return $result;
}
$result = Authenticate($domoticzURL, $zwaveNodeID);
if ($result != true)
{
echo "Failed to authenticate: {$result}";
return 1;
}
$result = SetNodeValue($domoticzURL, $zwaveNodeID, $nodeFunction, "{$nodeFunctionValue}");
if ($result != true)
{
echo "Failed to set parameter: {$result}";
return 2;
}
return 0;
Code: Select all
php -f bin/ozwcmd.php 3 62 "Red illumination"
Best Regards,
-
Benoît.
Benoît.
-
- Posts: 24
- Joined: Monday 27 April 2015 20:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.8258
- Location: Netherlands
- Contact:
Re: Send Z-Wave command in script?
If I look at the PHP code, I would say that one should be able to convert this to a curl command.
I don't know how I should use the PHP code. I don't have the file: 'ozwcp/valuepost.html';
I want to have a simple curl command to switch the alarm sound of the zwave aeotec siren dependend of the situation.
I don't know how I should use the PHP code. I don't have the file: 'ozwcp/valuepost.html';
I want to have a simple curl command to switch the alarm sound of the zwave aeotec siren dependend of the situation.
-
- Posts: 221
- Joined: Saturday 30 August 2014 20:20
- Target OS: Linux
- Domoticz version: 4.
- Location: Spain
- Contact:
Re: Send Z-Wave command in script?
Curl command equivalent:
curl --data "85-CONFIGURATION-config-list-1-62=Green illumination" http://127.0.0.1:8080/ozwcp/valuepost.html
valuepost.html does not exist as webpage, it's a page "inside http Domoticz server"
curl --data "85-CONFIGURATION-config-list-1-62=Green illumination" http://127.0.0.1:8080/ozwcp/valuepost.html
valuepost.html does not exist as webpage, it's a page "inside http Domoticz server"
-
- Posts: 8
- Joined: Tuesday 13 October 2015 22:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Send Z-Wave command in script?
Hi there,
I was wondering. When invoking the script with nodeID, Function and Value, how does one know the id of the function and the possible values. In the examples the function '62' is called. What is function 62 and what are the other functions?
Hope someone can help.
Thanx in advance.
I was wondering. When invoking the script with nodeID, Function and Value, how does one know the id of the function and the possible values. In the examples the function '62' is called. What is function 62 and what are the other functions?
Hope someone can help.
Thanx in advance.
Re: Send Z-Wave command in script?
I have the same question. How did you come up with the "85-CONFIGURATION-config-list-1-62=Green illumination" string? Thanks.
Who is online
Users browsing this forum: No registered users and 1 guest