I have created a “basic” flow that allows me to turn on/off two fans every hour if during daytime or every 30 minutes if it is nighttime. Here is what it looks like:
And here is the JSON for such flow (apologies in advance is big chunk of code):
[
{
"id": "4d66e46fdf014b28",
"type": "group",
"z": "6d9e82a8948d508f",
"name": "Server Rack Fans Control",
"style": {
"label": true,
"color": "#001f60"
},
"nodes": [
"2f62d03b6a0a24cd",
"6c40a92288e7dea6",
"fc02b28200938932",
"2c6fceee29cc9a24",
"0fd4d0bd078281a1",
"e6c428dab477e438",
"1b71cc1de3464325",
"73ffcdfc1958de42",
"a94ba14e2b1859c8",
"71d6d13e3de86cf5",
"49bcb9da63a5e46f",
"775a4b1771455dfc",
"2d2c5b3a996cd962",
"36678338ef5ba40f"
],
"x": 34,
"y": 19,
"w": 1522,
"h": 342
},
{
"id": "2f62d03b6a0a24cd",
"type": "time-range-switch",
"z": "6d9e82a8948d508f",
"g": "4d66e46fdf014b28",
"name": "",
"lat": "28.496890",
"lon": "-82.553900",
"startTime": "08:00",
"endTime": "20:00",
"startOffset": 0,
"endOffset": 0,
"x": 370,
"y": 100,
"wires": [
[
"0fd4d0bd078281a1"
],
[]
]
},
{
"id": "6c40a92288e7dea6",
"type": "inject",
"z": "6d9e82a8948d508f",
"g": "4d66e46fdf014b28",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "3600",
"crontab": "",
"once": false,
"onceDelay": "20",
"topic": "",
"payload": "",
"payloadType": "date",
"x": 150,
"y": 100,
"wires": [
[
"2f62d03b6a0a24cd"
]
]
},
{
"id": "fc02b28200938932",
"type": "time-range-switch",
"z": "6d9e82a8948d508f",
"g": "4d66e46fdf014b28",
"name": "",
"lat": "28.496890",
"lon": "-82.553900",
"startTime": "20:01",
"endTime": "07:59",
"startOffset": 0,
"endOffset": 0,
"x": 370,
"y": 280,
"wires": [
[
"e6c428dab477e438"
],
[]
]
},
{
"id": "2c6fceee29cc9a24",
"type": "inject",
"z": "6d9e82a8948d508f",
"g": "4d66e46fdf014b28",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "1800",
"crontab": "",
"once": false,
"onceDelay": "20",
"topic": "",
"payload": "",
"payloadType": "date",
"x": 150,
"y": 280,
"wires": [
[
"fc02b28200938932"
]
]
},
{
"id": "0fd4d0bd078281a1",
"type": "api-current-state",
"z": "6d9e82a8948d508f",
"g": "4d66e46fdf014b28",
"name": "",
"server": "e593dd3.052432",
"version": 3,
"outputs": 2,
"halt_if": "on",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "switch.smartplug_bottom_fan_switch",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "entity"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 750,
"y": 100,
"wires": [
[
"1b71cc1de3464325"
],
[
"73ffcdfc1958de42"
]
]
},
{
"id": "e6c428dab477e438",
"type": "api-current-state",
"z": "6d9e82a8948d508f",
"g": "4d66e46fdf014b28",
"name": "",
"server": "e593dd3.052432",
"version": 3,
"outputs": 2,
"halt_if": "on",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "switch.smartplug_bottom_fan_switch",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "entity"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 750,
"y": 280,
"wires": [
[
"49bcb9da63a5e46f"
],
[
"775a4b1771455dfc"
]
]
},
{
"id": "1b71cc1de3464325",
"type": "api-call-service",
"z": "6d9e82a8948d508f",
"g": "4d66e46fdf014b28",
"name": "",
"server": "e593dd3.052432",
"version": 5,
"debugenabled": false,
"domain": "switch",
"service": "turn_off",
"areaId": [],
"deviceId": [],
"entityId": [
"switch.smartplug_bottom_fan_switch"
],
"data": "",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "OFF",
"valueType": "str"
}
],
"queue": "none",
"x": 1080,
"y": 60,
"wires": [
[
"a94ba14e2b1859c8"
]
]
},
{
"id": "73ffcdfc1958de42",
"type": "api-call-service",
"z": "6d9e82a8948d508f",
"g": "4d66e46fdf014b28",
"name": "",
"server": "e593dd3.052432",
"version": 5,
"debugenabled": false,
"domain": "switch",
"service": "turn_on",
"areaId": [],
"deviceId": [],
"entityId": [
"switch.smartplug_bottom_fan_switch"
],
"data": "",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "ON",
"valueType": "str"
}
],
"queue": "none",
"x": 1080,
"y": 140,
"wires": [
[
"a94ba14e2b1859c8"
]
]
},
{
"id": "a94ba14e2b1859c8",
"type": "change",
"z": "6d9e82a8948d508f",
"g": "4d66e46fdf014b28",
"name": "Set notification attributes",
"rules": [
{
"t": "set",
"p": "title",
"pt": "msg",
"to": "Server Rack",
"tot": "str"
},
{
"t": "set",
"p": "message1",
"pt": "msg",
"to": "The bottom fan has been turned:",
"tot": "str"
},
{
"t": "set",
"p": "message2",
"pt": "msg",
"to": "payload",
"tot": "msg"
},
{
"t": "set",
"p": "message3",
"pt": "msg",
"to": "",
"tot": "str"
},
{
"t": "set",
"p": "critical",
"pt": "msg",
"to": "0",
"tot": "str"
},
{
"t": "set",
"p": "sound",
"pt": "msg",
"to": "default",
"tot": "str"
},
{
"t": "set",
"p": "volume",
"pt": "msg",
"to": "0.5",
"tot": "str"
},
{
"t": "set",
"p": "target",
"pt": "msg",
"to": "mobile_app_reynier_iphone",
"tot": "str"
},
{
"t": "set",
"p": "entity_id",
"pt": "msg",
"to": "",
"tot": "str"
},
{
"t": "set",
"p": "friendly_name",
"pt": "msg",
"to": "",
"tot": "str"
},
{
"t": "set",
"p": "event_action",
"pt": "msg",
"to": "",
"tot": "str"
},
{
"t": "set",
"p": "event_action_title",
"pt": "msg",
"to": "",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1350,
"y": 100,
"wires": [
[
"71d6d13e3de86cf5"
]
]
},
{
"id": "71d6d13e3de86cf5",
"type": "link out",
"z": "6d9e82a8948d508f",
"g": "4d66e46fdf014b28",
"name": "",
"mode": "link",
"links": [
"b6171fec.b478f"
],
"x": 1515,
"y": 100,
"wires": []
},
{
"id": "49bcb9da63a5e46f",
"type": "api-call-service",
"z": "6d9e82a8948d508f",
"g": "4d66e46fdf014b28",
"name": "",
"server": "e593dd3.052432",
"version": 5,
"debugenabled": false,
"domain": "switch",
"service": "turn_off",
"areaId": [],
"deviceId": [
"bd76567dec27ab2b7e2234b19e56452d"
],
"entityId": [],
"data": "",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "OFF",
"valueType": "str"
}
],
"queue": "none",
"x": 1100,
"y": 240,
"wires": [
[]
]
},
{
"id": "775a4b1771455dfc",
"type": "api-call-service",
"z": "6d9e82a8948d508f",
"g": "4d66e46fdf014b28",
"name": "",
"server": "e593dd3.052432",
"version": 5,
"debugenabled": false,
"domain": "switch",
"service": "turn_on",
"areaId": [],
"deviceId": [
"bd76567dec27ab2b7e2234b19e56452d"
],
"entityId": [],
"data": "",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "ON",
"valueType": "str"
}
],
"queue": "none",
"x": 1100,
"y": 320,
"wires": [
[]
]
},
{
"id": "2d2c5b3a996cd962",
"type": "comment",
"z": "6d9e82a8948d508f",
"g": "4d66e46fdf014b28",
"name": "Check every 1h",
"info": "",
"x": 140,
"y": 60,
"wires": []
},
{
"id": "36678338ef5ba40f",
"type": "comment",
"z": "6d9e82a8948d508f",
"g": "4d66e46fdf014b28",
"name": "Check every 30m",
"info": "",
"x": 140,
"y": 240,
"wires": []
},
{
"id": "e593dd3.052432",
"type": "server",
"name": "Home Assistant",
"addon": true
}
]
I want to go beyond and do something like:
if it is daytime then keep the fans running for one hour stop them for 30 min then run them again for the next hour and so on. If it is nighttime then I want the opposite keep them running for 30 minutes and have them stopped for one hour.
As you can see I am using an Inject node which injects a timestamp every hour or every 30 min but this will not allow me to do what I am looking for.
Can I get some ideas? or if you have something similar can you share it with me?