Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Node Red - Light Bulb Flow
[
{
"id": "7fff3c3f.6ec034",
"type": "server-state-changed",
"z": "be5d7e99.087c9",
"name": "Light",
"server": "2ef1a1b8.4b157e",
"version": 1,
"exposeToHomeAssistant": false,
"haConfig": [
{
"property": "name",
"value": ""
},
{
"property": "icon",
"value": ""
}
],
"entityidfilter": "light.",
"entityidfiltertype": "substring",
"outputinitially": false,
"state_type": "str",
"haltifstate": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"outputs": 1,
"output_only_on_state_change": false,
"x": 450,
"y": 1640,
"wires": [
[
"2575373d.692778",
"5e9562c9.8661dc"
]
]
},
{
"id": "2575373d.692778",
"type": "switch",
"z": "be5d7e99.087c9",
"name": "Bulb",
"property": "data.new_state.attributes.is_sync_bulb",
"propertyType": "msg",
"rules": [
{
"t": "true"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 570,
"y": 1640,
"wires": [
[
"587c8d49.98bb24"
]
],
"icon": "font-awesome/fa-exchange"
},
{
"id": "587c8d49.98bb24",
"type": "function",
"z": "be5d7e99.087c9",
"name": "Sync Entities",
"func": "let attrs = msg.data.new_state.attributes;\nlet payload = msg.payload;\n\nif(attrs.hasOwnProperty(\"sync_entities\")) {\n msg.payload = attrs.sync_entities;\n msg.original_payload = payload;\n return msg;\n}",
"outputs": 1,
"noerr": 0,
"x": 710,
"y": 1640,
"wires": [
[
"5a8eb054.60fcd"
]
],
"outputLabels": [
"Not Manual"
],
"icon": "font-awesome/fa-question-circle"
},
{
"id": "5a8eb054.60fcd",
"type": "split",
"z": "be5d7e99.087c9",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 850,
"y": 1640,
"wires": [
[
"5c130d08.7d94f4"
]
]
},
{
"id": "8e14edc5.7b031",
"type": "switch",
"z": "be5d7e99.087c9",
"name": "On/Off",
"property": "original_payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "on",
"vt": "str"
},
{
"t": "eq",
"v": "off",
"vt": "str"
}
],
"checkall": "false",
"repair": false,
"outputs": 2,
"x": 1110,
"y": 1640,
"wires": [
[
"10ab9d89.52a942"
],
[
"de22d1c5.9658"
]
],
"outputLabels": [
"On",
"Off"
],
"icon": "font-awesome/fa-question-circle"
},
{
"id": "10ab9d89.52a942",
"type": "function",
"z": "be5d7e99.087c9",
"name": "Manual",
"func": "let attrs = msg.payload.attributes;\nlet hasManual = attrs.hasOwnProperty(\"manual_state\");\n\nif(!hasManual || hasManual && attrs.manual_state == \"STOP\") {\n return msg;\n}",
"outputs": 1,
"noerr": 0,
"x": 1261,
"y": 1596,
"wires": [
[
"2c336f65.ec6d7"
]
],
"outputLabels": [
"Not Manual"
],
"icon": "font-awesome/fa-exclamation-triangle"
},
{
"id": "2c336f65.ec6d7",
"type": "api-call-service",
"z": "be5d7e99.087c9",
"name": "Dimmer On",
"server": "2ef1a1b8.4b157e",
"version": 1,
"debugenabled": false,
"service_domain": "light",
"service": "turn_on",
"entityId": "{{payload.entity_id}}",
"data": "{ \"brightness\": {{data.new_state.attributes.brightness}} }",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 1411,
"y": 1596,
"wires": [
[]
],
"icon": "font-awesome/fa-toggle-on"
},
{
"id": "de22d1c5.9658",
"type": "api-call-service",
"z": "be5d7e99.087c9",
"name": "Dimmer Off",
"server": "2ef1a1b8.4b157e",
"version": 1,
"debugenabled": false,
"service_domain": "light",
"service": "turn_off",
"entityId": "{{payload.entity_id}}",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "",
"output_location_type": "none",
"mustacheAltTags": false,
"x": 1412,
"y": 1647,
"wires": [
[]
],
"icon": "font-awesome/fa-toggle-off"
},
{
"id": "5c130d08.7d94f4",
"type": "ha-get-entities",
"z": "be5d7e99.087c9",
"server": "2ef1a1b8.4b157e",
"name": "Dimmer",
"rules": [
{
"property": "entity_id",
"logic": "is",
"value": "payload",
"valueType": "msg"
}
],
"output_type": "split",
"output_empty_results": false,
"output_location_type": "msg",
"output_location": "dimmers",
"output_results_count": 1,
"x": 980,
"y": 1640,
"wires": [
[
"8e14edc5.7b031",
"a8ad8411.6b5728"
]
],
"icon": "font-awesome/fa-search"
},
{
"id": "a8ad8411.6b5728",
"type": "debug",
"z": "be5d7e99.087c9",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1190,
"y": 1740,
"wires": []
},
{
"id": "5e9562c9.8661dc",
"type": "debug",
"z": "be5d7e99.087c9",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 610,
"y": 1740,
"wires": []
},
{
"id": "2ef1a1b8.4b157e",
"type": "server",
"z": "",
"name": "Rounds House",
"legacy": false,
"addon": false,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment