# Switch

Part of the entity node.

# Use cases

  • Start a flow using the service call nodered.trigger. This can be used in any place that you can do a service call (e.g. Node-RED, Lovelace). When a switch is triggered the output path will depend on if the HA switch is on (top) or off (bottom).

  • As a switch node where the condition is if the HA switch is on/off.

Sample Flow using the new switch entity:

Screenshot of Example

[{"id":"b1ddb7a.6547548","type":"inject","z":"56b1c979.b2c618","name":"Toggle Switch","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":182,"y":224,"wires":[["dfb609e7.8f9f38"]]},{"id":"dfb609e7.8f9f38","type":"api-call-service","z":"56b1c979.b2c618","name":"Toggle Switch On/Off","version":1,"debugenabled":false,"service_domain":"switch","service":"toggle","entityId":"switch.nodered_entity_switch","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":388,"y":224,"wires":[[]]},{"id":"ae4f1ef6.1afcf","type":"inject","z":"56b1c979.b2c618","name":"Trigger Switch","topic":"","payload":"{\"data\": {\"entity_id\": \"switch.nodered_entity_switch\"}}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":182,"y":272,"wires":[["9d8bb1d9.47b08"]]},{"id":"9d8bb1d9.47b08","type":"api-call-service","z":"56b1c979.b2c618","name":"nodered.trigger switch no payload","version":1,"debugenabled":false,"service_domain":"nodered","service":"trigger","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":428,"y":272,"wires":[["cdf62164.236c7"]]},{"id":"52ad42c3.813b0c","type":"ha-entity","z":"56b1c979.b2c618","name":"","server":"9c202bd8.b64db8","version":1,"debugenabled":false,"outputs":2,"entityType":"switch","config":[{"property":"name","value":"nodered_entity_switch"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:airplane"},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":358,"y":160,"wires":[["cd9b188.f1707e8"],["441482ca.d5a8dc"]]},{"id":"cd9b188.f1707e8","type":"debug","z":"56b1c979.b2c618","name":"on","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":514,"y":144,"wires":[]},{"id":"6ef82461.aaf80c","type":"inject","z":"56b1c979.b2c618","name":"Input to Switch","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":192,"y":160,"wires":[["52ad42c3.813b0c"]]},{"id":"441482ca.d5a8dc","type":"debug","z":"56b1c979.b2c618","name":"off","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":514,"y":176,"wires":[]},{"id":"cdf62164.236c7","type":"api-call-service","z":"56b1c979.b2c618","name":"nodered.trigger switch object payload","version":1,"debugenabled":false,"service_domain":"nodered","service":"trigger","entityId":"","data":"{\"payload\": {\"abc\": 123}}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":438,"y":320,"wires":[["ab5d1645.d48538"]]},{"id":"ab5d1645.d48538","type":"api-call-service","z":"56b1c979.b2c618","name":"nodered.trigger switch string payload","version":1,"debugenabled":false,"service_domain":"nodered","service":"trigger","entityId":"","data":"{\"payload\": \"abc\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":438,"y":368,"wires":[["24987085.42514"]]},{"id":"24987085.42514","type":"api-call-service","z":"56b1c979.b2c618","name":"nodered.trigger switch boolean payload","version":1,"debugenabled":false,"service_domain":"nodered","service":"trigger","entityId":"","data":"{\"payload\": true }","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":448,"y":416,"wires":[["beb6e063.28cbb"]]},{"id":"beb6e063.28cbb","type":"api-call-service","z":"56b1c979.b2c618","name":"nodered.trigger switch number payload","version":1,"debugenabled":false,"service_domain":"nodered","service":"trigger","entityId":"","data":"{\"payload\": 123 }","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":438,"y":464,"wires":[[]]}]