Motion Sensing GE Switch

Hi Guys,

I have a Node-Red automation for my kids bathroom. Here is how I want it to work:

  • Motion Detected in Bathroom
  • If daytime set brightness to 100%, if nighttime set brightness to 30%

The problem here is that when I click the button off, it detects motion and immediately turns back on.

So I need to do something else to prevent this.

Here is my current Automation: https://imgur.com/yqsQqW5

Please Advise!

I am currently using the following node-red palette:

  • 0.9.1 node-red-contrib-home-assistant-websocket

To add on, is there a way to detect a button CLICK on the switch or do I have to just use “level” 0 for down click?

You can use a trigger-state node for the motion sensor then disable/enable when the light switch if turned off.

[{"id":"173ca0f4.2c6d6f","type":"time-range-switch","z":"dd188fa8.9006c","name":"After 7:30","lat":"","lon":"","startTime":"07:28","endTime":"goldenHour","startOffset":0,"endOffset":0,"x":780,"y":912,"wires":[["18f7b4bc.1b6b8b"],["85146787.369858"]]},{"id":"74361f2a.7ef9c","type":"api-current-state","z":"dd188fa8.9006c","name":"Light off?","server":"2dad33ee.42bf5c","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is_not","override_topic":false,"entity_id":"light.light","state_type":"str","state_location":"","override_payload":"none","entity_location":"","override_data":"none","x":1148,"y":912,"wires":[["8a041658.31fda8"],[]]},{"id":"18f7b4bc.1b6b8b","type":"change","z":"dd188fa8.9006c","name":"30% Brightness","rules":[{"t":"set","p":"brightness","pt":"msg","to":"30","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":944,"y":864,"wires":[["74361f2a.7ef9c"]]},{"id":"85146787.369858","type":"change","z":"dd188fa8.9006c","name":"100% Brightness","rules":[{"t":"set","p":"brightness","pt":"msg","to":"100","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":954,"y":912,"wires":[["74361f2a.7ef9c"]]},{"id":"8a041658.31fda8","type":"api-call-service","z":"dd188fa8.9006c","name":"ON","server":"2dad33ee.42bf5c","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"light.light\",\"brightness_pct\":\"{{brightness}}\"}","mergecontext":"","output_location":"","output_location_type":"none","x":1282,"y":912,"wires":[[]]},{"id":"a2f28b35.942648","type":"trigger-state","z":"dd188fa8.9006c","name":"Girls Bathroom Motion","server":"2dad33ee.42bf5c","entityid":"sensor.motion","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"o9loc33ehm","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":596,"y":912,"wires":[["173ca0f4.2c6d6f"],[]]},{"id":"30789563.15390a","type":"server-state-changed","z":"dd188fa8.9006c","name":"Light turned off","server":"2dad33ee.42bf5c","entityidfilter":"light.light","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"off","halt_if_type":"str","halt_if_compare":"is_not","outputs":2,"output_only_on_state_change":true,"x":112,"y":912,"wires":[["74e09e3e.4f319","5765ca2.e965634"],[]]},{"id":"74e09e3e.4f319","type":"change","z":"dd188fa8.9006c","name":"disable","rules":[{"t":"set","p":"payload","pt":"msg","to":"disable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":284,"y":912,"wires":[["a2f28b35.942648"]]},{"id":"d20821cd.f5ac","type":"change","z":"dd188fa8.9006c","name":"enable","rules":[{"t":"set","p":"payload","pt":"msg","to":"enable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":418,"y":960,"wires":[["a2f28b35.942648"]]},{"id":"5765ca2.e965634","type":"delay","z":"dd188fa8.9006c","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":284,"y":960,"wires":[["d20821cd.f5ac"]]}]

Can you help me with the first component: Event State “Light Turned off”.

I am not sure how this works. But it sounds like it’s saying “If Entity light.light is off then…”

How is this detecting if the light is clicked off? Wouldnt this just run all the time the light is off?

It runs when the state is modified in Home Assistant and only triggers when the state changes from one state to another.

This totally fixed it. Thanks for being so clever.

Kermit,

So for some reason it doesnt appear that this is working anymore. I am not sure why but my kids go in the bathroom at night and it goes to 100% brightness…

Screenshot here

[{"id":"68d44ab5.e3cf54","type":"time-range-switch","z":"cd77f58e.b1cd48","name":"After 7:30","lat":"","lon":"","startTime":"19:30","endTime":"06:30","startOffset":0,"endOffset":0,"x":785,"y":163,"wires":[["2e3a0704.e3f5c8"],["26c73199.0dd7de"]]},{"id":"c4e70c76.ed53b","type":"api-current-state","z":"cd77f58e.b1cd48","name":"Light off?","server":"c01fd5bd.55d1e8","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is_not","override_topic":false,"entity_id":"light.girls_bathroom_level","state_type":"str","state_location":"","override_payload":"none","entity_location":"","override_data":"none","x":1153,"y":163,"wires":[["3544767c.3d44aa"],[]]},{"id":"2e3a0704.e3f5c8","type":"change","z":"cd77f58e.b1cd48","name":"50% Brightness","rules":[{"t":"set","p":"brightness","pt":"msg","to":"50","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":949,"y":115,"wires":[["c4e70c76.ed53b"]]},{"id":"26c73199.0dd7de","type":"change","z":"cd77f58e.b1cd48","name":"100% Brightness","rules":[{"t":"set","p":"brightness","pt":"msg","to":"100","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":959,"y":163,"wires":[["c4e70c76.ed53b"]]},{"id":"3544767c.3d44aa","type":"api-call-service","z":"cd77f58e.b1cd48","name":"ON","server":"c01fd5bd.55d1e8","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"light.girls_bathroom_level\",\"brightness_pct\":\"{{brightness}}\"}","mergecontext":"","output_location":"","output_location_type":"none","x":1287,"y":163,"wires":[[]]},{"id":"1a030013.e6997","type":"trigger-state","z":"cd77f58e.b1cd48","name":"Girls Bathroom Motion","server":"c01fd5bd.55d1e8","entityid":"sensor.girls_bathroom_burglar","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"o9loc33ehm","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":601,"y":163,"wires":[["68d44ab5.e3cf54"],[]]},{"id":"36f63834.2bbdb8","type":"server-state-changed","z":"cd77f58e.b1cd48","name":"Light turned off","server":"c01fd5bd.55d1e8","entityidfilter":"light.girls_bathroom_level","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"off","halt_if_type":"str","halt_if_compare":"is_not","outputs":2,"output_only_on_state_change":true,"x":117,"y":163,"wires":[["8c3e2b42.09cbf8","3136face.6a8a06"],[]]},{"id":"8c3e2b42.09cbf8","type":"change","z":"cd77f58e.b1cd48","name":"disable","rules":[{"t":"set","p":"payload","pt":"msg","to":"disable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":289,"y":163,"wires":[["1a030013.e6997"]]},{"id":"dbc51ac2.3ee4c8","type":"change","z":"cd77f58e.b1cd48","name":"enable","rules":[{"t":"set","p":"payload","pt":"msg","to":"enable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":423,"y":211,"wires":[["1a030013.e6997"]]},{"id":"3136face.6a8a06","type":"delay","z":"cd77f58e.b1cd48","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":289,"y":211,"wires":[["dbc51ac2.3ee4c8"]]},{"id":"c01fd5bd.55d1e8","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]

I’ve had success creating variables (https://github.com/rogro82/hass-variables) and then referencing the variable in automations / scripts / etc. in order to populate the values. Sometimes this method simplifies things and allows me to reference a single ‘custom variable’ from multiple scripts/flows/automations vs. having to customize each. Just my $.02 :slight_smile:

Are you using the Cync Wifi motion sensing switch? If so how did you get it to integration with Home Assistant?