Handler for Tina Desk Scenes

This commit is contained in:
2022-12-22 13:07:45 -05:00
parent 819c634e5e
commit be18131875

View File

@ -597,6 +597,38 @@
],
"icon": "node-red-contrib-huemagic/hue-light.svg"
},
{
"id": "85c4f81ca9628aea",
"type": "subflow",
"name": "Tina Desk Scenes Handler",
"info": "",
"category": "",
"in": [
{
"x": 140,
"y": 340,
"wires": [
{
"id": "d0822c2e7fdff092"
}
]
}
],
"out": [],
"env": [],
"meta": {},
"color": "#DDAA99",
"status": {
"x": 960,
"y": 340,
"wires": [
{
"id": "8ad119b6c6e11ddd",
"port": 0
}
]
}
},
{
"id": "eccca853a916b662",
"type": "group",
@ -1210,9 +1242,7 @@
"528d5448879fd3db"
],
"x": 54,
"y": 19,
"w": 2092,
"h": 282
"y": 19
},
{
"id": "0c81dfaed25d225c",
@ -4743,6 +4773,110 @@
"y": 140,
"wires": []
},
{
"id": "655050669e5ccf85",
"type": "api-call-service",
"z": "85c4f81ca9628aea",
"name": "Set Scene",
"server": "9e87348d.9c1c48",
"version": 5,
"debugenabled": false,
"domain": "scene",
"service": "turn_on",
"areaId": [],
"deviceId": [],
"entityId": [
"scene.{{payload}}_in_{{topic}}"
],
"data": "",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 670,
"y": 340,
"wires": [
[
"8ad119b6c6e11ddd"
]
]
},
{
"id": "8ad119b6c6e11ddd",
"type": "function",
"z": "85c4f81ca9628aea",
"name": "Format",
"func": "const str = msg.payload\nvar scene = str.replaceAll(\"_\",\" \")\n\nmsg.dest = msg.topic\n\nmsg.topic = \"Lights Changed\"\nmsg.payload = ('Lights changed to a new scene: ' + scene)\n\nif (msg.payload === 'Lights changed to a new scene: Reset') {\n return null;\n} else {\n return msg;\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 840,
"y": 340,
"wires": [
[]
]
},
{
"id": "78a73c2d816658d8",
"type": "subflow:582b8363c9f33bf8",
"z": "85c4f81ca9628aea",
"name": "",
"x": 710,
"y": 420,
"wires": []
},
{
"id": "493106346f58ba03",
"type": "switch",
"z": "85c4f81ca9628aea",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "Select",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 470,
"y": 340,
"wires": [
[],
[
"78a73c2d816658d8",
"655050669e5ccf85"
]
]
},
{
"id": "d0822c2e7fdff092",
"type": "function",
"z": "85c4f81ca9628aea",
"name": "Remove Spaces",
"func": "var str = msg.payload\nmsg.payload = str.replaceAll(\" \",\"_\")\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 300,
"y": 340,
"wires": [
[
"493106346f58ba03"
]
]
},
{
"id": "cc8645ebae721601",
"type": "api-current-state",
@ -7622,7 +7756,9 @@
"x": 1590,
"y": 360,
"wires": [
[]
[
"fc85ca4a4c57b5bf"
]
]
},
{
@ -8420,6 +8556,33 @@
[]
]
},
{
"id": "fc85ca4a4c57b5bf",
"type": "api-call-service",
"z": "e44b1e7a8ef7ae1d",
"name": "Reset Scene Text",
"server": "9e87348d.9c1c48",
"version": 5,
"debugenabled": false,
"domain": "input_text",
"service": "set_value",
"areaId": [],
"deviceId": [],
"entityId": [
"input_text.tina_desk_selected_scene"
],
"data": "{\t \"value\":\"Day Mode\"\t}",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 1810,
"y": 360,
"wires": [
[]
]
},
{
"id": "134433d6e21dab5b",
"type": "server-state-changed",
@ -9077,7 +9240,8 @@
"y": 340,
"wires": [
[
"9ae7e308f889137d"
"9ae7e308f889137d",
"d97b9088ab92e31d"
],
[]
]
@ -9632,6 +9796,101 @@
[]
]
},
{
"id": "ddf5b7633f597aef",
"type": "api-call-service",
"z": "3abb5ae57afb4761",
"name": "Night Mode",
"server": "9e87348d.9c1c48",
"version": 5,
"debugenabled": false,
"domain": "input_select",
"service": "select_option",
"areaId": [],
"deviceId": [],
"entityId": [
"input_select.tina_desk_scenes"
],
"data": "{\t \"option\":\"Night Mode\"\t}",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 1310,
"y": 240,
"wires": [
[]
]
},
{
"id": "d97b9088ab92e31d",
"type": "api-current-state",
"z": "3abb5ae57afb4761",
"name": "Early Night Mode?",
"server": "9e87348d.9c1c48",
"version": 3,
"outputs": 2,
"halt_if": "on",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "input_boolean.early_night_mode",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 1110,
"y": 280,
"wires": [
[
"ddf5b7633f597aef"
],
[
"b8e7db3f58ef8d8d"
]
]
},
{
"id": "b8e7db3f58ef8d8d",
"type": "api-call-service",
"z": "3abb5ae57afb4761",
"name": "Day Mode",
"server": "9e87348d.9c1c48",
"version": 5,
"debugenabled": false,
"domain": "input_select",
"service": "select_option",
"areaId": [],
"deviceId": [],
"entityId": [
"input_select.tina_desk_scenes"
],
"data": "{\t \"option\":\"Day Mode\"\t}",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 1310,
"y": 300,
"wires": [
[]
]
},
{
"id": "d95d9964546768a5",
"type": "server-state-changed",
@ -9973,7 +10232,7 @@
}
],
"x": 100,
"y": 420,
"y": 620,
"wires": [
[
"dfac5d681cf62083"
@ -10001,7 +10260,7 @@
"to": "",
"reg": false,
"x": 290,
"y": 480,
"y": 680,
"wires": [
[
"dfac5d681cf62083"
@ -10018,7 +10277,7 @@
"payloadval": "0",
"name": "",
"x": 500,
"y": 420,
"y": 620,
"wires": [
[
"5123a607588fa737"
@ -10050,7 +10309,7 @@
"output_location": "",
"output_location_type": "none",
"x": 690,
"y": 420,
"y": 620,
"wires": [
[]
]
@ -10111,7 +10370,7 @@
}
],
"x": 100,
"y": 480,
"y": 680,
"wires": [
[
"6755b1d81f7356ad"
@ -10126,7 +10385,7 @@
"name": "Downstairs Bathroom",
"info": "",
"x": 300,
"y": 420,
"y": 620,
"wires": []
},
{
@ -10245,7 +10504,7 @@
}
],
"x": 100,
"y": 540,
"y": 740,
"wires": [
[
"f0ef9a565f72dcae"
@ -10275,7 +10534,7 @@
"outputProperties": [],
"queue": "none",
"x": 530,
"y": 540,
"y": 740,
"wires": [
[]
]
@ -10311,7 +10570,7 @@
"entity_location": "data",
"override_data": "msg",
"x": 310,
"y": 540,
"y": 740,
"wires": [
[
"5e7a082800eeb73c"
@ -10319,6 +10578,78 @@
[]
]
},
{
"id": "5a81041c4a1390b8",
"type": "server-state-changed",
"z": "eff21041cc941fef",
"name": "Tina Desk Scenes",
"server": "9e87348d.9c1c48",
"version": 4,
"exposeToHomeAssistant": false,
"haConfig": [
{
"property": "name",
"value": ""
},
{
"property": "icon",
"value": ""
}
],
"entityidfilter": "input_select.tina_desk_scenes",
"entityidfiltertype": "exact",
"outputinitially": false,
"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": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "topic",
"propertyType": "msg",
"value": "tina_desk",
"valueType": "str"
},
{
"property": "include",
"propertyType": "msg",
"value": "dining_room",
"valueType": "str"
}
],
"x": 110,
"y": 400,
"wires": [
[
"b19f4a996fd4c2ee"
]
]
},
{
"id": "b19f4a996fd4c2ee",
"type": "subflow:85c4f81ca9628aea",
"z": "eff21041cc941fef",
"name": "",
"x": 590,
"y": 400,
"wires": []
},
{
"id": "879ee8903841b8f0",
"type": "server-state-changed",