Call-service Allows anything to trigger it - node-red-contrib-home-assistant

I’m puzzled by the call service node allowing anything to trigger it. I’m working on a timer that I can adjust on the fly (flow below), however, once I set the timer the lights go off although the timer is still running. To test what was happening I connected an inject node and set the payload to string but left the field blank, after deploying I was able to turn off the light just by pressing the inject mode, so that node is just waiting for anything to trigger it. What other HA nodes could I use for turning off the lights only after the timer finished?

[{"id":"b2da8313.f985e","type":"ui_slider","z":"e6ab8208.bfbbe","name":"timer","label":"M: {{value}}","group":"4bb4b124.c9376","order":7,"width":"2","height":"1","passthru":true,"topic":"","min":"10","max":"20","step":"5","x":130,"y":619,"wires":[["4aa8dbdf.d5e544","feede093.e236f"]]},{"id":"482fc6a7.4c9858","type":"mytimeout","z":"e6ab8208.bfbbe","name":"My Timeout","outtopic":"","outsafe":"on","outwarning":"Warning","outunsafe":"off","warning":"5","timer":"300","repeat":false,"again":false,"x":530,"y":619,"wires":[["9e70f7fa.d93098","992c8aca.9c5ab8"],["e57d6a44.5ff258"]]},{"id":"4aa8dbdf.d5e544","type":"change","z":"e6ab8208.bfbbe","name":"set timer count","rules":[{"t":"set","p":"timeout","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":619,"wires":[["9acbe9d4.b79198","482fc6a7.4c9858"]]},{"id":"9acbe9d4.b79198","type":"debug","z":"e6ab8208.bfbbe","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":490,"y":699,"wires":[]},{"id":"feede093.e236f","type":"debug","z":"e6ab8208.bfbbe","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":290,"y":699,"wires":[]},{"id":"e57d6a44.5ff258","type":"debug","z":"e6ab8208.bfbbe","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":670,"y":700,"wires":[]},{"id":"9e70f7fa.d93098","type":"debug","z":"e6ab8208.bfbbe","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":690,"y":560,"wires":[]},{"id":"992c8aca.9c5ab8","type":"api-call-service","z":"e6ab8208.bfbbe","name":"Off","server":"f0aa0465.fa7ce8","service_domain":"light","service":"turn_off","data":"{\"entity_id\":\"light.master_bedroom_level\"}","mergecontext":"","x":710,"y":619,"wires":[["46378732.65a9c8"]]},{"id":"46378732.65a9c8","type":"debug","z":"e6ab8208.bfbbe","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":850,"y":619,"wires":[]},{"id":"4bb4b124.c9376","type":"ui_group","z":"","name":"Lights","tab":"c5e67c2b.eb40e","order":1,"disp":false,"width":"5","collapse":false},{"id":"f0aa0465.fa7ce8","type":"server","z":"","name":"Home Assistant","url":"http:\\\\xxx.xxx.x.xx:8123","pass":"PASSWORD"},{"id":"c5e67c2b.eb40e","type":"ui_tab","z":"","name":"Dashboard","icon":"dashboard"}]

I’m using the below setup with myTimer … works nice and I can adjust timer dynamically (input_select to variable)

the general sequence is:

  1. select what light to switch on
  2. use HA node to switch-on the light
  3. reading a global variable which I use to keep the duration dynamic (can be selected by input_select)
  4. I have added a telegram node to send a log when light is turned on (does not impact the issue and can be ignored
  5. setting / tickling the timer
  6. proceed only when the timer went “off”
  7. select what light to switch off
  8. use HA node to switch-off the light
  9. check if telegram-logging is enabled
  10. send telegram

[{"id":"72b956bb.e1eac8","type":"link in","z":"e9a592e9.83a77","name":"Light GW","links":["d7f70ea2.d4ba7","8ae0c979.c11a78"],"x":75,"y":760,"wires":[["b519e69a.1ea468"]]},{"id":"b519e69a.1ea468","type":"change","z":"e9a592e9.83a77","name":"GW light","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"data\":{\"entity_id\":\"light.gateway_light_f0b4299aaf29\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":220,"y":760,"wires":[["cfec39ae.d15d08"]]},{"id":"cfec39ae.d15d08","type":"api-call-service","z":"e9a592e9.83a77","name":"Light ON","server":"8ad970d8.e2b73","service_domain":"light","service":"turn_on","data":"","mergecontext":"none","x":400,"y":760,"wires":[["a796d525.2bf298","4bd58b26.da5fa4"]],"icon":"node-red-contrib-home-assistant/arrow-right-bold-hexagon-outline.png"},{"id":"a796d525.2bf298","type":"change","z":"e9a592e9.83a77","name":"House Light timer","rules":[{"t":"set","p":"timeout","pt":"msg","to":"House_Light_timer","tot":"global"},{"t":"set","p":"payload","pt":"msg","to":"ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":760,"wires":[["9b5bee98.fe7bb"]]},{"id":"4bd58b26.da5fa4","type":"api-current-state","z":"e9a592e9.83a77","name":"log?","server":"8ad970d8.e2b73","halt_if":"off","override_topic":true,"override_payload":true,"entity_id":"input_boolean.send_telgram_log","x":550,"y":720,"wires":[["683b250f.e1e11c"]]},{"id":"9b5bee98.fe7bb","type":"mytimeout","z":"e9a592e9.83a77","name":"timer","outtopic":"","outsafe":"on","outwarning":"Warning","outunsafe":"off","warning":"5","timer":"30","repeat":false,"again":false,"x":870,"y":760,"wires":[["4ed02376.34a5ec"],[]]},{"id":"77970856.b76e08","type":"link in","z":"e9a592e9.83a77","name":"Light GW off","links":[],"x":435,"y":720,"wires":[["a796d525.2bf298"]]},{"id":"683b250f.e1e11c","type":"change","z":"e9a592e9.83a77","name":"Telegram","rules":[{"t":"set","p":"myMessage","pt":"global","to":"Hallway light ==> ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":720,"wires":[["3d105a9e.82e406"]]},{"id":"4ed02376.34a5ec","type":"switch","z":"e9a592e9.83a77","name":"off ?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1010,"y":760,"wires":[["a952e4aa.bb1868"]]},{"id":"2e8c5de5.fa5362","type":"change","z":"e9a592e9.83a77","name":"off","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":870,"y":720,"wires":[["9b5bee98.fe7bb"]]},{"id":"3d105a9e.82e406","type":"link out","z":"e9a592e9.83a77","name":"Send Msg","links":["ed951e00.620ec"],"x":735,"y":720,"wires":[]},{"id":"a952e4aa.bb1868","type":"change","z":"e9a592e9.83a77","name":"GW light","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"data\":{\"entity_id\":\"light.gateway_light_f0b4299aaf29\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1180,"y":760,"wires":[["2b627979.32cfa6"]]},{"id":"161ab6a3.aa1b59","type":"link in","z":"e9a592e9.83a77","name":"Light GW off - now","links":["ed2201a6.5ebd2"],"x":795,"y":720,"wires":[["2e8c5de5.fa5362"]]},{"id":"2b627979.32cfa6","type":"api-call-service","z":"e9a592e9.83a77","name":"Light OFF","server":"8ad970d8.e2b73","service_domain":"light","service":"turn_off","data":"","mergecontext":"none","x":1320,"y":760,"wires":[["2554f049.add85"]],"icon":"node-red-contrib-home-assistant/arrow-right-bold-hexagon-outline.png"},{"id":"2554f049.add85","type":"api-current-state","z":"e9a592e9.83a77","name":"log?","server":"8ad970d8.e2b73","halt_if":"off","override_topic":true,"override_payload":true,"entity_id":"input_boolean.send_telgram_log","x":1450,"y":760,"wires":[["707e1a8b.9a2e64"]]},{"id":"707e1a8b.9a2e64","type":"change","z":"e9a592e9.83a77","name":"Telegram","rules":[{"t":"set","p":"myMessage","pt":"global","to":"Hallway light ==> OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1580,"y":760,"wires":[["b2b43870.523a98"]]},{"id":"b2b43870.523a98","type":"link out","z":"e9a592e9.83a77","name":"Send Msg","links":["ed951e00.620ec"],"x":1675,"y":760,"wires":[]},{"id":"8ad970d8.e2b73","type":"server","z":"","name":"Home Assistant","url":"http://hassio/homeassistant","pass":"2bf95b829c8b4824987dcac37eed662a"}]

2 Likes

I see what I was missing, I wasn’t aware I could inject the data! Thank for the help!!

:+1:

I currently inject only one entity_id … for some reason I had problems with several entity_id’s at one time