Automatic Humidity Light

Automatically turn on a light and change color based on high (red), medium (green), and low (blue) humidity - using Home Assistant and Node-RED.

Requirements

Node-RED

[{"id":"3de80ebe.75388a","type":"server-state-changed","z":"9afdaf1d.9b88f","name":"Humidity","server":"a77b5e9d.0c69","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.bathroom_humidity","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"num","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":80,"y":460,"wires":[["3649abb3.175f2c"]]},{"id":"3649abb3.175f2c","type":"switch","z":"9afdaf1d.9b88f","name":"State","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"70","vt":"str"},{"t":"gt","v":"40","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":230,"y":460,"wires":[["2c273f27.525a8"],["f78863cb.8aed2"],["f82257f5.0a516"]]},{"id":"f78863cb.8aed2","type":"api-call-service","z":"9afdaf1d.9b88f","name":"Turn on light and set color to green","server":"a77b5e9d.0c69","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.living_room_lamp","data":"{\"color_name\":\"green\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":480,"y":460,"wires":[[]]},{"id":"2c273f27.525a8","type":"api-call-service","z":"9afdaf1d.9b88f","name":"Turn on light and set color to red","server":"a77b5e9d.0c69","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.living_room_lamp","data":"{\"color_name\":\"red\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":480,"y":400,"wires":[[]]},{"id":"f82257f5.0a516","type":"api-call-service","z":"9afdaf1d.9b88f","name":"Turn on light and set color to blue","server":"a77b5e9d.0c69","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.living_room_lamp","data":"{\"color_name\":\"blue\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":480,"y":520,"wires":[[]]},{"id":"a77b5e9d.0c69","type":"server","z":"","name":"Home Assistant","addon":true}]
Node-RED Flow

Copy the above, import into Node-RED, configure the nodes, and deploy the workflow.