State received 2 times by Nodered
Moderators: grovkillen, Stuntteam, TD-er
State received 2 times by Nodered
Hi, all
A simple switch on a garage door is connected on GPIO 13 of a nodemcu ESP8266 managed by Easyesp.
When the Garage#Etat changes, a publish command on rules sends :
Publish %sysname%/Garage/Etat,[Garage#Etat] to Home assistant MQTT on a Raspberry Pi 4
Node-red on the same Raspberry Pi 4 receives this state 2 times…… every time !
I try the different combinations of
- ESPEasy Controller > Ignore new/Delete Oldest > Ignore/Check Acknowledgment and Will retain or not
Actually Ignore New + Ignore acknowledgment + Will Retain = off
- EspEasy Hadware : GPIO 13 set as Default or Input : No change on results. Actually set as Input.
- In the log of EasyESP I can check that this Publish command is sent only once.
- I didn’t check parameters in MQTT Broker..... Is there my problem ????
- In Node-red the change state (ON to OFF *AND* OFF to ON) is ALWAYS received 2 times and registered on file Portail.txt on Raspberry….
- I tried different combinations of QOS 0/1/2 without any change on the results…. Always two states received at the same time.
I tried so many tests with these different values that I'm completely lost and I can’t find the good combination of these parameters.....I don’t remember the good values. This problem occured fron only 3 or 4 monthes. Worked correctly before.
Can you help me ?
Best regards
François
Sorry for my poor english….
Here are the rules in Espeasy
// Module portail IP233
on System#Boot do
timerSet,1,60
endon
on Rules#Timer=1 do
Timerset,1,60
Publish %sysname%/SW2/State,[Portail#Etat]
endon
On Portail#Etat do
Publish %sysname%/Portail/Etat,[Portail#Etat]
if [Portail#Etat] = 0
SendToHttp 192.168.1.231,80,'/control?cmd=Event,Portail_Ouverture'
else
SendToHttp 192.168.1.231,80,'/control?cmd=Event,Portail_Fermeture'
endif
endon
Here is the Node export
[{"id":"704ed223.86eca4","type":"mqtt in","z":"ba9b25e5.03e008","name":"Portail_3/Portail/Etat","topic":"Portail_3/Portail/Etat","qos":"0","datatype":"auto","broker":"b3887ed6.b2203","x":110,"y":120,"wires":[["84234ce.f11b23","48515842.a2732"]]},{"id":"b3887ed6.b2203","type":"mqtt-broker","z":"","name":"Cave","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
A simple switch on a garage door is connected on GPIO 13 of a nodemcu ESP8266 managed by Easyesp.
When the Garage#Etat changes, a publish command on rules sends :
Publish %sysname%/Garage/Etat,[Garage#Etat] to Home assistant MQTT on a Raspberry Pi 4
Node-red on the same Raspberry Pi 4 receives this state 2 times…… every time !
I try the different combinations of
- ESPEasy Controller > Ignore new/Delete Oldest > Ignore/Check Acknowledgment and Will retain or not
Actually Ignore New + Ignore acknowledgment + Will Retain = off
- EspEasy Hadware : GPIO 13 set as Default or Input : No change on results. Actually set as Input.
- In the log of EasyESP I can check that this Publish command is sent only once.
- I didn’t check parameters in MQTT Broker..... Is there my problem ????
- In Node-red the change state (ON to OFF *AND* OFF to ON) is ALWAYS received 2 times and registered on file Portail.txt on Raspberry….
- I tried different combinations of QOS 0/1/2 without any change on the results…. Always two states received at the same time.
I tried so many tests with these different values that I'm completely lost and I can’t find the good combination of these parameters.....I don’t remember the good values. This problem occured fron only 3 or 4 monthes. Worked correctly before.
Can you help me ?
Best regards
François
Sorry for my poor english….
Here are the rules in Espeasy
// Module portail IP233
on System#Boot do
timerSet,1,60
endon
on Rules#Timer=1 do
Timerset,1,60
Publish %sysname%/SW2/State,[Portail#Etat]
endon
On Portail#Etat do
Publish %sysname%/Portail/Etat,[Portail#Etat]
if [Portail#Etat] = 0
SendToHttp 192.168.1.231,80,'/control?cmd=Event,Portail_Ouverture'
else
SendToHttp 192.168.1.231,80,'/control?cmd=Event,Portail_Fermeture'
endif
endon
Here is the Node export
[{"id":"704ed223.86eca4","type":"mqtt in","z":"ba9b25e5.03e008","name":"Portail_3/Portail/Etat","topic":"Portail_3/Portail/Etat","qos":"0","datatype":"auto","broker":"b3887ed6.b2203","x":110,"y":120,"wires":[["84234ce.f11b23","48515842.a2732"]]},{"id":"b3887ed6.b2203","type":"mqtt-broker","z":"","name":"Cave","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
Re: State received 2 times by Nodered
You are sending something via sendtohttp.
This isn't the same ESPEasy node, right?
This isn't the same ESPEasy node, right?
Re: State received 2 times by Nodered
These are related to the sending queue.- ESPEasy Controller > Ignore new/Delete Oldest > Ignore/Check Acknowledgment and Will retain or not
Actually Ignore New + Ignore acknowledgment + Will Retain = off
If this queue is full, what to do, like ignore new ones, or delete the oldest one.
Will retain is related to the LWT of MQTT.
When connecting, a MQTT client sends its Last Will and Testament.
The broker will send this LWT message to all subscribed clients when this node is disconnected.
So this has nothing to do with sending messages, but only on what will happen when the node is no longer connected.
The ignore acknowledgement is not really related to MQTT, so I guess I could remove that one from MQTT controller settings.
For sending to HTTP, you may want to wait for an acknowledgement from the web server. But for MQTT there is not really an option to wait for an ack.
About your GPIO-13 switch...
How is it connected? Via a long cable? What configuration do you use in the switch plugin/task for this GPIO? Especially on a real button, you may need some debounce configured.
Using a long cable, you may get extra unexpected triggers, but that's not the issue here so it seems.
How is the switch task configured? Act on "change" or "rising edge" or "falling edge" ?
If it is just a push button, then you should have something like "rising edge" set as it would otherwise trigger on both pressing and releasing the button.
Re: State received 2 times by Nodered
Thanks TD-er for your answer...
Let's me a time to understand exactly what you said "between the lines"...
Answers expected tomorrow morning
Best regards
François
Let's me a time to understand exactly what you said "between the lines"...
Answers expected tomorrow morning
Best regards
François
Re: State received 2 times by Nodered
Hello TD-er
Again, thanks for your answer
In fact I have 2 NodeMcu ESP8266, one on my garage door, the second on my garden gate with a magnetic switch like attached image, on each. One has a short cable (about 15 cm) the second one is longer, about 2 meters.
I have exactly the same problem one the two detectors (as if commmand %sysname%/Garage/Etat,[Garage#Etat] or Portail (=gate) is sent two times at each change state.
The http: command is sent to another Nodemcu in my desk. A LED is blinking and a buzzer is bipping when the garage or the gate is open.
How or where do you specify parameter for the switch task (Change/Rising edge or falling edge) ? For me is on the change state.
Thanks for your help
Best regards
François
Again, thanks for your answer
In fact I have 2 NodeMcu ESP8266, one on my garage door, the second on my garden gate with a magnetic switch like attached image, on each. One has a short cable (about 15 cm) the second one is longer, about 2 meters.
I have exactly the same problem one the two detectors (as if commmand %sysname%/Garage/Etat,[Garage#Etat] or Portail (=gate) is sent two times at each change state.
The http: command is sent to another Nodemcu in my desk. A LED is blinking and a buzzer is bipping when the garage or the gate is open.
How or where do you specify parameter for the switch task (Change/Rising edge or falling edge) ? For me is on the change state.
Thanks for your help
Best regards
François
Re: State received 2 times by Nodered
Adding a task with the "Switch input" plugin.
There you set a GPIO nr, switch type to "Switch" and Switch Button Type to either "Push Button Active Low" or "...High"
You have it now probably set to "Normal Switch", which acts on either change.
"Push Button Active Low" triggers on the level going from high to low.
"Push Button Active High" triggers on the level going from low to high.
"Normal Switch" triggers on both high and low.
There you set a GPIO nr, switch type to "Switch" and Switch Button Type to either "Push Button Active Low" or "...High"
You have it now probably set to "Normal Switch", which acts on either change.
"Push Button Active Low" triggers on the level going from high to low.
"Push Button Active High" triggers on the level going from low to high.
"Normal Switch" triggers on both high and low.
Re: State received 2 times by Nodered
So I set it to normal switch.
Again thanks for you help
Regards
François
Again thanks for you help
Regards
François
Re: State received 2 times by Nodered
I would expect you need one of the other 2, with "normal switch" you will get 2 events
Re: State received 2 times by Nodered
OK... but I receive two times the event Door_Open when the door opens and 2 times the event Door_closed when the door closes.
These event are registered in a document.txt in the Raspberry (2 lines for each event).
It worked correctly (1 line for eac event) 1 year ago.
I probably change a parameter and obtain 2 lines for one event... but which parameter ?
In the log of Easyesp I note only one publish command for each event.
Node-Red receives two times this event.
Regards
François
These event are registered in a document.txt in the Raspberry (2 lines for each event).
It worked correctly (1 line for eac event) 1 year ago.
I probably change a parameter and obtain 2 lines for one event... but which parameter ?
In the log of Easyesp I note only one publish command for each event.
Node-Red receives two times this event.
Regards
François
Re: State received 2 times by Nodered
Is it possible NodeRed receives the event from 2 different sources?
For example via ESPEasy and also MQTT broker (or whatever connections you configured)
For example via ESPEasy and also MQTT broker (or whatever connections you configured)
Re: State received 2 times by Nodered
NO.
NodeRed (running on the Raspberry) receives the event only from the MQTT Broker.
There are two different Publish commands :
Publish %sysname%/SW2/State,[Portail#Etat] sent every minute
Publish %sysname%/Portail/Etat,[Portail#Etat] when the state changes : it's this event which is received 2 times by NodeRed. Perhaps due to MQTT Broker....
NodeRed (running on the Raspberry) receives the event only from the MQTT Broker.
There are two different Publish commands :
Publish %sysname%/SW2/State,[Portail#Etat] sent every minute
Publish %sysname%/Portail/Etat,[Portail#Etat] when the state changes : it's this event which is received 2 times by NodeRed. Perhaps due to MQTT Broker....
Re: State received 2 times by Nodered
Does this publish to the MQTT broker also trigger a state change in ESPEasy?
Re: State received 2 times by Nodered
No... Only from ESP to the MQTT Broker
Re: State received 2 times by Nodered
Can you have a look at the MQTT controller settings?
For example can you set the max. retries as a test to 0?
For example can you set the max. retries as a test to 0?
Re: State received 2 times by Nodered
I'll try tomorrow...
But I have somm difficulties to manage MQTT. This is the part I know not so well...
But I have somm difficulties to manage MQTT. This is the part I know not so well...
Re: State received 2 times by Nodered
I'm talking about the controller setting in ESPEasy.
Re: State received 2 times by Nodered
Hi TD-er
Max retry was at 10.
I change it to 1 (0 is not possible).
No change : NodeRed receives the change state info 2 times at each change state
Again, thanks for your help
Best regards
François
Max retry was at 10.
I change it to 1 (0 is not possible).
No change : NodeRed receives the change state info 2 times at each change state
Again, thanks for your help
Best regards
François
Re: State received 2 times by Nodered
Hmm, then I'm also a bit out of options here as I don't see where this extra message may come from.
Re: State received 2 times by Nodered
TD-er wrote: ↑14 Oct 2022, 13:26 Adding a task with the "Switch input" plugin.
There you set a GPIO nr, switch type to "Switch" and Switch Button Type to either "Push Button Active Low" or "...High"
You have it now probably set to "Normal Switch", which acts on either change.
"Push Button Active Low" triggers on the level going from high to low.
"Push Button Active High" triggers on the level going from low to high.
"Normal Switch" triggers on both high and low.
I don't think that Normal Switch is the suggested option in your situation, either of the Push Button options should be selected.
/Ton (PayPal.me)
Re: State received 2 times by Nodered
No Ath, I want to register in a .txt file each change state : Open action from closed state and Close action from Open state.
My problem is that any change is registered 2 times.
Thanks for your help
My problem is that any change is registered 2 times.
Thanks for your help
Re: State received 2 times by Nodered
in node red, use the "delay" node to put a rate limit in your flow.
it's quite hidden, there you can define the period where your superfluous messages will be dropped and only one will get forwarded.
e.g.:
it's quite hidden, there you can define the period where your superfluous messages will be dropped and only one will get forwarded.
e.g.:
Re: State received 2 times by Nodered
Thanks _Cyber_
I'll try your suggestion and post the result in 2-3 days...
I'll try your suggestion and post the result in 2-3 days...
Re: State received 2 times by Nodered
Hi _Cyber_
I add a rate node with a 6 seconds delay as you suggested and it works !
But... since I added the rate node the result of the join node is inversed : the two members of the Join node are inversed :
I get "day on month : opening at" instead of "opening at : day on month"
Could you explain me that ? How to correct it ?
download/file.php?mode=view&id=7235
I add a rate node with a 6 seconds delay as you suggested and it works !
But... since I added the rate node the result of the join node is inversed : the two members of the Join node are inversed :
I get "day on month : opening at" instead of "opening at : day on month"
Could you explain me that ? How to correct it ?
download/file.php?mode=view&id=7235
- Attachments
-
- Join & Rate.png (64.75 KiB) Viewed 2802 times
[Resolved] State received 2 times by Nodered
I think I find the solution.
I put the rate node just after the MQTT input node and before the Change and the Date/time nodes.
It seems to work fine...
Again thanks to TD-ER and _Cyber_ and others.
Best regards
François
I put the rate node just after the MQTT input node and before the Change and the Date/time nodes.
It seems to work fine...
Again thanks to TD-ER and _Cyber_ and others.
Best regards
François
Who is online
Users browsing this forum: No registered users and 3 guests