Hello, I'm new with node red and programing so please do not destroy me for stupid questions.
In sweat, tears and blo0d I created this:
var count=context.get('count') || 0;
count +=1;
msg.payload=count;
context.set('count',count);
if (count == 3 ) {
count = 0;
}
return msg;
My objective is to recive in the end counter that counts 1,2,3,1,2,3 etc...
Right now I have counter that count from 1 to infinity .... My issue is that im not able to reset this counter after it reaches to some value.
Sorry for beginners question but i'm not so good with programing.
Yeah I have it like this right now, insted of msg I have call services for single entity to change it states.
I was wondering if one function with longer code is better then solution above ....
If its stuid and it works, it means it not so stupid
What I have to type in properties of call service block to corectly read this ?
For example I have Aquara micro switch and I would like to do:
Signle click - On/Off - I have it
Double click - select settings from 4 or 5 presets - I have it right now but Im wondering is there any more efficient wat to do it ....
Hold / release - Dimmer - no code yet....