Controller does not get ack from z-uno

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
sega66
Posts: 38
Joined: 30 Jul 2017 19:31

Re: Controller does not get ack from z-uno

Post by sega66 »

petergebruers
Thank you for your code! I will definitely try it in the coming days and write the result.
User avatar
PoltoS
Posts: 7562
Joined: 26 Jan 2011 19:36

Re: Controller does not get ack from z-uno

Post by PoltoS »

The only thing I do not understand, is why channel one getter is called three times instead of two...
Because Z-Uno does unsolicited report on the channel and in the mapped non-channeled CC.
petergebruers
Posts: 255
Joined: 26 Jul 2015 17:29

Re: Controller does not get ack from z-uno

Post by petergebruers »

PoltoS wrote:
24 Nov 2017 12:13
The only thing I do not understand, is why channel one getter is called three times instead of two...
Because Z-Uno does unsolicited report on the channel and in the mapped non-channeled CC.
Thank you for your fast reply. I think I get what you mean, but how do I get three reports? One unsolicited on the channel and one unsolicited on the mapped non-channeled CC equals two. So the third one is an unsolicited from the controller? In that case, I expect one solicited on the channel and one solicited on the mapped non-channeled CC, that is another two, and that brings us to the total of four. So there has to be another explanation. It is not terribly important, but I am curious... :)
User avatar
PoltoS
Posts: 7562
Joined: 26 Jan 2011 19:36

Re: Controller does not get ack from z-uno

Post by PoltoS »

One solicited on poll
User avatar
PoltoS
Posts: 7562
Joined: 26 Jan 2011 19:36

Re: Controller does not get ack from z-uno

Post by PoltoS »

One because controller polls the channel it controls - it do not know about mapping and don't poll the mapped one
petergebruers
Posts: 255
Joined: 26 Jul 2015 17:29

Re: Controller does not get ack from z-uno

Post by petergebruers »

PoltoS wrote:
24 Nov 2017 16:29
One because controller polls the channel it controls - it do not know about mapping and don't poll the mapped one
Sure! Got it! Thanks!

So my log in the previous post is 100% as expected and represents 100% of all the real trafic between controller and device. Good to know.
knst08
Posts: 28
Joined: 15 Oct 2017 20:14

Re: Controller does not get ack from z-uno

Post by knst08 »

sega66 wrote:
22 Nov 2017 18:13
Thank you!
How to use a lot of "ZUNO_SWITCH_BINARY"? Can use the delay ?
I store an array of last reported values and each loop call finds one channel that needs to be reported (comparing actual and last reported value), reports and updates last reported value. Also there is a check to run this process not once per 100ms. Thus z-uno sends reports only for one channel at a loop call and with delays enough to keep network functional.

Also as I've noticed millis() is very expensive, so I call it only once per loop and store in var passing to all functions where it is required.
Had about 10 calls to millis() after adding caching thing became 2 times faster (1050 loop cycles per second against 550 without millis caching)

here is function called from loop

Code: Select all

void ZWaveController::main(long millis){
    if (millis - timer>100 && !context->zwaveLearning){
        lastReportedChannel++;
        if (lastReportedChannel == 11) lastReportedChannel=1;
        if(lastReportedChannel==1){ 
            if(lastReportedRelayState[lastReportedChannel] != (context->bypass?255:0) ) {
                report(lastReportedChannel);
                lastReportedRelayState[lastReportedChannel] = (context->bypass?255:0);
            }
        }
        else if(lastReportedChannel<10){
            byte channelMask = 1 << (lastReportedChannel-2);
            boolean currentValue = ((context->requestedRelayOnOff & channelMask) == channelMask ? 255 :0);
            if(lastReportedRelayState[lastReportedChannel] != currentValue) {
                report(lastReportedChannel);
                lastReportedRelayState[lastReportedChannel] = currentValue;
            }
        }
        else if (lastPower!=context->power && (millis  - lastPowerReport>30000) ){
            report(lastReportedChannel);
            lastPowerReport=millis ;
            lastPower = context->power;
        }
        timer=millis ;
    }

    if(learningStart!=0 && millis  - learningStart>learningTime*1000){
        context->zwaveLearning=false;
        learningStart=0;
    }
}
petergebruers
Posts: 255
Joined: 26 Jul 2015 17:29

Re: Controller does not get ack from z-uno

Post by petergebruers »

knst08 wrote:
25 Nov 2017 13:12
(...)
I store an array of last reported values and each loop call finds one channel that needs to be reported (comparing actual and last reported value), reports and updates last reported value. Also there is a check to run this process not once per 100ms. Thus z-uno sends reports only for one channel at a loop call and with delays enough to keep network functional.
(...)
Thank your for sharing your solution. I fully agree with you, reporting should be "quite limited", which for me also means never to send more than ten updates per second and preferably less than that... and the least possible amount of updates too. Maybe, when everybody uses Z-Wave Plus with 2 channels this can be increased, I do not know, most of my sensors are still Z-Wave (though all of them support 40k and higher bitrate) and my HC2 still has an old 300 series chip. I did some test on my HC2 and I empirically determined I can toggle a relay (only) about 20 times per second, including all processing and completely blocking all other communication. This was some months ago, I am not sure if the results are still valid, it might depend on HC firmware. I have never tried such a stress test on my RaZberry, so I do not know if the results are similar...
sega66
Posts: 38
Joined: 30 Jul 2017 19:31

Re: Controller does not get ack from z-uno

Post by sega66 »

knst08
Thanks for the answer.
Could you show the complete code on the example of my code on the previous page!
I do not know how to insert your code.
Please show the complete code, for example, for two "ZUNO_SWITCH_BINARY"
knst08
Posts: 28
Joined: 15 Oct 2017 20:14

Re: Controller does not get ack from z-uno

Post by knst08 »

My code is hardly applicable to your case - your sketch does not send unsolicited reports.
And I do not see why adding another channel may slow down the communication. But try to move everything but variable set from setter to loop

insead of

Code: Select all

byte switchValue1 = 0;
void loop()
{

}
void setterSwitch1(byte value) {
  digitalWrite(RelePin1, (value > 0) ? LOW : HIGH);

  switchValue1 = value;
}
try something like

Code: Select all


long timer=millis();
byte requestedSwitchValue1 = 0;
byte switchValue1 = 0;
void loop()
{
	if (millis()-timer>100){ //Once per 100ms
		if (switchValue1 != requestedSwitchValue1){
			switchValue1 = requestedSwitchValue1;
			digitalWrite(RelePin1, (switchValue1 > 0) ? LOW : HIGH);
			}
		timer=millis();
		}
}

void setterSwitch1(byte value) {
  requestedSwitchValue1 = value;
}

Post Reply