WARNING

Needs Custom Integrationopen in new window installed in Home Assistant for this node to function

Switch

Creates a switch in Home Assistant which can be manipulated from this node.

Configuration

Enable input

Input is disabled by default. It can be enabled by checking this option.

Output on state change

  • Type: boolean

When the state of the switch changes it will output to the top if the switch is on or to the bottom if it is in the off position.

Inputs

msg.enable

  • Type: boolean

Set to true to turn on the switch and false to turn it off. If the message has a property enable defined and set to a boolean the node will not have any output.

Outputs

Status Color

  • Green/Red: output from the node was due to input to the node
  • Blue: output from the node was due to the state of the node changing
  • Yellow: state of node changed but no output

Examples

Usage example

screenshot

[{"id":"fab7baeb7be8c516","type":"debug","z":"c84b6e0a642a4bce","name":"on b","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":434,"y":1072,"wires":[]},{"id":"85438e0d960024f9","type":"api-call-service","z":"c84b6e0a642a4bce","name":"","server":"","version":5,"debugenabled":false,"domain":"nodered","service":"trigger","areaId":[],"deviceId":[],"entityId":["switch.switch_test"],"data":"{\"payload\": \"i am the payload\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":320,"y":1216,"wires":[[]]},{"id":"026d576cab2ba685","type":"inject","z":"c84b6e0a642a4bce","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":132,"y":1216,"wires":[["85438e0d960024f9"]]},{"id":"ecc4cf9f7bed0a46","type":"debug","z":"c84b6e0a642a4bce","name":"off b","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":434,"y":1120,"wires":[]},{"id":"489165f36ed911cf","type":"api-call-service","z":"c84b6e0a642a4bce","name":"","server":"","version":5,"debugenabled":false,"domain":"switch","service":"toggle","areaId":[],"deviceId":[],"entityId":["switch.switch_test"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":326,"y":832,"wires":[[]]},{"id":"7e026638397d33b7","type":"inject","z":"c84b6e0a642a4bce","name":"toggle switch state","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":832,"wires":[["489165f36ed911cf"]]},{"id":"aa7e8ed024dab3c8","type":"server-state-changed","z":"c84b6e0a642a4bce","name":"","server":"","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.switch_test","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[],"x":204,"y":784,"wires":[[]]},{"id":"657d91f04b24f723","type":"inject","z":"c84b6e0a642a4bce","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":132,"y":1120,"wires":[["b85c010f7e098b73"]]},{"id":"baac3eb05828d07e","type":"inject","z":"c84b6e0a642a4bce","name":"enable","props":[{"p":"enable","v":"true","vt":"bool"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":126,"y":1024,"wires":[["b85c010f7e098b73"]]},{"id":"051cdb052c6f99db","type":"inject","z":"c84b6e0a642a4bce","name":"disable","props":[{"p":"enable","v":"false","vt":"bool"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":126,"y":1072,"wires":[["b85c010f7e098b73"]]},{"id":"b85c010f7e098b73","type":"ha-switch","z":"c84b6e0a642a4bce","name":"","version":0,"debugenabled":false,"inputs":1,"outputs":2,"entityConfig":"9236992af61f2695","enableInput":true,"outputOnStateChange":false,"outputProperties":[{"property":"topic","propertyType":"msg","value":"state change","valueType":"str"},{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"$entity()","valueType":"jsonata"}],"x":294,"y":1072,"wires":[["fab7baeb7be8c516"],["ecc4cf9f7bed0a46"]]},{"id":"6c90e6c00caee078","type":"debug","z":"c84b6e0a642a4bce","name":"on a","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":434,"y":928,"wires":[]},{"id":"b57fa2a7ad97b2eb","type":"debug","z":"c84b6e0a642a4bce","name":"off a","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":434,"y":976,"wires":[]},{"id":"238e849949f437e6","type":"inject","z":"c84b6e0a642a4bce","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":132,"y":976,"wires":[["a6736ba07743d64e"]]},{"id":"74d43743ff8f07b3","type":"inject","z":"c84b6e0a642a4bce","name":"enable","props":[{"p":"enable","v":"true","vt":"bool"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":118,"y":880,"wires":[["a6736ba07743d64e"]]},{"id":"d1d4b53d44caeb92","type":"inject","z":"c84b6e0a642a4bce","name":"disable","props":[{"p":"enable","v":"false","vt":"bool"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":122,"y":928,"wires":[["a6736ba07743d64e"]]},{"id":"a6736ba07743d64e","type":"ha-switch","z":"c84b6e0a642a4bce","name":"","version":0,"debugenabled":false,"inputs":1,"outputs":2,"entityConfig":"9236992af61f2695","enableInput":true,"outputOnStateChange":true,"outputProperties":[{"property":"topic","propertyType":"msg","value":"state change","valueType":"str"},{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"state","propertyType":"msg","value":"$entity().state = true ? \"on\" : \"off\"","valueType":"jsonata"}],"x":294,"y":928,"wires":[["6c90e6c00caee078"],["b57fa2a7ad97b2eb"]]},{"id":"1f28cd07093de4bf","type":"comment","z":"c84b6e0a642a4bce","name":"outputs on state change","info":"","x":344,"y":880,"wires":[]},{"id":"bc15274098491edc","type":"comment","z":"c84b6e0a642a4bce","name":"does not output on state change","info":"","x":374,"y":1024,"wires":[]},{"id":"7d848a75391906d1","type":"comment","z":"c84b6e0a642a4bce","name":"use nodered.trigger service","info":"","x":350,"y":1168,"wires":[]},{"id":"9236992af61f2695","type":"ha-entity-config","server":"e120e5718cc68a9a","deviceConfig":"_ADD_","name":"switch test","version":"6","entityType":"switch","haConfig":[{"property":"name","value":"switch test"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":"switch"}],"resend":false}]