Diagnosing Node Red flows/ history

Hi, Im working on my sleep routine and most of it already works, but now I had some unexpected behavior.

Sleep mode is activated via a helper/bool, which works well.
Then all lights get turned off and I’m using Hass workstation to shut my PC down.
Lastly, I’m turning off smart switch that shuts off power to the PC, printer, stereo etc.

To make sure my running PC doesn’t get turned off, I have an AND gate running that checks if the sleep bool is active and if a virtual sensor is not reporting any activity for the PC

However now, the “pc power off” switch is randomly called and none of the conditions of the AND gate are met. I checked the history of the sleep bool and it wasn’t active during that time and the virtual sensor also works as expected.

So I wonder how I can figure out what called this switch?

You have “PC shut down” in the top part of the picture and “PC power off” in the bottom. Did you mean to do that? Seems like “PC shut down” should be removed from the top part of the picture and only the lower one should exist (since that requires both checks to pass)

EDIT: Also what is the node you are using for the “AND gate”? I am not familiar with that one and don’t see a node that looks like it in my palette.

@CentralCommand yes thats intentional. the “shut down” is a hass workstation command. that executes a windows shutdown command via the hass workstation service that runs on the PC.

the “power off” is the smartswitch that phyically shuts of the switch from which the PC is powered.

the gate comes from “node-red-contrib-boolean-logic” from the many logic gate options I tested this seemed to be the simplest one.

**[{"id":"97aba0f8a5c773f2","type":"tab","label":"Bedroom lights v2","disabled":false,"info":"","env":[]},{"id":"136c13e32b82c7cc","type":"api-call-service","z":"97aba0f8a5c773f2","name":"","server":"","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.osram_weis_level_light_color_on_off"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1770,"y":1660,"wires":[["c1d58ef68de71456"]]},{"id":"c1d58ef68de71456","type":"debug","z":"97aba0f8a5c773f2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1810,"y":1600,"wires":[]},{"id":"7fd47cc53899440b","type":"server-state-changed","z":"97aba0f8a5c773f2","name":"","server":"","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.ewelink_ms01_9f514525_ias_zone","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[],"x":340,"y":120,"wires":[["b2cc679e55317c4c"],[]]},{"id":"b2cc679e55317c4c","type":"ha-wait-until","z":"97aba0f8a5c773f2","name":"wait until charging","server":"","version":1,"outputs":2,"entityId":"binary_sensor.fig_lx1_is_charging","entityIdFilterType":"exact","property":"state","comparator":"is","value":"on","valueType":"str","timeout":"3","timeoutType":"num","timeoutUnits":"minutes","entityLocation":"data","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":690,"y":120,"wires":[["b21f378f8d05b4c9"],[]]},{"id":"b21f378f8d05b4c9","type":"time-range-switch","z":"97aba0f8a5c773f2","name":"","lat":"","lon":"","startTime":"22:00","endTime":"02:00","startOffset":0,"endOffset":0,"x":890,"y":120,"wires":[["116f994fa4525684","a303451151300304"],[]]},{"id":"33fa5a0c3b51abe5","type":"api-call-service","z":"97aba0f8a5c773f2","name":"Bedroom lights out","server":"","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.osram_weis_level_light_color_on_off"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"x":610,"y":240,"wires":[[]]},{"id":"116f994fa4525684","type":"api-call-service","z":"97aba0f8a5c773f2","name":"sleep bool on","server":"","version":5,"debugenabled":false,"domain":"input_boolean","service":"turn_on","areaId":[],"deviceId":[],"entityId":["input_boolean.schlafen"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1130,"y":140,"wires":[[]]},{"id":"20b2c047924bb830","type":"server-state-changed","z":"97aba0f8a5c773f2","name":"Sleepmode on","server":"","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.schlafen","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"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"}],"x":150,"y":380,"wires":[["33fa5a0c3b51abe5","4ea03322241f1450","849c3d186456fce4","604cf210eafcc475","0cea5219ae66f3a2"],[]]},{"id":"4ea03322241f1450","type":"api-call-service","z":"97aba0f8a5c773f2","name":"Kitchen power off","server":"","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.smart_plug_4_socket_1"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":610,"y":300,"wires":[[]]},{"id":"849c3d186456fce4","type":"api-call-service","z":"97aba0f8a5c773f2","name":"living room lights off","server":"","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.wohnzimmerlampe_broadlink_switch"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":610,"y":360,"wires":[[]]},{"id":"e8958dedc2d55aa2","type":"comment","z":"97aba0f8a5c773f2","name":"Trigger sleep routine","info":"","x":150,"y":40,"wires":[]},{"id":"2798d6a2f10c6788","type":"comment","z":"97aba0f8a5c773f2","name":"Sleep routine","info":"","x":110,"y":240,"wires":[]},{"id":"604cf210eafcc475","type":"delay","z":"97aba0f8a5c773f2","name":"","pauseType":"delay","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":580,"y":420,"wires":[["0cdeef54a424fb58"]]},{"id":"7a64fcef3c317b61","type":"api-call-service","z":"97aba0f8a5c773f2","name":"PC, printer, stereo power off","server":"","version":5,"debugenabled":true,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.pc_socket_1"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1160,"y":660,"wires":[[]]},{"id":"0cdeef54a424fb58","type":"api-call-service","z":"97aba0f8a5c773f2","name":"PC shut down","server":"","version":5,"debugenabled":false,"domain":"switch","service":"toggle","areaId":[],"deviceId":[],"entityId":["switch.pccshutdown"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":760,"y":420,"wires":[["4e32f13f9aa2f759"]]},{"id":"a303451151300304","type":"api-call-service","z":"97aba0f8a5c773f2","name":"awake bool off","server":"","version":5,"debugenabled":false,"domain":"input_boolean","service":"turn_off","areaId":[],"deviceId":[],"entityId":["input_boolean.wach"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1140,"y":80,"wires":[[]]},{"id":"cc45eb91e3c013e6","type":"trigger-state","z":"97aba0f8a5c773f2","name":"Hass Worstation dummy sensor unavailable","server":"","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"sensor.dummy","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"unavailable"}],"inputs":1,"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","enableInput":true,"x":210,"y":640,"wires":[["8d7126c1f5859f71","47c255c08ad3e8e1"],[]]},{"id":"8334a714d54741be","type":"server-state-changed","z":"97aba0f8a5c773f2","name":"","server":"","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.philips_sml001_fc6b090b_occupancy","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"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":"true","valueType":"bool"},{"property":"topic","propertyType":"msg","value":"motionsensor1","valueType":"str"}],"x":400,"y":1060,"wires":[["54a147affeded3c9","850e15b43e5132c7"],[]]},{"id":"3e0a95c373fbc42b","type":"api-call-service","z":"97aba0f8a5c773f2","name":"Wake turn on","server":"","version":5,"debugenabled":false,"domain":"input_boolean","service":"turn_on","areaId":[],"deviceId":[],"entityId":["input_boolean.wach"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1230,"y":1060,"wires":[[]]},{"id":"afa3d74796a04646","type":"api-call-service","z":"97aba0f8a5c773f2","name":"Sleep turn off","server":"","version":5,"debugenabled":false,"domain":"input_boolean","service":"turn_off","areaId":[],"deviceId":[],"entityId":["input_boolean.schlafen"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1230,"y":1120,"wires":[[]]},{"id":"c04f6e93afda5182","type":"comment","z":"97aba0f8a5c773f2","name":"Sleep Wake on off","info":"","x":150,"y":1000,"wires":[]},{"id":"54a147affeded3c9","type":"debug","z":"97aba0f8a5c773f2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1030,"y":940,"wires":[]},{"id":"1a90a718.5c0409","type":"BooleanLogicUltimate","z":"97aba0f8a5c773f2","name":"","filtertrue":"both","persist":true,"sInitializeWith":"WaitForPayload","triggertopic":"trigger","outputtriggeredby":"all","inputCount":2,"topic":"result","restrictinputevaluation":false,"delayEvaluation":"","x":830,"y":1580,"wires":[["5f9fbfcc.d2c34"],[],[]]},{"id":"81ef6fec.5d413","type":"inject","z":"97aba0f8a5c773f2","name":"Night","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Dark","payload":"true","payloadType":"bool","x":620,"y":1600,"wires":[["1a90a718.5c0409"]]},{"id":"e0d5d620.966478","type":"inject","z":"97aba0f8a5c773f2","name":"Daylight","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Dark","payload":"false","payloadType":"bool","x":610,"y":1560,"wires":[["1a90a718.5c0409"]]},{"id":"1c2f8e73.2c22ba","type":"inject","z":"97aba0f8a5c773f2","name":"Motion detect true","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Motion","payload":"true","payloadType":"bool","x":580,"y":1660,"wires":[["1a90a718.5c0409"]]},{"id":"5f9fbfcc.d2c34","type":"debug","z":"97aba0f8a5c773f2","name":"Garden Light","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1030,"y":1580,"wires":[]},{"id":"201baa3d.7c63ae","type":"inject","z":"97aba0f8a5c773f2","name":"Motion detect false","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Motion","payload":"false","payloadType":"bool","x":580,"y":1700,"wires":[["1a90a718.5c0409"]]},{"id":"b65f4ff4.bfe2c8","type":"comment","z":"97aba0f8a5c773f2","name":"Motion sensor turns on lights, when it's dark. The light turns off itself at day","info":"","x":740,"y":1520,"wires":[]},{"id":"53a10a7a.cf1894","type":"BooleanLogicUltimate","z":"97aba0f8a5c773f2","name":"","filtertrue":"onlytrue","persist":true,"sInitializeWith":"true","triggertopic":"Pushbutton","outputtriggeredby":"onlyonetopic","inputCount":2,"topic":"result","restrictinputevaluation":false,"delayEvaluation":"","x":780,"y":1960,"wires":[["cd9244ea.471b78"],[],[]]},{"id":"9318320b.670af8","type":"inject","z":"97aba0f8a5c773f2","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Pushbutton","payload":"true","payloadType":"bool","x":560,"y":1960,"wires":[["53a10a7a.cf1894"]]},{"id":"20a981b9.552b4e","type":"inject","z":"97aba0f8a5c773f2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"IsNight","payload":"true","payloadType":"bool","x":550,"y":2060,"wires":[["53a10a7a.cf1894"]]},{"id":"da0dff55.d7888","type":"inject","z":"97aba0f8a5c773f2","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"IsNight","payload":"false","payloadType":"bool","x":550,"y":2100,"wires":[["53a10a7a.cf1894"]]},{"id":"7129d101.1fb7d8","type":"comment","z":"97aba0f8a5c773f2","name":"Pushbutton to switch on light stairs, only if it's night.","info":"","x":650,"y":1920,"wires":[]},{"id":"cd9244ea.471b78","type":"debug","z":"97aba0f8a5c773f2","name":"Temporized Stairs Lightbulb","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1020,"y":1960,"wires":[]},{"id":"ad5a62a1.7ad81","type":"comment","z":"97aba0f8a5c773f2","name":"Brightness sensor","info":"","x":550,"y":2020,"wires":[]},{"id":"5383d88d1d5d530d","type":"BooleanLogic","z":"97aba0f8a5c773f2","name":"","operation":"AND","inputCount":2,"topic":"result","x":700,"y":2320,"wires":[["5df037ee107a7acf"]]},{"id":"4ab270bf3a44ec31","type":"inject","z":"97aba0f8a5c773f2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"result1","payload":"true","payloadType":"bool","x":480,"y":2240,"wires":[["5383d88d1d5d530d"]]},{"id":"7a99739b213a5ac8","type":"inject","z":"97aba0f8a5c773f2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"result2","payload":"true","payloadType":"bool","x":460,"y":2340,"wires":[["5383d88d1d5d530d"]]},{"id":"5df037ee107a7acf","type":"debug","z":"97aba0f8a5c773f2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":950,"y":2320,"wires":[]},{"id":"d9e9a8db05c94356","type":"inject","z":"97aba0f8a5c773f2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"result3","payload":"false","payloadType":"bool","x":510,"y":2420,"wires":[["5383d88d1d5d530d"]]},{"id":"aa455a1b3bf9264b","type":"debug","z":"97aba0f8a5c773f2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1010,"y":1020,"wires":[]},{"id":"fa3c7b0d9406ed87","type":"debug","z":"97aba0f8a5c773f2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1270,"y":960,"wires":[]},{"id":"b3af0667151c5323","type":"BooleanLogic","z":"97aba0f8a5c773f2","name":"","operation":"AND","inputCount":"3","topic":"result","x":700,"y":600,"wires":[["ab2822c5af8e9be3","44e19f0fddf97128","9992bd12ed5174ca"]]},{"id":"ab2822c5af8e9be3","type":"api-call-service","z":"97aba0f8a5c773f2","name":"","server":"","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_fig_lx1","areaId":[],"deviceId":[],"entityId":[],"data":"{\t    \"title\": \"Switch called\",\t    \"message\": \"PC turned off\"\t\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1130,"y":580,"wires":[[]]},{"id":"8d7126c1f5859f71","type":"change","z":"97aba0f8a5c773f2","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"unavailable","fromt":"str","to":"true","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"sleep_mode_on_topic2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":640,"wires":[["b3af0667151c5323"]]},{"id":"47c255c08ad3e8e1","type":"debug","z":"97aba0f8a5c773f2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":230,"y":580,"wires":[]},{"id":"4e32f13f9aa2f759","type":"debug","z":"97aba0f8a5c773f2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":930,"y":420,"wires":[]},{"id":"850e15b43e5132c7","type":"time-range-switch","z":"97aba0f8a5c773f2","name":"","lat":"","lon":"","startTime":"06:00","endTime":"13:00","startOffset":0,"endOffset":0,"x":810,"y":1080,"wires":[["3e0a95c373fbc42b","afa3d74796a04646"],[]]},{"id":"44e19f0fddf97128","type":"delay","z":"97aba0f8a5c773f2","name":"","pauseType":"delay","timeout":"60","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":920,"y":660,"wires":[["7a64fcef3c317b61"]]},{"id":"9992bd12ed5174ca","type":"debug","z":"97aba0f8a5c773f2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":890,"y":560,"wires":[]},{"id":"0cea5219ae66f3a2","type":"change","z":"97aba0f8a5c773f2","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"on","fromt":"str","to":"true","tot":"bool"},{"t":"set","p":"topic","pt":"msg","to":"sleep_mode_on_topic3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":580,"wires":[["b3af0667151c5323"]]}]**

If I’m understanding the flow correctly, the bottom part of the flow is only supposed to run when sleep mode is on and the dummy sensor is unavailable. If this is so you can replace the first half of the bottom flow with a wait-until node.

[{"id":"33fa5a0c3b51abe5","type":"api-call-service","z":"97aba0f8a5c773f2","name":"Bedroom lights out","server":"","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.osram_weis_level_light_color_on_off"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"x":610,"y":240,"wires":[[]]},{"id":"20b2c047924bb830","type":"server-state-changed","z":"97aba0f8a5c773f2","name":"Sleepmode on","server":"","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.schlafen","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"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"}],"x":150,"y":380,"wires":[["33fa5a0c3b51abe5","4ea03322241f1450","849c3d186456fce4","604cf210eafcc475","a91cd66c3df4e033"],[]]},{"id":"4ea03322241f1450","type":"api-call-service","z":"97aba0f8a5c773f2","name":"Kitchen power off","server":"","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.smart_plug_4_socket_1"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":610,"y":300,"wires":[[]]},{"id":"849c3d186456fce4","type":"api-call-service","z":"97aba0f8a5c773f2","name":"living room lights off","server":"","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.wohnzimmerlampe_broadlink_switch"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":610,"y":360,"wires":[[]]},{"id":"2798d6a2f10c6788","type":"comment","z":"97aba0f8a5c773f2","name":"Sleep routine","info":"","x":110,"y":240,"wires":[]},{"id":"604cf210eafcc475","type":"delay","z":"97aba0f8a5c773f2","name":"","pauseType":"delay","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":580,"y":420,"wires":[["0cdeef54a424fb58"]]},{"id":"7a64fcef3c317b61","type":"api-call-service","z":"97aba0f8a5c773f2","name":"PC, printer, stereo power off","server":"","version":5,"debugenabled":true,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.pc_socket_1"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":952,"y":512,"wires":[[]]},{"id":"0cdeef54a424fb58","type":"api-call-service","z":"97aba0f8a5c773f2","name":"PC shut down","server":"","version":5,"debugenabled":false,"domain":"switch","service":"toggle","areaId":[],"deviceId":[],"entityId":["switch.pccshutdown"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":760,"y":420,"wires":[["4e32f13f9aa2f759"]]},{"id":"ab2822c5af8e9be3","type":"api-call-service","z":"97aba0f8a5c773f2","name":"","server":"","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_fig_lx1","areaId":[],"deviceId":[],"entityId":[],"data":"{\t    \"title\": \"Switch called\",\t    \"message\": \"PC turned off\"\t\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":786,"y":464,"wires":[[]]},{"id":"4e32f13f9aa2f759","type":"debug","z":"97aba0f8a5c773f2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":930,"y":420,"wires":[]},{"id":"44e19f0fddf97128","type":"delay","z":"97aba0f8a5c773f2","name":"","pauseType":"delay","timeout":"60","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":740,"y":512,"wires":[["7a64fcef3c317b61"]]},{"id":"a91cd66c3df4e033","type":"ha-wait-until","z":"97aba0f8a5c773f2","name":"","server":"","version":1,"outputs":1,"entityId":"sensor.dummy","entityIdFilterType":"exact","property":"state","comparator":"is","value":"unavailable","valueType":"str","timeout":"0","timeoutType":"num","timeoutUnits":"seconds","entityLocation":"data","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":580,"y":464,"wires":[["44e19f0fddf97128","ab2822c5af8e9be3"]]}]
1 Like

Yea what Kermit said sounds a lot easier.

For reference though I just installed that node and I believe your bug is that the boolean logic node isn’t actually a gate. When you have it set to AND and two topics each time it receives a message what happens is this:

  1. Received only messages with one topic - no output provided by the node regardless of what is in the messages.
  2. Received one or more message with a second topic - outputs a message with payload set to either true or false based on the result of comparing the latest message received in each topic

So essentially your “gate” is only a gate until it receives a message from each events: state node. After that its no longer a gate, its always outputting a message for every message it receives.

EDIT: Here’s a simple test case I was using for it if you want to try it out for yourself:

[{"id":"ea5fce610a471d6f","type":"BooleanLogic","z":"f9be3564.a66948","name":"","operation":"AND","inputCount":2,"topic":"topic","x":700,"y":660,"wires":[["6b0d29efcbff63ed"]]},{"id":"9788f9769353a5c8","type":"inject","z":"f9be3564.a66948","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"a","payload":"true","payloadType":"bool","x":430,"y":620,"wires":[["ea5fce610a471d6f"]]},{"id":"6b0d29efcbff63ed","type":"debug","z":"f9be3564.a66948","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":870,"y":660,"wires":[]},{"id":"eabf712a8a645ac1","type":"inject","z":"f9be3564.a66948","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"b","payload":"true","payloadType":"bool","x":430,"y":700,"wires":[["ea5fce610a471d6f"]]},{"id":"ac5b0a6b5fab06fc","type":"inject","z":"f9be3564.a66948","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"a","payload":"false","payloadType":"bool","x":430,"y":660,"wires":[["ea5fce610a471d6f"]]},{"id":"fa2f179b8a995b62","type":"inject","z":"f9be3564.a66948","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"b","payload":"false","payloadType":"bool","x":430,"y":740,"wires":[["ea5fce610a471d6f"]]}]

Ah, interesting. I didnt think of using “wait until” like that, but that seems indeed like a good solution with in house nodes. Thanks!

Just checked your test and yes the way this behaves leads to false triggers in my flow.

I just looked at the test gate I build:

[{"id":"5383d88d1d5d530d","type":"BooleanLogic","z":"97aba0f8a5c773f2","name":"","operation":"AND","inputCount":2,"topic":"result","x":700,"y":2320,"wires":[["5df037ee107a7acf"]]},{"id":"4ab270bf3a44ec31","type":"inject","z":"97aba0f8a5c773f2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"result1","payload":"true","payloadType":"bool","x":460,"y":2280,"wires":[["5383d88d1d5d530d"]]},{"id":"7a99739b213a5ac8","type":"inject","z":"97aba0f8a5c773f2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"result2","payload":"true","payloadType":"bool","x":460,"y":2340,"wires":[["5383d88d1d5d530d"]]},{"id":"5df037ee107a7acf","type":"debug","z":"97aba0f8a5c773f2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":950,"y":2320,"wires":[]},{"id":"d9e9a8db05c94356","type":"inject","z":"97aba0f8a5c773f2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"result3","payload":"false","payloadType":"bool","x":470,"y":2400,"wires":[["5383d88d1d5d530d"]]}]

and if you define a different topic for each input, you get an error when 3rd one gets input.
but im noticing now that a “false” would probably have triggered the turn off also, because there is nothing checking the output of the gate if its true or false.

ill guess i have to check out some other gate add ons, should i need that functionality in the future, although that “wait until” thing will probably be applicable in a lot of cases instead of a gate.

thanks for the logic lesson anyway :slight_smile:

1 Like

Kermits flow seems good. The only thing I would add is a timeout on the wait until node and perhaps notify phone if it has taken too long.

Would it not be easier to just put a smart plug with metering on the computer, then you can read the meter to know if the computer use any power.

yes absolutly, and i bought some that have that function, which works in their app but not in HA integration

which brand and model?

KYG smart plugs connecting via the TUYA app

That looks like a Tuya smart plug.
Those can usually be OTA flashed to tasmota and if that is not possible then a flash to tasmota over a rs232 interface mught still be possible.

nice, yeah i have checking on the firmware of some of my cheaper hardware on my smart home to do list. good to know that i can maybe awaken this functionality.