NODE-Red vs. Automation

Ich habe eine AUTOMATION die, bei einem Akkustand < 20%, eine Meldung geschickt hat. Das hat immer gut funktioniert.

Dann habe ich es versucht in NR. Bei der AUTOMATION konnte man nur zwischen “unter” und “über” wählen. Ich habe bei NR <= 20% vorgegeben. Ich habe schnell gelernt, dass NR das anders handhabt. Die AUTOMATION hat einmal ausgelöst, NR bei jedem Schritt nach unten. Also bei 20, 19, 18 usw… Gut, in NR auf = 20 geändert, jetzt geht es, aber: Meine FRAU hat so eine IO Zahnbürste, die scheint sich nicht so oft zu melden. In der AUTOMATION war das kein Thema, wenn sich die Bürste erst mit 13% gemeldet hat, weil < 20 das abgedeckt hat. Geht nun leider nicht in NR. Wenn die Bürste sich nicht mit 20 meldet, dann nicht mehr.

Wie kann ich das abfangen? Wert <= 20, aber nur einmal auslösen. Any ideas?

Im 1. Ansatz könntest Du Dir einen Helfer (input_boolean) erzeugen, den Du beim 1. erreichen von <=20% setzt und als Bedingung: Helfer AUS vor die Meldung setzt.
Zum Rücksetzen dann einfach >30% oder so.

Das mit den HELPERn habe ich noch nicht wirklich begriffen… Muss ich mal gucken. :wave:t4:

Nicht gefunden unter “Helper”… :woozy_face:

So sieht das z. Z. aus, jetzt gehe ich erstmal mit dem Hundi raus…

[{"id":"b6f9951b7789ad82","type":"server-state-changed","z":"90edb93b995c41f6","g":"7f1a23f653ce62dc","name":"Sylvia - Handy","server":"1046d712.e31c69","version":5,"outputs":2,"exposeAsEntityConfig":"","entityId":"sensor.sylvia_handy_battery_level","entityIdType":"exact","outputInitially":false,"stateType":"num","ifState":"20","ifStateType":"num","ifStateOperator":"is","outputOnlyOnStateChange":false,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[],"x":120,"y":140,"wires":[["5954b66047db3869"],[]]},{"id":"ca5c76d3c42ff085","type":"comment","z":"90edb93b995c41f6","g":"7f1a23f653ce62dc","name":"Akkuleistung = 20%","info":"","x":130,"y":80,"wires":[]},{"id":"9f28e4a44731bbb8","type":"mqtt out","z":"90edb93b995c41f6","g":"7f1a23f653ce62dc","name":"awtrix/NOTIFY","topic":"awtrix/notify","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"346df2a95aac5785","x":920,"y":260,"wires":[]},{"id":"625c7d50f02ac5c7","type":"function","z":"90edb93b995c41f6","g":"7f1a23f653ce62dc","name":"MSG erzeugen","func":"// Get the data from the sensor\nvar Sylvia_Handy = global.get('homeassistant.homeAssistant.states[\"sensor.sylvia_handy_battery_level\"].state');\n\nmsg.payload = { \"text\": \"A34: \" + Sylvia_Handy + \"%\", \"icon\": \"12833\", \"textCase\": \"2\", \"pushIcon\": \"2\", \"color\": \"ffffff\", \"hold\": true }\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":140,"wires":[["9f28e4a44731bbb8","d28a2afcd18930fa"]]},{"id":"2236d333b712ba0e","type":"server-state-changed","z":"90edb93b995c41f6","g":"7f1a23f653ce62dc","name":"Roberts - Handy","server":"1046d712.e31c69","version":5,"outputs":2,"exposeAsEntityConfig":"","entityId":"sensor.roberts_handy_battery_level","entityIdType":"exact","outputInitially":false,"stateType":"num","ifState":"20","ifStateType":"num","ifStateOperator":"is","outputOnlyOnStateChange":false,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[],"x":120,"y":320,"wires":[["cba43d2c78f47b50"],[]]},{"id":"0f38daa972d92823","type":"function","z":"90edb93b995c41f6","g":"7f1a23f653ce62dc","name":"MSG erzeugen","func":"// Get the data from the sensor\nvar Roberts_Handy = global.get('homeassistant.homeAssistant.states[\"sensor.roberts_handy_battery_level\"].state');\n\nmsg.payload = { \"text\": \"S23: \" + Roberts_Handy + \"%\", \"icon\": \"12833\", \"textCase\": \"2\", \"pushIcon\": \"2\", \"color\": \"ffffff\", \"hold\": true }\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":320,"wires":[["9f28e4a44731bbb8","c81ebfa0ffac6372"]]},{"id":"492a4e7df95cb714","type":"server-state-changed","z":"90edb93b995c41f6","g":"7f1a23f653ce62dc","name":"Roberts - M5 Pad","server":"1046d712.e31c69","version":5,"outputs":2,"exposeAsEntityConfig":"","entityId":"sensor.roberts_pad_battery_level","entityIdType":"exact","outputInitially":false,"stateType":"num","ifState":"20","ifStateType":"num","ifStateOperator":"is","outputOnlyOnStateChange":false,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[],"x":130,"y":380,"wires":[["7bd85f5148e8f105"],[]]},{"id":"12d17a179ac125e3","type":"function","z":"90edb93b995c41f6","g":"7f1a23f653ce62dc","name":"MSG erzeugen","func":"// Get the data from the sensor\nvar Roberts_Pad = global.get('homeassistant.homeAssistant.states[\"sensor.roberts_pad_battery_level\"].state');\n\nmsg.payload = { \"text\": \"M5: \" + Roberts_Pad + \"%\", \"icon\": \"12833\", \"textCase\": \"2\", \"pushIcon\": \"2\", \"color\": \"ffffff\", \"hold\": true }\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":380,"wires":[["9f28e4a44731bbb8"]]},{"id":"a4109b87b72b8cb4","type":"server-state-changed","z":"90edb93b995c41f6","g":"7f1a23f653ce62dc","name":"Sylvias -W19 Pad","server":"1046d712.e31c69","version":5,"outputs":2,"exposeAsEntityConfig":"","entityId":"sensor.sylvias_pad_battery_level","entityIdType":"exact","outputInitially":false,"stateType":"num","ifState":"20","ifStateType":"num","ifStateOperator":"is","outputOnlyOnStateChange":false,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[],"x":120,"y":200,"wires":[["37b44a21caa83c2f"],[]]},{"id":"ac1432dea01fd60a","type":"function","z":"90edb93b995c41f6","g":"7f1a23f653ce62dc","name":"MSG erzeugen","func":"// Get the data from the sensor\nvar Sylvias_Pad = global.get('homeassistant.homeAssistant.states[\"sensor.sylvias_pad_battery_level\"].state');\n\nmsg.payload = { \"text\": \"W19: \" + Sylvias_Pad + \"%\", \"icon\": \"12833\", \"textCase\": \"2\", \"pushIcon\": \"2\", \"color\": \"ffffff\", \"hold\": true }\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":200,"wires":[["9f28e4a44731bbb8"]]},{"id":"c629b7d0cdaaaef9","type":"server-state-changed","z":"90edb93b995c41f6","g":"7f1a23f653ce62dc","name":"Sylvias - IO Zahnbürste","server":"1046d712.e31c69","version":5,"outputs":2,"exposeAsEntityConfig":"","entityId":"sensor.io_series_8_9_075b_battery","entityIdType":"exact","outputInitially":false,"stateType":"num","ifState":"20","ifStateType":"num","ifStateOperator":"is","outputOnlyOnStateChange":false,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[],"x":140,"y":260,"wires":[["ea8e87530a3b9271"],[]]},{"id":"ea8e87530a3b9271","type":"function","z":"90edb93b995c41f6","g":"7f1a23f653ce62dc","name":"MSG erzeugen","func":"// Get the data from the sensor\nvar Sylvias_IO = global.get('homeassistant.homeAssistant.states[\"sensor.io_series_8_9_075b_battery\"].state');\n\nmsg.payload = { \"text\": Sylvias_IO + \"%\", \"icon\": \"52587\", \"textCase\": \"2\", \"pushIcon\": \"2\", \"color\": \"ffffff\", \"hold\": true }\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":260,"wires":[["9f28e4a44731bbb8"]]},{"id":"98adc1386e2bf1a1","type":"inject","z":"90edb93b995c41f6","g":"7f1a23f653ce62dc","name":"Test with 5%","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"5","payloadType":"num","x":130,"y":440,"wires":[["625c7d50f02ac5c7","ac1432dea01fd60a","ea8e87530a3b9271","0f38daa972d92823","12d17a179ac125e3"]]},{"id":"c81ebfa0ffac6372","type":"api-call-service","z":"90edb93b995c41f6","g":"7f1a23f653ce62dc","name":"> Roberts Handy","server":"1046d712.e31c69","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_roberts_handy","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"Dein Handy hat noch 20% Akku!!\",\"title\":\"🔴 Roberts Handy 🔴\",\"data\":{\"type\":\"announce\"}}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":910,"y":320,"wires":[[]]},{"id":"d28a2afcd18930fa","type":"api-call-service","z":"90edb93b995c41f6","g":"7f1a23f653ce62dc","name":"> Sylvias Handy","server":"1046d712.e31c69","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_sylvia_phone","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"Dein Handy hat noch 20% Akku!!\",\"title\":\"🔴 Sylvias Handy 🔴\",\"data\":{\"type\":\"announce\"}}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":920,"y":140,"wires":[[]]},{"id":"5954b66047db3869","type":"api-current-state","z":"90edb93b995c41f6","g":"7f1a23f653ce62dc","name":"Charging?","server":"1046d712.e31c69","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.sylvia_handy_is_charging","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":370,"y":140,"wires":[["625c7d50f02ac5c7"],[]]},{"id":"37b44a21caa83c2f","type":"api-current-state","z":"90edb93b995c41f6","g":"7f1a23f653ce62dc","name":"Charging?","server":"1046d712.e31c69","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.sylvias_pad_is_charging","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":370,"y":200,"wires":[["ac1432dea01fd60a"],[]]},{"id":"cba43d2c78f47b50","type":"api-current-state","z":"90edb93b995c41f6","g":"7f1a23f653ce62dc","name":"Charging?","server":"1046d712.e31c69","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.roberts_handy_is_charging","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":370,"y":320,"wires":[["0f38daa972d92823"],[]]},{"id":"7bd85f5148e8f105","type":"api-current-state","z":"90edb93b995c41f6","g":"7f1a23f653ce62dc","name":"Charging?","server":"1046d712.e31c69","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.roberts_pad_is_charging","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":370,"y":380,"wires":[["12d17a179ac125e3"],[]]},{"id":"1046d712.e31c69","type":"server","name":"Home Assistant","addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"","statusSeparator":"","enableGlobalContextStore":false},{"id":"346df2a95aac5785","type":"mqtt-broker","name":"","broker":"localhost","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]

Ich würde wenn ich in NodeRED arbeite nicht was in Home Assistant in Helfer Speichern um dann in NoderRED weiter damit zu arbeiten.
Ich würde das als Variable “speichern” und dann damit arbeiten.

Schau mal bei „Schalter“, die Entität ist dann „input_boolean“ :wink:

Ich habe da gestern noch was schönes im Netz gefunden.

[{"id":"aceb3f69.5314c","type":"inject","z":"b794137d2f016623","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"24","payloadType":"str","x":130,"y":380,"wires":[["e63f7184.19c09"]],"info":"// If voltage drops below level and we \n  // haven't sent an alert...\n  if (msg.payload < 26 && !context.sentAlert) {\n      // Set the content of the alert\n      msg.payload = \"Oh no!\";\n      // Set the flag so we know not to alert again\n      context.sentAlert = true;\n      // Return the message so the alert is sent\n      return msg;\n  } else if (msg.payload > 26) {\n      // Voltage back to normal, reset alert flag\n      context.sentAlert = false;\n  }\n  // Return null so no message is sent\n  return null;"},{"id":"f7a927e7.0856d8","type":"inject","z":"b794137d2f016623","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"27","payloadType":"str","x":130,"y":440,"wires":[["e63f7184.19c09"]]},{"id":"e63f7184.19c09","type":"switch","z":"b794137d2f016623","name":"","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"26","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":290,"y":400,"wires":[["289ed11e.d7612e"],["7c1c26d9.83e3d8"]]},{"id":"fbece5a6.041318","type":"debug","z":"b794137d2f016623","name":"","active":true,"console":"false","complete":"false","x":770,"y":400,"wires":[]},{"id":"289ed11e.d7612e","type":"trigger","z":"b794137d2f016623","name":"","op1":"1","op2":"0","op1type":"pay","op2type":"str","duration":"0","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":580,"y":400,"wires":[["fbece5a6.041318"]]},{"id":"7c1c26d9.83e3d8","type":"change","z":"b794137d2f016623","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":415,"y":473,"wires":[["289ed11e.d7612e"]]}]

Macht genau was ich will (meine ich), muss ich nur noch bei mir “einbauen”. Somit ist wohl auch dieses Thema gelöst. Wenn jemand nachlesen mag: https://groups.google.com/g/node-red/c/wB3Tp2Z8Z-M