Hello all I hope you are all keeping well in these difficult times.
I am trying to figure out the best way to stop flows from interfering with lights if they have been manually turned on.
I have several lights around the house that are set to activate different scenes when motion is detected, depending on the time of day. This kind of works 'ok' if the light is normally meant to be off, but is problematic if someone has turned the light on and then the sensor is triggered.
Here's a basic 1 light flow:
[
{
"id": "5f7bc884.9e1998",
"type": "tab",
"label": "Example",
"disabled": false,
"info": ""
},
{
"id": "5b214d14.7a35ec",
"type": "server-state-changed",
"z": "5f7bc884.9e1998",
"name": "Front Door",
"server": "91682e0f.5024c",
"version": 1,
"exposeToHomeAssistant": false,
"haConfig": [
{
"property": "name",
"value": ""
},
{
"property": "icon",
"value": ""
}
],
"entityidfilter": "binary_sensor.hue_front_door_motion_sensor_occupancy",
"entityidfiltertype": "exact",
"outputinitially": false,
"state_type": "str",
"haltifstate": "on",
"halt_if_type": "str",
"halt_if_compare": "is",
"outputs": 2,
"output_only_on_state_change": true,
"x": 140,
"y": 200,
"wires": [
[
"84f5787f.e2aef",
"fc291366.29d32"
],
[
"bc0eed3b.2bfd8"
]
]
},
{
"id": "bc0eed3b.2bfd8",
"type": "stoptimer",
"z": "5f7bc884.9e1998",
"duration": "2",
"units": "Minute",
"payloadtype": "num",
"payloadval": "0",
"name": "2 Mins",
"x": 450,
"y": 242,
"wires": [
[
"c68d1691.a53c58"
],
[]
]
},
{
"id": "c68d1691.a53c58",
"type": "api-call-service",
"z": "5f7bc884.9e1998",
"name": "Turn off",
"server": "91682e0f.5024c",
"version": 1,
"debugenabled": false,
"service_domain": "light",
"service": "turn_off",
"entityId": "light.hue_hallway_light",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "payload",
"output_location_type": "msg",
"mustacheAltTags": false,
"x": 600,
"y": 240,
"wires": [
[]
]
},
{
"id": "6de407a3.359968",
"type": "api-call-service",
"z": "5f7bc884.9e1998",
"name": "Turn on",
"server": "91682e0f.5024c",
"version": 1,
"debugenabled": false,
"service_domain": "scene",
"service": "turn_on",
"entityId": "scene.hall_early_hours",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "payload",
"output_location_type": "msg",
"mustacheAltTags": false,
"x": 1000,
"y": 120,
"wires": [
[]
]
},
{
"id": "5d08188b.b193f8",
"type": "api-call-service",
"z": "5f7bc884.9e1998",
"name": "Turn on",
"server": "91682e0f.5024c",
"version": 1,
"debugenabled": false,
"service_domain": "scene",
"service": "turn_on",
"entityId": "scene.hall_dark",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "payload",
"output_location_type": "msg",
"mustacheAltTags": false,
"x": 1060,
"y": 240,
"wires": [
[]
]
},
{
"id": "dce9aad0.6409a8",
"type": "switch",
"z": "5f7bc884.9e1998",
"name": "Is it late?",
"property": "latehours",
"propertyType": "global",
"rules": [
{
"t": "eq",
"v": "true",
"vt": "str"
},
{
"t": "eq",
"v": "false",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 900,
"y": 180,
"wires": [
[
"98252826.1f1a4"
],
[
"5d08188b.b193f8"
]
]
},
{
"id": "fc291366.29d32",
"type": "switch",
"z": "5f7bc884.9e1998",
"name": "Sunset?",
"property": "sunset",
"propertyType": "global",
"rules": [
{
"t": "eq",
"v": "true",
"vt": "str"
},
{
"t": "eq",
"v": "false",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 500,
"y": 160,
"wires": [
[
"da4e784f.9de0f8"
],
[]
]
},
{
"id": "84f5787f.e2aef",
"type": "change",
"z": "5f7bc884.9e1998",
"name": "STOP",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "STOP",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 330,
"y": 202,
"wires": [
[
"bc0eed3b.2bfd8"
]
]
},
{
"id": "da4e784f.9de0f8",
"type": "switch",
"z": "5f7bc884.9e1998",
"name": "Is it early hours?",
"property": "earlyhours",
"propertyType": "global",
"rules": [
{
"t": "eq",
"v": "true",
"vt": "str"
},
{
"t": "eq",
"v": "false",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 700,
"y": 160,
"wires": [
[
"6de407a3.359968"
],
[
"dce9aad0.6409a8"
]
]
},
{
"id": "98252826.1f1a4",
"type": "api-call-service",
"z": "5f7bc884.9e1998",
"name": "Turn on",
"server": "91682e0f.5024c",
"version": 1,
"debugenabled": false,
"service_domain": "scene",
"service": "turn_on",
"entityId": "scene.hall_late",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "payload",
"output_location_type": "msg",
"mustacheAltTags": false,
"x": 1060,
"y": 180,
"wires": [
[]
]
},
{
"id": "91682e0f.5024c",
"type": "server",
"z": "",
"name": "Home Assistant",
"legacy": false,
"addon": true,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": false,
"cacheJson": true
}
]
This turns the hall light on if someone comes through the front door. Problem being, if someone was already in the hall and has manually turned the light on, it:
- Overrides it to the settings of the scene
- Triggers the timer and turns it off
But then I have somehing like this:
[
{
"id": "5f7bc884.9e1998",
"type": "tab",
"label": "Example",
"disabled": false,
"info": ""
},
{
"id": "1892d875.4a4ec",
"type": "server-state-changed",
"z": "5f7bc884.9e1998",
"name": "Stairs",
"server": "91682e0f.5024c",
"version": 1,
"exposeToHomeAssistant": false,
"haConfig": [
{
"property": "name",
"value": ""
},
{
"property": "icon",
"value": ""
}
],
"entityidfilter": "binary_sensor.hue_stairs_motion_sensor_occupancy",
"entityidfiltertype": "exact",
"outputinitially": false,
"state_type": "str",
"haltifstate": "on",
"halt_if_type": "str",
"halt_if_compare": "is",
"outputs": 2,
"output_only_on_state_change": true,
"x": 90,
"y": 200,
"wires": [
[
"4b5a6ed3.23e18",
"2b2150d0.d2a9d8"
],
[
"29e967c8.19fc"
]
]
},
{
"id": "12b1a23d.b2b16e",
"type": "api-call-service",
"z": "5f7bc884.9e1998",
"name": "Turn off",
"server": "91682e0f.5024c",
"version": 1,
"debugenabled": false,
"service_domain": "light",
"service": "turn_off",
"entityId": "light.hue_landing_night_light",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "payload",
"output_location_type": "msg",
"mustacheAltTags": false,
"x": 600,
"y": 320,
"wires": [
[]
]
},
{
"id": "b6c17f58.b30888",
"type": "api-call-service",
"z": "5f7bc884.9e1998",
"name": "Turn on",
"server": "91682e0f.5024c",
"version": 1,
"debugenabled": false,
"service_domain": "scene",
"service": "turn_on",
"entityId": "scene.stairs_early_hours",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "payload",
"output_location_type": "msg",
"mustacheAltTags": false,
"x": 660,
"y": 100,
"wires": [
[]
]
},
{
"id": "2fd3e71.a350198",
"type": "api-call-service",
"z": "5f7bc884.9e1998",
"name": "Turn on",
"server": "91682e0f.5024c",
"version": 1,
"debugenabled": false,
"service_domain": "scene",
"service": "turn_on",
"entityId": "scene.stairs_dark",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "payload",
"output_location_type": "msg",
"mustacheAltTags": false,
"x": 860,
"y": 220,
"wires": [
[]
]
},
{
"id": "96fdab49.3366b",
"type": "switch",
"z": "5f7bc884.9e1998",
"name": "Is it late?",
"property": "latehours",
"propertyType": "global",
"rules": [
{
"t": "eq",
"v": "true",
"vt": "str"
},
{
"t": "eq",
"v": "false",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 660,
"y": 160,
"wires": [
[
"72c5df25.eaffc"
],
[
"2fd3e71.a350198"
]
]
},
{
"id": "4b5a6ed3.23e18",
"type": "switch",
"z": "5f7bc884.9e1998",
"name": "Dark Inside?",
"property": "darkinside",
"propertyType": "global",
"rules": [
{
"t": "eq",
"v": "true",
"vt": "str"
},
{
"t": "eq",
"v": "false",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 290,
"y": 180,
"wires": [
[
"582d420b.b87924"
],
[]
]
},
{
"id": "582d420b.b87924",
"type": "switch",
"z": "5f7bc884.9e1998",
"name": "Is it early hours?",
"property": "earlyhours",
"propertyType": "global",
"rules": [
{
"t": "eq",
"v": "true",
"vt": "str"
},
{
"t": "eq",
"v": "false",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 480,
"y": 140,
"wires": [
[
"b6c17f58.b30888"
],
[
"96fdab49.3366b"
]
]
},
{
"id": "72c5df25.eaffc",
"type": "api-call-service",
"z": "5f7bc884.9e1998",
"name": "Turn on",
"server": "91682e0f.5024c",
"version": 1,
"debugenabled": false,
"service_domain": "scene",
"service": "turn_on",
"entityId": "scene.stairs_late",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "payload",
"output_location_type": "msg",
"mustacheAltTags": false,
"x": 860,
"y": 160,
"wires": [
[]
]
},
{
"id": "db2601f.687578",
"type": "api-call-service",
"z": "5f7bc884.9e1998",
"name": "Turn off",
"server": "91682e0f.5024c",
"version": 1,
"debugenabled": false,
"service_domain": "light",
"service": "turn_off",
"entityId": "light.hue_hall_play_bar",
"data": "",
"dataType": "json",
"mergecontext": "",
"output_location": "payload",
"output_location_type": "msg",
"mustacheAltTags": false,
"x": 600,
"y": 260,
"wires": [
[]
]
},
{
"id": "29e967c8.19fc",
"type": "stoptimer",
"z": "5f7bc884.9e1998",
"duration": "2",
"units": "Minute",
"payloadtype": "num",
"payloadval": "0",
"name": "2 Mins",
"x": 450,
"y": 280,
"wires": [
[
"db2601f.687578"
],
[
"12b1a23d.b2b16e"
]
]
},
{
"id": "2b2150d0.d2a9d8",
"type": "change",
"z": "5f7bc884.9e1998",
"name": "STOP",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "STOP",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 330,
"y": 220,
"wires": [
[
"29e967c8.19fc"
]
]
},
{
"id": "91682e0f.5024c",
"type": "server",
"z": "",
"name": "Home Assistant",
"legacy": false,
"addon": true,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": false,
"cacheJson": true
}
]
This flow triggers a light at the top and bottom of the stairs to cater for movement in both directions but has the same issues as the hall light. We recently added a play bar which is sat on a bookshelf and is now used for ambient lighting in the evenings and is also the light used at the bottom of the stairs. In this case, it would probably be preferable to store the state prior to the scene then recall it.
So my question is: What is the best way to go about this?