petergebruers
Thank you for your code! I will definitely try it in the coming days and write the result.
Controller does not get ack from z-uno
Re: Controller does not get ack from z-uno
Because Z-Uno does unsolicited report on the channel and in the mapped non-channeled CC.The only thing I do not understand, is why channel one getter is called three times instead of two...
-
- Posts: 255
- Joined: 26 Jul 2015 17:29
Re: Controller does not get ack from z-uno
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...
Meet me here: https://forum.fibaro.com/index.php?/pro ... rgebruers/ or here: memberlist.php?mode=viewprofile&u=564463
Re: Controller does not get ack from z-uno
One solicited on poll
Re: Controller does not get ack from z-uno
One because controller polls the channel it controls - it do not know about mapping and don't poll the mapped one
-
- Posts: 255
- Joined: 26 Jul 2015 17:29
Re: Controller does not get ack from z-uno
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.
Meet me here: https://forum.fibaro.com/index.php?/pro ... rgebruers/ or here: memberlist.php?mode=viewprofile&u=564463
Re: Controller does not get ack from z-uno
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;
}
}
-
- Posts: 255
- Joined: 26 Jul 2015 17:29
Re: Controller does not get ack from z-uno
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...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.
(...)
Meet me here: https://forum.fibaro.com/index.php?/pro ... rgebruers/ or here: memberlist.php?mode=viewprofile&u=564463
Re: Controller does not get ack from z-uno
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"
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"
Re: Controller does not get ack from z-uno
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
try something like
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;
}
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;
}