One node inputs output only if inputs are different

Hi all. I've searched and couldn't find a solution to my problem. I think it should be easy but can't figure it out on my own. Just starting with node-red. I'm using it with home assistant.

I have a poll state node that checks temp every 10 minutes. I use this flow to send a message to my tv. What I want is to be able to only send the message if the temperature changes. Better yet, would be output if change and compare for 3 times and if even then temperature didn't change output anyway.

Can you help me?

Have you looked at the Filter node?

It ofers "block unless the value changes" and "block unless the value changes by n%"

This should work

[{"id":"89faddb4.adcff","type":"inject","z":"aaa27ee4852b402b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"20","payloadType":"num","x":110,"y":660,"wires":[["69d74780.c3706","d8105e11.a53ba8"]]},{"id":"69d74780.c3706","type":"rbe","z":"aaa27ee4852b402b","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":330,"y":660,"wires":[["e5efcba5.436668"]]},{"id":"d8105e11.a53ba8","type":"join","z":"aaa27ee4852b402b","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":330,"y":720,"wires":[["b91de405.26f66"]]},{"id":"defae9a4.8f94a","type":"inject","z":"aaa27ee4852b402b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"21","payloadType":"num","x":110,"y":720,"wires":[["69d74780.c3706","d8105e11.a53ba8"]]},{"id":"e5efcba5.436668","type":"change","z":"aaa27ee4852b402b","name":"","rules":[{"t":"set","p":"complete","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":660,"wires":[["d8105e11.a53ba8"]]},{"id":"b91de405.26f66","type":"change","z":"aaa27ee4852b402b","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$$.payload[-1]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":720,"wires":[["f5f3d227.61fc28"]]},{"id":"f5f3d227.61fc28","type":"debug","z":"aaa27ee4852b402b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":720,"wires":[]}]

if 3 payloads the same it will output, or if payload changes it will output.

I've seen some flows using the filter node but can't seem to know how to use it. It can do the part "block unless the value changes" but, where/how can I do the "block unless the value changes by n%" ?

imagem

This is my current flow:

[{"id":"3085c8029a404c08","type":"api-call-service","z":"804ab9ebc9da9197","name":"Notifica TV","server":"e1926eef.58258","version":5,"debugenabled":false,"domain":"notify","service":"tv_sala","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"A temperatura no exterior Ă© de {{payload}}\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":810,"y":580,"wires":[[]]},{"id":"6d0a40ac81937050","type":"api-current-state","z":"804ab9ebc9da9197","name":"Verifica Estado TV","server":"e1926eef.58258","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"media_player.tv_sala","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"flow","value":"","valueType":"entityState"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":630,"y":580,"wires":[["3085c8029a404c08"],[]]},{"id":"e04ecc6f9501148c","type":"poll-state","z":"804ab9ebc9da9197","name":"Temp","server":"e1926eef.58258","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"10","updateIntervalType":"num","updateIntervalUnits":"minutes","outputinitially":false,"outputonchanged":false,"entity_id":"sensor.temp_exterior","state_type":"str","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":55.20000076293945,"y":577.5999755859375,"wires":[["bddb7f249a6576e3"]]},{"id":"bddb7f249a6576e3","type":"rbe","z":"804ab9ebc9da9197","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":270,"y":580,"wires":[["6d0a40ac81937050"]]},{"id":"e1926eef.58258","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m"}]

I only use 1 input. Your example seems to be useful for 2 different inputs.

It is two inject simulating different readings connect your HA node to both the filter and the join.

ahh... ok. Sorry. I didn't understood it

If you select "block unless value change is greater than", you can then enter eg "10%" and choose if the comparison should be with the last input or output value.

[{"id":"4d711fe85855c6fd","type":"rbe","z":"ac631a6e.90e038","name":"","func":"deadband","gap":"10%","start":"","inout":"in","septopics":true,"property":"payload","topi":"topic","x":520,"y":200,"wires":[["d1416f72b38a04d5"]]},{"id":"d1416f72b38a04d5","type":"debug","z":"ac631a6e.90e038","name":"debug 35","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":660,"y":200,"wires":[]},{"id":"2389ba4fd1a59acc","type":"inject","z":"ac631a6e.90e038","name":"120.9 (109.9 + 10.0001%)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"120.9","payloadType":"num","x":310,"y":240,"wires":[["4d711fe85855c6fd"]]},{"id":"4d896c47c9651f4f","type":"inject","z":"ac631a6e.90e038","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"100","payloadType":"num","x":250,"y":160,"wires":[["4d711fe85855c6fd"]]},{"id":"c05ecea30a051b17","type":"inject","z":"ac631a6e.90e038","name":"109.9 (100 + 9.9%) ","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"109.9","payloadType":"num","x":290,"y":200,"wires":[["4d711fe85855c6fd"]]}]
1 Like

@E1cid I've marked your answer as the solution. I does exactly what I wanted. Thank you.

@jbudd Thank you for your contribution, too.

2 Likes

SO much to learn... Thank you again.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.