Hi Guys,
Iam scraping a changing list and want to detect if one of my 4 resulting entities rise in the value.
Using an rising edge filter was not successful as it must detect if the values rise from 0 to a higher value, but also from a value higher 0 to a even higher one…
What would be a good way to determine this changes?
Thanks in advance
share what you’ve got so far please. Share the list
With the current info, I’d create a sensor with the entity node and then work whether it’s growing and above 0 or whatever condition. The entity node will make things easier.
[{"id":"7a6c4126.076e3","type":"trigger-state","z":"937ef78.ec6b408","name":"trigger","server":"9405c3fe.d0a6c","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"sensor.your_entity","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","comparatorType":">","comparatorValueDatatype":"prevEntity","comparatorValue":"state","propertyValue":"new_state.state"},{"targetType":"this_entity","targetValue":"","propertyType":"current_state","comparatorType":">","comparatorValueDatatype":"num","comparatorValue":"0","propertyValue":"new_state.state"}],"inputs":0,"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","enableInput":false,"x":230,"y":280,"wires":[["ed45c407.171858"],[]]},{"id":"ed45c407.171858","type":"debug","z":"937ef78.ec6b408","name":"do","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":360,"y":280,"wires":[]},{"id":"9405c3fe.d0a6c","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]
Make a loop, store the value in a global variable, and if value is higher in the next loop, update the global variable….
Not sure about node-red but you could create a derivative sensor.
share what you’ve got so far please. Share the list
this was my rising edge approach
[{"id":"2916f559c16a2912","type":"api-current-state","z":"0f1244fbb0f7a8c3","name":"","server":"7bbb53f4.e9c61c","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.lmr_on_off","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1080,"y":120,"wires":[["1d58e5358b64a8b5"],[]]},{"id":"1d58e5358b64a8b5","type":"debug","z":"0f1244fbb0f7a8c3","name":"output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1370,"y":120,"wires":[]},{"id":"f750efc8aac4503d","type":"server-state-changed","z":"0f1244fbb0f7a8c3","name":"","server":"7bbb53f4.e9c61c","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.neue_verteilung","entityidfiltertype":"exact","outputinitially":false,"state_type":"num","haltifstate":"","halt_if_type":"num","halt_if_compare":"gt","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":170,"y":40,"wires":[["5987c303a4ea67c8"]]},{"id":"5987c303a4ea67c8","type":"rising-edge","z":"0f1244fbb0f7a8c3","name":"","threshold":"1","x":430,"y":40,"wires":[["46e39478b4d93646"]]},{"id":"46e39478b4d93646","type":"switch","z":"0f1244fbb0f7a8c3","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":570,"y":40,"wires":[["dbd3099d5e5620ed"]]},{"id":"dbd3099d5e5620ed","type":"change","z":"0f1244fbb0f7a8c3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":40,"wires":[["2916f559c16a2912"]]},{"id":"88ab91831a77d312","type":"server-state-changed","z":"0f1244fbb0f7a8c3","name":"","server":"7bbb53f4.e9c61c","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.neue_verteilung_2","entityidfiltertype":"exact","outputinitially":false,"state_type":"num","haltifstate":"","halt_if_type":"num","halt_if_compare":"gt","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":180,"y":100,"wires":[["99101f28a99c040e"]]},{"id":"3bb51532944fd75f","type":"server-state-changed","z":"0f1244fbb0f7a8c3","name":"","server":"7bbb53f4.e9c61c","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.neue_verteilung_3","entityidfiltertype":"exact","outputinitially":false,"state_type":"num","haltifstate":"","halt_if_type":"num","halt_if_compare":"gt","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":180,"y":160,"wires":[["3dafdbb67c673b39"]]},{"id":"12d5383512debfcc","type":"server-state-changed","z":"0f1244fbb0f7a8c3","name":"","server":"7bbb53f4.e9c61c","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.neue_verteilung_4","entityidfiltertype":"exact","outputinitially":false,"state_type":"num","haltifstate":"","halt_if_type":"num","halt_if_compare":"gt","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":180,"y":220,"wires":[["7ff0944d1c7131b0"]]},{"id":"99101f28a99c040e","type":"rising-edge","z":"0f1244fbb0f7a8c3","name":"","threshold":"1","x":430,"y":100,"wires":[["1e259bcd50a44fe8"]]},{"id":"1e259bcd50a44fe8","type":"switch","z":"0f1244fbb0f7a8c3","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":570,"y":100,"wires":[["999951f83cf993ed"]]},{"id":"999951f83cf993ed","type":"change","z":"0f1244fbb0f7a8c3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":100,"wires":[["2916f559c16a2912"]]},{"id":"3dafdbb67c673b39","type":"rising-edge","z":"0f1244fbb0f7a8c3","name":"","threshold":"1","x":430,"y":160,"wires":[["9f38c53ccd263e99"]]},{"id":"9f38c53ccd263e99","type":"switch","z":"0f1244fbb0f7a8c3","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":570,"y":160,"wires":[["d79af5adc9387b7d"]]},{"id":"d79af5adc9387b7d","type":"change","z":"0f1244fbb0f7a8c3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":160,"wires":[["2916f559c16a2912"]]},{"id":"7ff0944d1c7131b0","type":"rising-edge","z":"0f1244fbb0f7a8c3","name":"","threshold":"1","x":430,"y":220,"wires":[["b673881006f44a39"]]},{"id":"b673881006f44a39","type":"switch","z":"0f1244fbb0f7a8c3","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":570,"y":220,"wires":[["619b2d30b292a91e"]]},{"id":"619b2d30b292a91e","type":"change","z":"0f1244fbb0f7a8c3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":220,"wires":[["2916f559c16a2912"]]},{"id":"7bbb53f4.e9c61c","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]
but this only detects if the threshold is triggered (not if it is already above…)
I can not share the list, as it is not public… (it is a system where open spots are distributed)
all for sensors can rise or fall between 0-10 normally they start at a high number and count down and then jump up to a higher number again to start count down again. The high numbers will vary as well as the lower end. On a graph it looks like this with all should-be triggers are circled in red
@obaldius
thanks for that example, this looks very promising I am trying this right now!
@aceindy
I read about this too, but I can not figure out how to get started with variables, do I always need to use the function block to write/read variables?
@seanomat
that looks interesting too I will look into it
thanks everybody, I will let you know if I figured out the solution!
authorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30
This works perfect. But still have the issue that the value can be “NaN” instead of a number… and then miss the jump from NaN to a number > 0
[{"id":"9a19374b.ca64d8","type":"trigger-state","z":"937ef78.ec6b408","name":"trigger","server":"9405c3fe.d0a6c","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"sensor.your_entity","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","comparatorType":">","comparatorValueDatatype":"num","comparatorValue":"0","propertyValue":"new_state.state"}],"inputs":0,"outputs":4,"customoutputs":[{"messageType":"default","messageValue":"","messageValueType":"json","comparatorPropertyType":"previous_state","comparatorType":"is","comparatorValue":"NaN","comparatorValueDataType":"str","comparatorPropertyValue":"old_state.state"},{"messageType":"default","messageValue":"","messageValueType":"json","comparatorPropertyType":"current_state","comparatorType":">","comparatorValue":"state","comparatorValueDataType":"prevEntity","comparatorPropertyValue":"new_state.state"}],"outputinitially":false,"state_type":"str","enableInput":false,"x":230,"y":1020,"wires":[[],[],["18a8791a.8ef8b7"],["18a8791a.8ef8b7"]]},{"id":"18a8791a.8ef8b7","type":"debug","z":"937ef78.ec6b408","name":"Do","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":390,"y":1040,"wires":[]},{"id":"9405c3fe.d0a6c","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]
wow, that is really awesome! Thanks you so much! this seems to work.
I guess, this is a lot of experience? or are there some good tutorials i did not find.