I had a flow which the community help me get going - the post is here:
It’s now stopped working after some of the sensors were removed. I’ve stripped it back to two sensors but i still get an error in the debugs; i cant trigger it at the moment but i think it was ‘entity ID can’t be empty’ or something very similar.
Hopefully i’ve managed to paste the current code below, can anyone give me a pointer?
[
{
"id": "fbaea1aaab14874b",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "7c20d6964e467237",
"type": "server-state-changed",
"z": "fbaea1aaab14874b",
"name": "sensors",
"server": "80ed050d.56b658",
"version": 5,
"outputs": 2,
"exposeAsEntityConfig": "",
"entityId": [
"binary_sensor.7wr_kitchen_doors_motion",
"binary_sensor.7wr_rear_doorbell_motion"
],
"entityIdType": "list",
"outputInitially": false,
"stateType": "str",
"ifState": "on",
"ifStateType": "str",
"ifStateOperator": "is",
"outputOnlyOnStateChange": true,
"for": "0",
"forType": "num",
"forUnits": "minutes",
"ignorePrevStateNull": false,
"ignorePrevStateUnknown": false,
"ignorePrevStateUnavailable": false,
"ignoreCurrentStateUnknown": false,
"ignoreCurrentStateUnavailable": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "entityidfilter",
"valueType": "config"
}
],
"x": 110,
"y": 200,
"wires": [
[
"ca42ab738f030c2b"
],
[]
]
},
{
"id": "ca42ab738f030c2b",
"type": "change",
"z": "fbaea1aaab14874b",
"name": "set entity ids",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\"entity_id\": payload ~> $join(\",\")}",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 270,
"y": 200,
"wires": [
[
"8a6d4e80ebf31f28",
"b7c39c3a32076d04"
]
]
},
{
"id": "8a6d4e80ebf31f28",
"type": "countdown",
"z": "fbaea1aaab14874b",
"name": "",
"topic": "",
"payloadTimerStart": "true",
"payloadTimerStartType": "bool",
"payloadTimerStop": "false",
"payloadTimerStopType": "bool",
"timer": "320",
"resetWhileRunning": true,
"setTimeToNewWhileRunning": true,
"startCountdownOnControlMessage": false,
"minuteCounter": false,
"x": 490,
"y": 200,
"wires": [
[],
[]
]
},
{
"id": "fa5cc73317dc1d3f",
"type": "api-get-history",
"z": "fbaea1aaab14874b",
"name": "Get 20s History",
"server": "80ed050d.56b658",
"version": 1,
"startDate": "",
"endDate": "",
"entityId": "",
"entityIdType": "equals",
"useRelativeTime": true,
"relativeTime": "320 seconds",
"flatten": false,
"outputType": "array",
"outputLocationType": "msg",
"outputLocation": "payload",
"x": 560,
"y": 260,
"wires": [
[
"ecfdfa6d1022e9bd"
]
]
},
{
"id": "b7c39c3a32076d04",
"type": "delay",
"z": "fbaea1aaab14874b",
"name": "",
"pauseType": "delay",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 400,
"y": 320,
"wires": [
[
"fa5cc73317dc1d3f"
]
]
},
{
"id": "ecfdfa6d1022e9bd",
"type": "function",
"z": "fbaea1aaab14874b",
"name": "check sensor states >1",
"func": "// loop through the different sensors\nconst activeSensors = msg.payload.map((sensor) => {\n // check if atleast one history has the state \"on\"\n return sensor.some((entity) => entity.state === \"on\");\n// count how many sensors had an \"on\" state\n}).filter((sensor) => sensor === true).length > 1;\n\n// if activeSensors is true than two sensor were active in the time window\nif(activeSensors) {\n return msg;\n}\n",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 810,
"y": 320,
"wires": [
[
"6b85147702262cc5",
"ea74f27aa182f0ec"
]
]
},
{
"id": "6b85147702262cc5",
"type": "time-range-switch",
"z": "fbaea1aaab14874b",
"name": "",
"lat": "",
"lon": "",
"startTime": "22:00",
"endTime": "06:00",
"startOffset": 0,
"endOffset": 0,
"x": 1070,
"y": 320,
"wires": [
[
"bb763592ce0872a1"
],
[]
]
},
{
"id": "bb763592ce0872a1",
"type": "api-call-service",
"z": "fbaea1aaab14874b",
"name": "CRITICAL NOTIFICATION ",
"server": "80ed050d.56b658",
"version": 5,
"debugenabled": true,
"domain": "notify",
"service": "mobile_app_ians_iphone_2",
"areaId": [],
"deviceId": [],
"entityId": [],
"data": "{\"title\":\"Garden\",\"message\":\"Garden Motion\",\"data\":{\"push\":{\"sound\":{\"name\":\"default\",\"critical\":1,\"volume\":0.7}}}}",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 1340,
"y": 300,
"wires": [
[]
]
},
{
"id": "ea74f27aa182f0ec",
"type": "debug",
"z": "fbaea1aaab14874b",
"name": "debug 104",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1250,
"y": 440,
"wires": []
},
{
"id": "80ed050d.56b658",
"type": "server",
"name": "Home Assistant",
"addon": true,
"rejectUnauthorizedCerts": true,
"ha_boolean": "",
"connectionDelay": false,
"cacheJson": false,
"heartbeat": false,
"heartbeatInterval": "",
"statusSeparator": "",
"enableGlobalContextStore": false
}
]