Page 3 of 5
Re: Qubino ZMNHBA2 2 relays doesn't report status?
Posted: Thursday 20 August 2015 1:38
by juankar
Hello
The script Works fine.... but sometimes it doesn't.
I don't lnow the reason but the script doesn't exit with OK, but no error is reported.
I tried to execute and execute and execute several times until it returns the OK status.
I've thought to modify the script to execute a while loop, removing the sleep() sentence. It would be:
#!/usr/bin/php
<?php
$zwaveurl = '
http://127.0.0.1:8080/ozwcp/refreshpost.html';
$zwavedata = array('fun' => 'racp', 'node' => '4');
$zwaveoptions = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => http_build_query($zwavedata),
),
);
$zwavecontext = stream_context_create($zwaveoptions);
$zwaveresult = '';
while ($zwaveresult != "OK") {
$zwaveresult = file_get_contents($zwaveurl, false, $zwavecontext);
}
echo 'Resultado: '.$zwaveresult;
echo PHP_EOL;
?>
Re: Qubino ZMNHBA2 2 relays doesn't report status?
Posted: Thursday 20 August 2015 7:42
by Egregius
It was yust my findings that the sleep was the key to have a good result. Without the sleep the refresh comes to quick.
Bad idea to have it in a constant loop. How will the loop stop if somethings wrong?
Good idea to check te result do!
Recently I learned that sometimes the script stopped working. At least until I opened the zwave control panel in a browser. Like something needs to be authenticated or activated, don't know.
Now I have:
Code: Select all
#!/usr/bin/php
<?php
file_get_contents('http://127.0.0.1:8080/ozwcp/cp.html');
$zwaveurl = 'http://127.0.0.1:8080/ozwcp/refreshpost.html';
$zwavedata = array('fun' => 'racp', 'node' => '10');
$zwaveoptions = array(
'http' => array(
'header' => 'Content-Type: application/x-www-form-urlencoded\r\n',
'method' => 'POST',
'content' => http_build_query($zwavedata),
),
);
$zwavecontext = stream_context_create($zwaveoptions);
for ($k = 1 ; $k <= 5; $k++){
sleep(3);
$result = file_get_contents($zwaveurl, false, $zwavecontext);echo $result.PHP_EOL;
if($result=='OK') die;
}
Re: Qubino ZMNHBA2 2 relays doesn't report status?
Posted: Thursday 20 August 2015 11:42
by juankar
Yes, there is the posibility if an endless loop, so it¡s posible to add a counter to avoid it. When it works it does without sleep
But yes, you are right, it looks like if it need an "activation" or so
If a switch manually the light the script doesn't work, then I switch it on/off in the dashboard or I make a refresh in the Control Panel, and after that the script Works fine.
I need to check but I think this happens the first time I switch (manually) the light every day.
bye
Re: Qubino ZMNHBA2 2 relays doesn't report status?
Posted: Thursday 20 August 2015 12:43
by Egregius
Try my script from just above, I added a get_contents of cp.html

And it stops after 5 tries...
Re: Qubino ZMNHBA2 2 relays doesn't report status?
Posted: Thursday 20 August 2015 17:03
by juankar
Thanks, at this time the script doesn't work all the times. So I'll try this modification.
Bye.
Re: Qubino ZMNHBA2 2 relays doesn't report status?
Posted: Thursday 20 August 2015 23:53
by Egregius
Damned, still not good.
Apparantly it's not enough to include cp.html.
Even more, when I opened cp.html in a browser I got a white screen. Only after going to the hardware page in Domoticz I got the control panel again and the script worked again.
So, now I'm trying with adding
Code: Select all
file_get_contents('http://127.0.0.1:8080/#/Hardware');
Re: Qubino ZMNHBA2 2 relays doesn't report status?
Posted: Monday 07 September 2015 0:34
by jin
Hi,
the domoticz shipped config Config/qubino/ZMNHBA2.xml is not in sync with the upstream OZW version.
I confirm using the OZW upstream version, this device works perfectly and only two switches are recognized. (with the shipped domoticz version I have three devices and the update status doesn't works)
Gizmocuz, can you make a sync from OZW config tree? (and a binary library rebuild also if you can).
Thank you very much!
With kind regards.
Re: Qubino ZMNHBA2 2 relays doesn't report status?
Posted: Monday 07 September 2015 5:56
by Egregius
Yes, only two switches shown. But, do you have lokal attached switches on I1 & I2?
Re: Qubino ZMNHBA2 2 relays doesn't report status?
Posted: Wednesday 09 September 2015 14:34
by pejo
I'm also having problems with this device.
With the latest change in OZW config I see 2 devices.
I have push-buttons attached to L1 and L2 and if I operate the first line it works fine. I can turn on and off lights attached to Q1 just fine.
The problems starts when I turn on Q2 with L2. It turns on OK, but when I'm going to turn it off it never works as it should.
Example:
1. Both Q1 and Q2 are turned on.
2. Press the button attached to L2 and both Q1 and Q2 turns off for a second and turns on again. Pressing L2 again yields the same result.
3. If I turn off Q1 with L1 and then try to turn off Q2 with L2 it usually turns off after 3 or so tries.
Is that the same behavior you are seeing?
Re: Qubino ZMNHBA2 2 relays doesn't report status?
Posted: Wednesday 09 September 2015 18:45
by Egregius
Remove the following to Config/qubino/ZMNHBA2.xml
Code: Select all
<!-- Map endpoints to instances -->
<CommandClass id="96" mapping="endpoints" />
And you'll have 3 switches. Add the script to the first switch. Works perfect here

Re: Qubino ZMNHBA2 2 relays doesn't report status?
Posted: Wednesday 09 September 2015 18:48
by pejo
Can you operate the switches with L1 and L2 without a problem after you apply the script?
I tried the script earlier and I got pretty much the same result.
Re: Qubino ZMNHBA2 2 relays doesn't report status?
Posted: Wednesday 09 September 2015 21:48
by Egregius
Yes, here it works as it should.
Just keep in mind that the switch with ID1 is a 'global' switch, that one should trigger the script.
ID2=Q1, ID3=Q2.
To be up to date, my latest code for this:
Code: Select all
<?php
function RefreshZwave($node) {
global $domoticzurl;
file_get_contents($domoticzurl.'type=openzwavenodes&idx=5');
$zwaveurl='http://127.0.0.1:8084/ozwcp/refreshpost.html';
$zwavedata=array('fun'=>'racp','node'=>$node);
$zwaveoptions = array('http'=>array('header'=>'Content-Type: application/x-www-form-urlencoded\r\n','method'=>'POST','content'=>http_build_query($zwavedata),),);
$zwavecontext=stream_context_create($zwaveoptions);
for ($k=1;$k<=5;$k++){sleep(2);$result=file_get_contents($zwaveurl,false,$zwavecontext);if($result=='OK') break;}
}
Since I changed the first file_get_contents it keeps on working
I don't call the script from the first switch anymore. Instead of that I do it from my cron script:
Code: Select all
<?php
//Refresh Zwave node
if($STTV>$time-10) RefreshZwave(10);
if($STLichtHallZolder>$time-10) RefreshZwave(20);
if($STLichtInkomVoordeur>$time-10) RefreshZwave(23);
if($STLichtTerrasGarage>$time-10) RefreshZwave(16);
All used scripts are available at
https://github.com/Egregius/PHP-Custom- ... r-Domoticz
Re: Qubino ZMNHBA2 2 relays doesn't report status?
Posted: Wednesday 09 September 2015 21:51
by pejo
OK, I will try your latest script and see if that resolves the problem
Thanks
Re: Qubino ZMNHBA2 2 relays doesn't report status?
Posted: Wednesday 09 September 2015 23:38
by juankar
Hello
I'm reading this post and I wonder if is there any switch that sends status when swtched manually?
I have Philio and it doesn't sends status when manually switched. I need polling or this tricky (the script mentioned in these posts).
Thanks
Re: Qubino ZMNHBA2 2 relays doesn't report status?
Posted: Thursday 10 September 2015 14:08
by pejo
I tried putting a call to RefreshZwave in a while(1) loop but it doesn't work as it should anyway.
It works one time to turn off the relays individually. the second time it's back to the same erratic behavior.
Where I end up turning both Q1 and Q2 off when using the button attached to L2. Pretty much the same thing as before.
Re: Qubino ZMNHBA2 2 relays doesn't report status?
Posted: Thursday 10 September 2015 18:22
by Egregius
Can you post the complete code you used?
And did you remove the endpoints mapping from the config? After that you also need to remove the zwcfg xml file, or at least remove the id's from there.
Re: Qubino ZMNHBA2 2 relays doesn't report status?
Posted: Thursday 10 September 2015 21:42
by pejo
I tried again tonight with removing the zwcfg file.
But i't still not 100% correct.
The problem is when I have both Q1 and Q2 turned on.
If I turn off Q1 first and then turn off Q2 it works.
However turning off Q2 first, is also turning Q1 off for a second and then they are both enabled again.
This is the code I'm running. I start it with "php refresh.php".
Code: Select all
<?php
function RefreshZwave($node) {
$domoticzurl='http://127.0.0.1:8080/json.htm?';
file_get_contents($domoticzurl.'type=openzwavenodes&idx=5');
$zwaveurl='http://127.0.0.1:8080/ozwcp/refreshpost.html';
$zwavedata=array('fun'=>'racp','node'=>$node);
$zwaveoptions = array('http'=>array('header'=>'Content-Type: application/x-www-form-urlencoded\r\n','method'=>'POST','content'=>http_build_query($zwavedata),),);
$zwavecontext=stream_context_create($zwaveoptions);
for ($k=1;$k<=5;$k++)
{
sleep(2);
$result=file_get_contents($zwaveurl,false,$zwavecontext);
echo $result . "\n";
if($result=='OK')
break;
}
}
while(1)
{
echo "Refreshing...\n";
RefreshZwave(17);
}
?>
Am I right with the node id being 17?
Re: Qubino ZMNHBA2 2 relays doesn't report status?
Posted: Friday 11 September 2015 5:43
by Egregius
Yes, the NodeID is the number to use.
In the first line there's a idx=5, should be the IDX of your zwave hardware.
But what with the while(1)? That's a continous loop!
There is already a loop in the function that will try 5 times to get a OK.
Re: Qubino ZMNHBA2 2 relays doesn't report status?
Posted: Friday 11 September 2015 8:09
by pejo
Instead of calling the script after every switch change, I added the call to RefreshZwave in a while(1) loop to call it over and over again.
So it's not there to try more than 5 times, it's just how i set it up to try out your solution.
Re: Qubino ZMNHBA2 2 relays doesn't report status?
Posted: Friday 11 September 2015 19:07
by juankar
Then, perhaps it would be better to use polling isntead of this infinite loop.
The advantage of this script is that it substitutes the reporting status not sent by devices. If devices send its status when this one changes, this wotkaround wouldn't be necessary
And this remind me a repeated question: is there any switch that sends status when switched manually?
Bye