I created a subflow which can call light service from state. It can be used to return a light to a previously stored state, or to copy the state of another light.
[
{
"id": "9bfadbfcdf77da5b",
"type": "subflow",
"name": "Light State to Service",
"info": "",
"category": "",
"in": [
{
"x": 60,
"y": 180,
"wires": [
{
"id": "379f1f060be9a2c4"
}
]
}
],
"out": [
{
"x": 1920,
"y": 80,
"wires": [
{
"id": "cab276a503874843",
"port": 1
},
{
"id": "cab276a503874843",
"port": 2
},
{
"id": "ecc723e95492fc83",
"port": 0
}
]
}
],
"env": [
{
"name": "CallService",
"type": "bool",
"value": "true"
}
],
"meta": {},
"color": "#DDAA99"
},
{
"id": "e9de110ba10ae413",
"type": "switch",
"z": "9bfadbfcdf77da5b",
"name": "",
"property": "data.attributes.color_mode",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "color_temp",
"vt": "str"
},
{
"t": "eq",
"v": "xy",
"vt": "str"
},
{
"t": "eq",
"v": "rgb_color",
"vt": "str"
}
],
"checkall": "false",
"repair": false,
"outputs": 3,
"x": 510,
"y": 180,
"wires": [
[
"f1092f7fd95ee70b"
],
[
"249149bd33b574b1"
],
[
"52d779682f10c372"
]
]
},
{
"id": "52d779682f10c372",
"type": "change",
"z": "9bfadbfcdf77da5b",
"name": "",
"rules": [
{
"t": "set",
"p": "payload.data.rgb_color",
"pt": "msg",
"to": "data.attributes.rgb_color",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 750,
"y": 220,
"wires": [
[
"bf3ee3c68431ada2"
]
]
},
{
"id": "f1092f7fd95ee70b",
"type": "change",
"z": "9bfadbfcdf77da5b",
"name": "",
"rules": [
{
"t": "set",
"p": "payload.data.color_temp",
"pt": "msg",
"to": "data.attributes.color_temp",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 760,
"y": 140,
"wires": [
[
"bf3ee3c68431ada2"
]
]
},
{
"id": "bf3ee3c68431ada2",
"type": "change",
"z": "9bfadbfcdf77da5b",
"name": "",
"rules": [
{
"t": "set",
"p": "payload.data.brightness",
"pt": "msg",
"to": "data.attributes.brightness",
"tot": "msg"
},
{
"t": "set",
"p": "payload.domain",
"pt": "msg",
"to": "light",
"tot": "str"
},
{
"t": "set",
"p": "payload.service",
"pt": "msg",
"to": "turn_on",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1020,
"y": 180,
"wires": [
[
"98ccea8132289242"
]
]
},
{
"id": "249149bd33b574b1",
"type": "change",
"z": "9bfadbfcdf77da5b",
"name": "",
"rules": [
{
"t": "set",
"p": "payload.data.xy_color",
"pt": "msg",
"to": "data.attributes.xy_color",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 750,
"y": 180,
"wires": [
[
"bf3ee3c68431ada2"
]
]
},
{
"id": "98ccea8132289242",
"type": "switch",
"z": "9bfadbfcdf77da5b",
"name": "call service env variable?",
"property": "CallService",
"propertyType": "env",
"rules": [
{
"t": "true"
},
{
"t": "false"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 1390,
"y": 120,
"wires": [
[
"ecc723e95492fc83"
],
[
"cab276a503874843"
]
]
},
{
"id": "cab276a503874843",
"type": "switch",
"z": "9bfadbfcdf77da5b",
"name": "call service env variable?",
"property": "callService",
"propertyType": "flow",
"rules": [
{
"t": "empty"
},
{
"t": "false"
},
{
"t": "true"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 1650,
"y": 180,
"wires": [
[
"ecc723e95492fc83"
],
[],
[]
]
},
{
"id": "ecc723e95492fc83",
"type": "api-call-service",
"z": "9bfadbfcdf77da5b",
"name": "Call service",
"server": "63cd03f0f580c143",
"version": 3,
"debugenabled": false,
"service_domain": "",
"service": "",
"entityId": "",
"data": "",
"dataType": "jsonata",
"mergecontext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 1650,
"y": 100,
"wires": [
[]
]
},
{
"id": "e9e2eda0d0b6b9a2",
"type": "switch",
"z": "9bfadbfcdf77da5b",
"name": "",
"property": "data.state",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "on",
"vt": "str"
},
{
"t": "eq",
"v": "off",
"vt": "str"
}
],
"checkall": "false",
"repair": false,
"outputs": 2,
"x": 370,
"y": 180,
"wires": [
[
"e9de110ba10ae413"
],
[
"f03128a1fb71b857"
]
]
},
{
"id": "f03128a1fb71b857",
"type": "change",
"z": "9bfadbfcdf77da5b",
"name": "",
"rules": [
{
"t": "set",
"p": "payload.domain",
"pt": "msg",
"to": "light",
"tot": "str"
},
{
"t": "set",
"p": "payload.service",
"pt": "msg",
"to": "turn_off",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 540,
"y": 300,
"wires": [
[
"98ccea8132289242"
]
]
},
{
"id": "379f1f060be9a2c4",
"type": "change",
"z": "9bfadbfcdf77da5b",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\"data\": {\"entity_id\": msg.data.entity_id},\"domain\": \"light\"}",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 200,
"y": 180,
"wires": [
[
"e9e2eda0d0b6b9a2"
]
]
},
{
"id": "63cd03f0f580c143",
"type": "server",
"name": "Home Assistant",
"version": 1,
"addon": false,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true
}
]