I’m mostly new to Node-Red (but I did stay at a Holiday Inn Express last night), but managing to pick up bits and pieces each time I try a new automation with it! So, there’s hope for me!
Background: I have a couple of 3d printers in my workshop. I also have a couple of Zigbee lights overhead that turn on with motion in the workshop. I’m trying to keep the lights on while any of the printers is printing since only one of the printers has an IR capable camera on it.
So, I’ve created a test flow in NR (using the first 2 printers to simplify the logic, and adding the 3rd one in later) that takes input from the MQTT/HA integration in Octoprint. I have the following flow, so far:
[{"id":"bfb0b07dd6dfa394","type":"tab","label":"3D Printers","disabled":false,"info":"","env":[]},{"id":"29e9942ff8311ff3","type":"mqtt in","z":"bfb0b07dd6dfa394","name":"","topic":"drevil/hass/is_printing","qos":"2","datatype":"auto-detect","broker":"8e73d9db192d604b","nl":false,"rap":true,"rh":0,"inputs":0,"x":160,"y":320,"wires":[["d3dad7929cfc4312"]]},{"id":"e6aadefea1af51ad","type":"mqtt in","z":"bfb0b07dd6dfa394","name":"","topic":"minime/hass/is_printing","qos":"2","datatype":"auto-detect","broker":"8e73d9db192d604b","nl":false,"rap":true,"rh":0,"inputs":0,"x":160,"y":420,"wires":[["d3dad7929cfc4312"]]},{"id":"78d6794c8939841e","type":"api-call-service","z":"bfb0b07dd6dfa394","name":"","server":"a3c613d7.a1f6","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.craft_room_fan_lights"],"data":"{\"brightness\":255}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":910,"y":320,"wires":[[]]},{"id":"d3dad7929cfc4312","type":"BooleanLogic","z":"bfb0b07dd6dfa394","name":"","operation":"OR","inputCount":2,"topic":"result","x":450,"y":320,"wires":[["78d6794c8939841e","5cdfd82f7821bb57"]]},{"id":"5cdfd82f7821bb57","type":"Invert","z":"bfb0b07dd6dfa394","name":"Invert","x":670,"y":420,"wires":[["cfed703b2a989f57"]]},{"id":"cfed703b2a989f57","type":"api-call-service","z":"bfb0b07dd6dfa394","name":"","server":"a3c613d7.a1f6","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.craft_room_fan_lights"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":910,"y":420,"wires":[[]]},{"id":"8e73d9db192d604b","type":"mqtt-broker","name":"","broker":"localhost","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"a3c613d7.a1f6","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"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"}]
But, I’m running into an annoying issue and I can’t figure out if I’m simply doing something wrong or not. The lights DO turn on when either of the two printers start printing, but, the lights immediately turn right back off regardless of the printer state (even if the MQTT topic still shows either printer “is_printing=True” state. Am I simply doing something wrong or taking the wrong approach?
TLDR: I want the lights to come on (if not already) and remain on while any of the 3D printers are on and in a state of “is_printing=true” in MQTT.