I am using a state_node
to check whether a device has been turned on/off for a given amount of time and then send a notification to my phone. Here is an image of this:
The notification will be sent after 5 minutes and as you can see only if it was turned on but … I would like to check every other 5 min if the device remains on and the main reason is that sometimes someone at home left devices on for a long time wasting money because of power heh. Can I get some ideas for this?
Here is my current flow JSON:
[
{
"id": "acc66eae0bd38f04",
"type": "tab",
"label": "Lights On",
"disabled": false,
"info": "",
"env": [
]
},
{
"id": "53068e834c06c590",
"type": "server-state-changed",
"z": "acc66eae0bd38f04",
"name": "Device is On",
"server": "e593dd3.052432",
"version": 4,
"exposeToHomeAssistant": false,
"haConfig": [
{
"property": "name",
"value": ""
},
{
"property": "icon",
"value": ""
}
],
"entityidfilter": [
"fan.living_room_switch",
"fan.master_bedroom_switch",
"fan.office_switch"
],
"entityidfiltertype": "list",
"outputinitially": false,
"state_type": "str",
"haltifstate": "on",
"halt_if_type": "str",
"halt_if_compare": "is",
"outputs": 2,
"output_only_on_state_change": true,
"for": "5",
"forType": "num",
"forUnits": "minutes",
"ignorePrevStateNull": false,
"ignorePrevStateUnknown": false,
"ignorePrevStateUnavailable": false,
"ignoreCurrentStateUnknown": false,
"ignoreCurrentStateUnavailable": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "eventData"
}
],
"x": 130,
"y": 100,
"wires": [
[
"20ef09168211f89b"
],
[
]
]
},
{
"id": "20ef09168211f89b",
"type": "template",
"z": "acc66eae0bd38f04",
"name": "Get Friendly Name",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "The {{payload.new_state.attributes.friendly_name}} has been ON for more than 5 minutes!!!",
"output": "str",
"x": 390,
"y": 60,
"wires": [
[
"7dea291ec83ed2db"
]
]
},
{
"id": "7dea291ec83ed2db",
"type": "api-call-service",
"z": "acc66eae0bd38f04",
"name": "Send a notification",
"server": "e593dd3.052432",
"version": 5,
"debugenabled": true,
"domain": "notify",
"service": "mobile_app_reyniers_iphone",
"areaId": [
],
"deviceId": [
],
"entityId": [
],
"data": "{\"title\":\"Device is ON\",\"message\":\"{{payload}}\"}",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [
],
"queue": "none",
"x": 650,
"y": 80,
"wires": [
[
]
]
},
{
"id": "e593dd3.052432",
"type": "server",
"name": "Home Assistant",
"addon": true
}
]