Home Assistant Community

NodeRed multi if commands

#1

am kinda fresh into red node world so i having kinda big problem setting am automation :smiley:

i want to make automation that if atlest if one of my pc is on my ac will kick on

and then no pc are active my ac will switch off

#2

[{"id":"863545c6.37b4c8","type":"trigger-state","z":"ffbd7f06.4a014","name":"","server":"2dad33ee.42bf5c","entityid":"sensor.pc,sensor.vmware,sensor.testing","entityidfiltertype":"substring","debugenabled":false,"constraints":[{"id":"bywgy2rvx3e","targetType":"entity_id","targetValue":"sensor.pc","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off"},{"id":"hip4q3vt78f","targetType":"entity_id","targetValue":"sensor.vmware","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off"},{"id":"w1396n23y3e","targetType":"entity_id","targetValue":"sensor.testing","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":248,"y":416,"wires":[["6a6a7ef4.54d56"],["a07ac454.0aca78"]]},{"id":"6a6a7ef4.54d56","type":"api-call-service","z":"ffbd7f06.4a014","name":"","server":"2dad33ee.42bf5c","service_domain":"switch","service":"turn_off","data":"{\"entity_id\":\"switch.ac\"}","mergecontext":"","output_location":"","output_location_type":"none","x":714,"y":416,"wires":[[]]},{"id":"a07ac454.0aca78","type":"change","z":"ffbd7f06.4a014","name":"turn_on","rules":[{"t":"set","p":"payloa","pt":"msg","to":"{\"data\": {\"service\": \"turn_on\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":524,"y":448,"wires":[["6a6a7ef4.54d56"]]}]
1 Like
#3

Thanks, btw how can i add this code directly into node red or i can’t :?

#4

Copy the JSON string and then within node-red click on the hamburger icon in the upper right corner then select Import > Clipboard and paste the copied JSON string into it.

2 Likes
#5

Thanks for help ^^