I have this flow:
[
{
"id": "b984ca5b35cf43bb",
"type": "tab",
"label": "Airco Automation",
"disabled": false,
"info": "",
"env": []
},
{
"id": "f469ea8cf928138a",
"type": "server-state-changed",
"z": "b984ca5b35cf43bb",
"name": "realtime_produced_power_kw",
"server": "e088f9a18be9efaf",
"version": 6,
"outputs": 1,
"exposeAsEntityConfig": "",
"entities": {
"entity": [
"sensor.realtime_produced_power_kw"
],
"substring": [],
"regex": []
},
"outputInitially": false,
"stateType": "num",
"ifState": "",
"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": "",
"valueType": "entityState"
}
],
"x": 380,
"y": 200,
"wires": [
[
"af9e50462e4fa7a9"
]
]
},
{
"id": "af9e50462e4fa7a9",
"type": "change",
"z": "b984ca5b35cf43bb",
"name": "set topic to realtime_produced_power_kw",
"rules": [
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "realtime_produced_power_kw",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 720,
"y": 200,
"wires": [
[
"29afbc6978016251",
"9d4cd0482f4339dd"
]
]
},
{
"id": "a86e2f17605167a2",
"type": "change",
"z": "b984ca5b35cf43bb",
"name": "set topic to realtime_consumption_kw",
"rules": [
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "realtime_consumption_kw",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 710,
"y": 100,
"wires": [
[
"9d4cd0482f4339dd",
"d74b013885f9862e"
]
]
},
{
"id": "46f29b5046816ca2",
"type": "server-state-changed",
"z": "b984ca5b35cf43bb",
"name": "realtime_consumption_kw",
"server": "e088f9a18be9efaf",
"version": 6,
"outputs": 1,
"exposeAsEntityConfig": "",
"entities": {
"entity": [
"sensor.realtime_power_kw"
],
"substring": [],
"regex": []
},
"outputInitially": false,
"stateType": "num",
"ifState": "",
"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": "",
"valueType": "entityState"
}
],
"x": 370,
"y": 100,
"wires": [
[
"a86e2f17605167a2"
]
]
},
{
"id": "9d4cd0482f4339dd",
"type": "join",
"z": "b984ca5b35cf43bb",
"name": "Join Power Data",
"mode": "custom",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"useparts": false,
"accumulate": true,
"timeout": "",
"count": "3",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 1070,
"y": 140,
"wires": [
[
"96f29f2f35a0e8f1"
]
]
},
{
"id": "29afbc6978016251",
"type": "debug",
"z": "b984ca5b35cf43bb",
"name": "realtime_produced_power_kw",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1150,
"y": 200,
"wires": []
},
{
"id": "d74b013885f9862e",
"type": "debug",
"z": "b984ca5b35cf43bb",
"name": "realtime_consumption_kw",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1070,
"y": 100,
"wires": []
},
{
"id": "96f29f2f35a0e8f1",
"type": "function",
"z": "b984ca5b35cf43bb",
"name": "Check conditions",
"func": "let producedPower = parseFloat(msg.payload.realtime_produced_power_kw); // Extracting the produced power\nlet realtime_consumption_kw = parseFloat(msg.payload.realtime_consumption_kw); // Extracting the consumption power\nlet hvacState = msg.payload.hvac_state; // Extracting the HVAC state\n\n// Log the incoming values to check they are as expected\nnode.warn(`Produced Power: ${producedPower}`);\nnode.warn(`Real-time Consumption: ${realtime_consumption_kw}`);\nnode.warn(`HVAC State: ${hvacState}`);\n\n// Set up a flow variable to track if HVAC is already on\nlet hvacOn = flow.get(\"hvacOn\") || false;\n\n// Adjust conditions to account for the hvac_state\nif (producedPower - realtime_consumption_kw >= 1.8 && !hvacOn && hvacState !== \"heat\") {\n // Condition to turn ON: produced power exceeds consumption by 1.8 kW, and HVAC is off and not in 'heat' mode\n node.warn(\"Condition to turn ON met\");\n flow.set(\"hvacOn\", true);\n return [msg, null]; // Proceed with \"on\" actions\n}\nelse if (realtime_consumption_kw > producedPower && hvacOn && hvacState === \"heat\") {\n // Condition to turn OFF: consumption exceeds production, and HVAC is on and in 'heat' mode\n node.warn(\"Condition to turn OFF met\");\n flow.set(\"hvacOn\", false);\n return [null, msg]; // Trigger \"off\" actions\n}\nelse {\n // Log which condition failed\n if (!(producedPower - realtime_consumption_kw >= 1.8)) {\n node.warn(\"Condition to turn ON not met: Produced power is not sufficient.\");\n }\n if (!(realtime_consumption_kw > producedPower)) {\n node.warn(\"Condition to turn OFF not met: Consumption is not greater than production.\");\n }\n if (!(hvacState !== \"heat\")) {\n node.warn(\"HVAC is in heat mode, so turn ON condition is skipped.\");\n }\n if (!(hvacState === \"heat\")) {\n node.warn(\"HVAC is not in heat mode, so turn OFF condition is skipped.\");\n }\n\n node.warn(\"No action taken - conditions not met\");\n}\n\nreturn null; // No action if conditions are not met\n",
"outputs": 2,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 310,
"y": 560,
"wires": [
[
"15de4adb5840fcf7",
"0f3a9ac1dcd8cf64",
"6b5d8fceb4d0b66d"
],
[
"735ac8ec4566d685"
]
]
},
{
"id": "be064340653c0bda",
"type": "api-call-service",
"z": "b984ca5b35cf43bb",
"name": "Set HVAC Mode to Heat",
"server": "e088f9a18be9efaf",
"version": 7,
"debugenabled": false,
"action": "climate.set_hvac_mode",
"floorId": [],
"areaId": [],
"deviceId": [],
"entityId": [
"climate.1e6a9e2b"
],
"labelId": [],
"data": "{ \"hvac_mode\": \"heat\" }",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"blockInputOverrides": false,
"domain": "climate",
"service": "set_hvac_mode",
"service_domain": "climate",
"x": 1110,
"y": 540,
"wires": [
[
"fd0d61c5bd083414"
]
]
},
{
"id": "4f54c319b9c5f408",
"type": "api-call-service",
"z": "b984ca5b35cf43bb",
"name": "Set Preset Mode to Boost",
"server": "e088f9a18be9efaf",
"version": 7,
"debugenabled": false,
"action": "climate.set_preset_mode",
"floorId": [],
"areaId": [],
"deviceId": [],
"entityId": [
"climate.1e6a9e2b"
],
"labelId": [],
"data": "{ \"preset_mode\": \"boost\" }",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"blockInputOverrides": false,
"domain": "climate",
"service": "set_preset_mode",
"service_domain": "climate",
"x": 1110,
"y": 600,
"wires": [
[
"b18a65bc919bcaf5"
]
]
},
{
"id": "025f5c9eaa43c581",
"type": "api-call-service",
"z": "b984ca5b35cf43bb",
"name": "Set Target Temperature to 30",
"server": "e088f9a18be9efaf",
"version": 7,
"debugenabled": false,
"action": "climate.set_temperature",
"floorId": [],
"areaId": [],
"deviceId": [],
"entityId": [
"climate.1e6a9e2b"
],
"labelId": [],
"data": "{ \"temperature\": 30 }",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"blockInputOverrides": false,
"domain": "climate",
"service": "set_temperature",
"service_domain": "climate",
"x": 1120,
"y": 660,
"wires": [
[
"79cd5c0219bfdb7c"
]
]
},
{
"id": "78744bf75ef1cdf9",
"type": "api-call-service",
"z": "b984ca5b35cf43bb",
"name": "Set HVAC Mode to Off",
"server": "e088f9a18be9efaf",
"version": 7,
"debugenabled": false,
"action": "climate.set_hvac_mode",
"floorId": [],
"areaId": [],
"deviceId": [],
"entityId": [
"climate.1e6a9e2b"
],
"labelId": [],
"data": "{ \"hvac_mode\": \"off\" }",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"blockInputOverrides": false,
"domain": "climate",
"service": "set_hvac_mode",
"service_domain": "climate",
"x": 1120,
"y": 760,
"wires": [
[
"fc2c7a977d86f73c"
]
]
},
{
"id": "c1c3b6e18bf75f8b",
"type": "api-current-state",
"z": "b984ca5b35cf43bb",
"name": "",
"server": "e088f9a18be9efaf",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "climate.1e6a9e2b",
"state_type": "str",
"blockInputOverrides": true,
"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": 390,
"y": 280,
"wires": [
[
"e768509ea2cead1f"
]
]
},
{
"id": "e768509ea2cead1f",
"type": "change",
"z": "b984ca5b35cf43bb",
"name": "set topic to hvac_state",
"rules": [
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "hvac_state",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 700,
"y": 280,
"wires": [
[
"9d4cd0482f4339dd"
]
]
},
{
"id": "d76f3c23df45ac81",
"type": "inject",
"z": "b984ca5b35cf43bb",
"name": "start_check",
"props": [],
"repeat": "30",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 150,
"y": 280,
"wires": [
[
"c1c3b6e18bf75f8b"
]
]
},
{
"id": "6b5d8fceb4d0b66d",
"type": "trigger",
"z": "b984ca5b35cf43bb",
"name": "Trigger 5 Min Timer",
"op1": "true",
"op2": "false",
"op1type": "bool",
"op2type": "bool",
"duration": "5",
"extend": true,
"overrideDelay": false,
"units": "min",
"reset": "false",
"bytopic": "all",
"topic": "topic",
"outputs": 1,
"x": 810,
"y": 660,
"wires": [
[
"025f5c9eaa43c581"
]
]
},
{
"id": "0f3a9ac1dcd8cf64",
"type": "trigger",
"z": "b984ca5b35cf43bb",
"name": "Trigger 5 Min Timer",
"op1": "true",
"op2": "false",
"op1type": "bool",
"op2type": "bool",
"duration": "5",
"extend": true,
"units": "min",
"reset": "false",
"outputs": 1,
"x": 810,
"y": 600,
"wires": [
[
"4f54c319b9c5f408"
]
]
},
{
"id": "15de4adb5840fcf7",
"type": "trigger",
"z": "b984ca5b35cf43bb",
"name": "Trigger 5 Min Timer",
"op1": "true",
"op2": "false",
"op1type": "bool",
"op2type": "bool",
"duration": "5",
"extend": true,
"units": "min",
"reset": "false",
"outputs": 1,
"x": 810,
"y": 540,
"wires": [
[
"be064340653c0bda"
]
]
},
{
"id": "735ac8ec4566d685",
"type": "trigger",
"z": "b984ca5b35cf43bb",
"name": "Trigger 5 Min Timer",
"op1": "true",
"op2": "false",
"op1type": "bool",
"op2type": "bool",
"duration": "5",
"extend": true,
"units": "min",
"reset": "false",
"outputs": 1,
"x": 810,
"y": 760,
"wires": [
[
"78744bf75ef1cdf9"
]
]
},
{
"id": "fd0d61c5bd083414",
"type": "debug",
"z": "b984ca5b35cf43bb",
"name": "HVAC Mode to Heat",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1380,
"y": 540,
"wires": []
},
{
"id": "b18a65bc919bcaf5",
"type": "debug",
"z": "b984ca5b35cf43bb",
"name": "Preset Mode to Boost",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1380,
"y": 600,
"wires": []
},
{
"id": "79cd5c0219bfdb7c",
"type": "debug",
"z": "b984ca5b35cf43bb",
"name": "Target Temperature to 30",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1390,
"y": 660,
"wires": []
},
{
"id": "fc2c7a977d86f73c",
"type": "debug",
"z": "b984ca5b35cf43bb",
"name": "HVAC Mode to Off",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1370,
"y": 760,
"wires": []
},
{
"id": "e088f9a18be9efaf",
"type": "server",
"name": "Home Assistant",
"version": 5,
"addon": false,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": false,
"heartbeatInterval": "30",
"areaSelector": "friendlyName",
"deviceSelector": "friendlyName",
"entitySelector": "friendlyName",
"statusSeparator": ": ",
"statusYear": "hidden",
"statusMonth": "short",
"statusDay": "numeric",
"statusHourCycle": "default",
"statusTimeFormat": "h:m",
"enableGlobalContextStore": false
}
]
This automation is related to an airco start and stop based on energy production and consumption. If the production is higher then consumption by 1.8 kw for 5 minutes then the airco is started. If production drops more the consumption for 5 minutes then airco will be turned off.
I need to use the same logic for my new flow but instead of 1 airco to have 3 aircos in there. If production is higher then consumption by 1.8 kw for 5 minutes then start airco1. If production is still higher then consumption after 5 minutes by 1.8 kw more then start airco2.
If production is still higher then consumption after another 5 minutes by 1.8 kw then start airco3.
I would need the same logic to be applied on turning off. Basically if consumption is higher then production for 5 minutes by 1.8 kw then stop airco1. If after another 5 minutes the consumption is higher then production by 1.8 kw then stop airco2. If after another 5 minutes the consumption is higher then production by 1.8 kw then stop airco3.
Also the state of the airco should be checked before sending any commands to it. If the airco is already turned on, then there is no more need to send the command again. If the airco is already turned off, then there is no more need to send the configuration again
I managed to get it working properly for a single airco but I have no idea how I can make this happen for 3 aircos.
Any help or idea is greatly appreciated