Qubino ZMNHBA2 2 relays doesn't report status?

Others (MiLight, Hue, Toon etc...)

Moderator: leecollings

juankar
Posts: 221
Joined: Saturday 30 August 2014 20:20
Target OS: Linux
Domoticz version: 4.
Location: Spain
Contact:

Re: Qubino ZMNHBA2 2 relays doesn't report status?

Post 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;
?>
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Qubino ZMNHBA2 2 relays doesn't report status?

Post 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;
}
juankar
Posts: 221
Joined: Saturday 30 August 2014 20:20
Target OS: Linux
Domoticz version: 4.
Location: Spain
Contact:

Re: Qubino ZMNHBA2 2 relays doesn't report status?

Post 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
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Qubino ZMNHBA2 2 relays doesn't report status?

Post by Egregius »

Try my script from just above, I added a get_contents of cp.html ;)
And it stops after 5 tries...
juankar
Posts: 221
Joined: Saturday 30 August 2014 20:20
Target OS: Linux
Domoticz version: 4.
Location: Spain
Contact:

Re: Qubino ZMNHBA2 2 relays doesn't report status?

Post by juankar »

Thanks, at this time the script doesn't work all the times. So I'll try this modification.
Bye.
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Qubino ZMNHBA2 2 relays doesn't report status?

Post 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');
jin
Posts: 62
Joined: Thursday 18 September 2014 20:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Qubino ZMNHBA2 2 relays doesn't report status?

Post 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.
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Qubino ZMNHBA2 2 relays doesn't report status?

Post by Egregius »

Yes, only two switches shown. But, do you have lokal attached switches on I1 & I2?
pejo
Posts: 6
Joined: Thursday 13 August 2015 9:17
Target OS: Linux
Domoticz version: Beta
Location: Sweden
Contact:

Re: Qubino ZMNHBA2 2 relays doesn't report status?

Post 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?
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Qubino ZMNHBA2 2 relays doesn't report status?

Post 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 :)
pejo
Posts: 6
Joined: Thursday 13 August 2015 9:17
Target OS: Linux
Domoticz version: Beta
Location: Sweden
Contact:

Re: Qubino ZMNHBA2 2 relays doesn't report status?

Post 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.
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Qubino ZMNHBA2 2 relays doesn't report status?

Post 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
Last edited by Egregius on Wednesday 25 November 2015 13:09, edited 1 time in total.
pejo
Posts: 6
Joined: Thursday 13 August 2015 9:17
Target OS: Linux
Domoticz version: Beta
Location: Sweden
Contact:

Re: Qubino ZMNHBA2 2 relays doesn't report status?

Post by pejo »

OK, I will try your latest script and see if that resolves the problem

Thanks
juankar
Posts: 221
Joined: Saturday 30 August 2014 20:20
Target OS: Linux
Domoticz version: 4.
Location: Spain
Contact:

Re: Qubino ZMNHBA2 2 relays doesn't report status?

Post 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
pejo
Posts: 6
Joined: Thursday 13 August 2015 9:17
Target OS: Linux
Domoticz version: Beta
Location: Sweden
Contact:

Re: Qubino ZMNHBA2 2 relays doesn't report status?

Post 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.
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Qubino ZMNHBA2 2 relays doesn't report status?

Post 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.
pejo
Posts: 6
Joined: Thursday 13 August 2015 9:17
Target OS: Linux
Domoticz version: Beta
Location: Sweden
Contact:

Re: Qubino ZMNHBA2 2 relays doesn't report status?

Post 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?
Attachments
Skärmavbild 2015-09-10 kl. 21.39.06.png
Skärmavbild 2015-09-10 kl. 21.39.06.png (24.92 KiB) Viewed 3512 times
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Qubino ZMNHBA2 2 relays doesn't report status?

Post 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.
pejo
Posts: 6
Joined: Thursday 13 August 2015 9:17
Target OS: Linux
Domoticz version: Beta
Location: Sweden
Contact:

Re: Qubino ZMNHBA2 2 relays doesn't report status?

Post 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.
juankar
Posts: 221
Joined: Saturday 30 August 2014 20:20
Target OS: Linux
Domoticz version: 4.
Location: Spain
Contact:

Re: Qubino ZMNHBA2 2 relays doesn't report status?

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest