# Gestão AQS - Solar

**URL:** <https://forum.cpha.pt/t/gestao-aqs-solar/15500>\
**Category:** Node-Red\
**Created:** [26 Novembro , 2025 12:24 UTC](https://forum.cpha.pt/t/gestao-aqs-solar/15500 "2025-11-26T12:24:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cafeoliveira](https://forum.cpha.pt/user_avatar/forum.cpha.pt/cafeoliveira/32/1106_2.png) [@cafeoliveira](https://forum.cpha.pt/u/cafeoliveira)\
**Post date:** [26 Novembro , 2025 12:24 UTC](https://forum.cpha.pt/t/gestao-aqs-solar/15500/1 "2025-11-26T12:24:06Z")

</div>

Bom dia Pessoal.

Estou com problemas em configurar uma automação no node red.  
Pretendo que a minha bomba AQS ligue apenas quando tenho excedente de energia (se este se mantiver por 2 minutos, para evitar ligar e desligar constantemente)

Segue abaixo o pretendido, mas não está a funcionar:

 ![imagem](https://forum.cpha.pt/uploads/default/original/3X/2/9/29c6272227e9c7fb55dc0d187ddbcdd7064fee58.png)

```auto
[
    {
        "id": "af8fabd7bd8d8fb2",
        "type": "server-state-changed",
        "z": "0f96bdfeb8c30bfd",
        "name": "Excedente Shelly EM",
        "server": "263571d7.8a05ce",
        "version": 6,
        "outputs": 1,
        "exposeAsEntityConfig": "",
        "entities": {
            "entity": [
                "sensor.shelly_em_channel_2_power"
            ],
            "substring": [],
            "regex": []
        },
        "outputInitially": false,
        "stateType": "num",
        "ifState": "",
        "ifStateType": "str",
        "outputOnlyOnStateChange": true,
        "for": "",
        "forType": "num",
        "ignorePrevStateNull": false,
        "ignorePrevStateUnknown": false,
        "ignorePrevStateUnavailable": false,
        "ignoreCurrentStateUnknown": false,
        "ignoreCurrentStateUnavailable": false,
        "outputProperties": [],
        "x": 160,
        "y": 120,
        "wires": [
            [
                "576c846cae8761f6",
                "e5458b71ae08ea52",
                "8b92ab7c5ff4a73a"
            ]
        ]
    },
    {
        "id": "576c846cae8761f6",
        "type": "switch",
        "z": "0f96bdfeb8c30bfd",
        "name": "Excedente < -800W ?",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "lt",
                "v": "-800",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "outputs": 1,
        "x": 430,
        "y": 60,
        "wires": [
            [
                "5d857d556bdd831b"
            ]
        ]
    },
    {
        "id": "5d857d556bdd831b",
        "type": "trigger",
        "z": "0f96bdfeb8c30bfd",
        "name": "Mantém 2 min",
        "op1": "ligar",
        "op2": "",
        "duration": "2",
        "units": "min",
        "outputs": 1,
        "x": 680,
        "y": 60,
        "wires": [
            [
                "07cd447daa8f9d23"
            ]
        ]
    },
    {
        "id": "07cd447daa8f9d23",
        "type": "api-call-service",
        "z": "0f96bdfeb8c30bfd",
        "name": "Ligar Bomba AQS",
        "server": "263571d7.8a05ce",
        "version": 7,
        "action": "switch.turn_on",
        "entityId": [
            "switch.bomba_de_calor"
        ],
        "data": "{}",
        "dataType": "jsonata",
        "x": 950,
        "y": 60,
        "wires": [
            []
        ]
    },
    {
        "id": "e5458b71ae08ea52",
        "type": "switch",
        "z": "0f96bdfeb8c30bfd",
        "name": "Excedente > -300W ?",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "gt",
                "v": "-300",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "outputs": 1,
        "x": 440,
        "y": 160,
        "wires": [
            [
                "5b81846dde7b31f2"
            ]
        ]
    },
    {
        "id": "5b81846dde7b31f2",
        "type": "trigger",
        "z": "0f96bdfeb8c30bfd",
        "name": "Mantém 30s",
        "op1": "desligar",
        "op2": "",
        "duration": "30",
        "units": "s",
        "outputs": 1,
        "x": 690,
        "y": 160,
        "wires": [
            [
                "14c20cfc50c4b1b2"
            ]
        ]
    },
    {
        "id": "14c20cfc50c4b1b2",
        "type": "api-call-service",
        "z": "0f96bdfeb8c30bfd",
        "name": "Desligar Bomba AQS",
        "server": "263571d7.8a05ce",
        "version": 7,
        "action": "switch.turn_off",
        "entityId": [
            "switch.bomba_de_calor"
        ],
        "data": "{}",
        "dataType": "jsonata",
        "x": 930,
        "y": 160,
        "wires": [
            []
        ]
    },
    {
        "id": "8b92ab7c5ff4a73a",
        "type": "switch",
        "z": "0f96bdfeb8c30bfd",
        "name": "Excedente < -500W ?",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "lt",
                "v": "-500",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "outputs": 1,
        "x": 430,
        "y": 260,
        "wires": [
            [
                "adc1c6bac4c268df"
            ]
        ]
    },
    {
        "id": "adc1c6bac4c268df",
        "type": "api-call-service",
        "z": "0f96bdfeb8c30bfd",
        "name": "Ligar Bomba Retorno",
        "server": "263571d7.8a05ce",
        "version": 7,
        "action": "switch.turn_on",
        "entityId": [
            "switch.bombaretorno"
        ],
        "data": "{}",
        "dataType": "jsonata",
        "x": 680,
        "y": 260,
        "wires": [
            []
        ]
    },
    {
        "id": "263571d7.8a05ce",
        "type": "server",
        "name": "Home Assistant",
        "addon": true,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "",
        "connectionDelay": false,
        "cacheJson": false,
        "heartbeat": false,
        "heartbeatInterval": "",
        "statusSeparator": "",
        "enableGlobalContextStore": false
    },
    {
        "id": "6a34275d927de98e",
        "type": "global-config",
        "env": [],
        "modules": {
            "node-red-contrib-home-assistant-websocket": "0.80.3"
        }
    }
]

```

Agradeço ajuda.

Obrigado

---

<div class="post-metadata">

**Author:** ![luuuis](https://forum.cpha.pt/user_avatar/forum.cpha.pt/luuuis/32/14755_2.png) [@luuuis](https://forum.cpha.pt/u/luuuis)\
**Post date:** [2 Dezembro , 2025 11:30 UTC](https://forum.cpha.pt/t/gestao-aqs-solar/15500/2 "2025-12-02T11:30:31Z")

</div>

Podes incluir o tempo mínimo e a condição directamente em `Events state`. Experimenta da seguinte forma.

 ![image](https://forum.cpha.pt/uploads/default/original/3X/9/8/985f37f6e4a3bf8dbf940f3d7df13558e0749a5f.png)

> **XML export**
>
> ```auto
> [{"id":"e76154b153226947","type":"server-state-changed","z":"6ed3438d.db38fc","name":"Excedente > 800 W (2 min)","server":"2b48fe51.991b42","version":6,"outputs":2,"exposeAsEntityConfig":"","entities":{"entity":["sensor.shelly_em_channel_2_power"],"substring":[],"regex":[]},"outputInitially":false,"stateType":"str","ifState":"800","ifStateType":"num","ifStateOperator":"gt","outputOnlyOnStateChange":true,"for":"2","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"turn_on","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":190,"y":1300,"wires":[["ca4433e26519864b"],[]]},{"id":"a9938ac9dd709a3b","type":"server-state-changed","z":"6ed3438d.db38fc","name":"Excedente < 300 W (30 seg.)","server":"2b48fe51.991b42","version":6,"outputs":2,"exposeAsEntityConfig":"","entities":{"entity":["sensor.shelly_em_channel_2_power"],"substring":[],"regex":[]},"outputInitially":false,"stateType":"str","ifState":"800","ifStateType":"num","ifStateOperator":"gte","outputOnlyOnStateChange":true,"for":"30","forType":"num","forUnits":"seconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"turn_off","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":200,"y":1360,"wires":[["ca4433e26519864b"],[]]},{"id":"ca4433e26519864b","type":"api-call-service","z":"6ed3438d.db38fc","name":"Bomba AQS","server":"2b48fe51.991b42","version":7,"debugenabled":false,"action":"{{payload}}","floorId":[],"areaId":[],"deviceId":[],"entityId":["{{topic}}"],"labelId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":true,"domain":"","service":"","x":470,"y":1320,"wires":[[]]},{"id":"2b48fe51.991b42","type":"server","name":"Home Assistant","version":5,"addon":true,"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":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"bc242528b6d9d1ca","type":"global-config","env":[],"modules":{"node-red-contrib-home-assistant-websocket":"0.79.4"}}]
> 
> ```

---

<div class="post-metadata">

**Author:** ![cafeoliveira](https://forum.cpha.pt/user_avatar/forum.cpha.pt/cafeoliveira/32/1106_2.png) [@cafeoliveira](https://forum.cpha.pt/u/cafeoliveira)\
**Post date:** [17 Dezembro , 2025 16:28 UTC](https://forum.cpha.pt/t/gestao-aqs-solar/15500/3 "2025-12-17T16:28:25Z")

</div>

Boas.

Resolvi desta forma:

 ![imagem](https://forum.cpha.pt/uploads/default/original/3X/a/9/a932b8d253b920d716f5cc22db0065976f6ec9c7.png)

```auto
[
    {
        "id": "0f96bdfeb8c30bfd",
        "type": "tab",
        "label": "Gestão Solar AQS",
        "disabled": false,
        "info": ""
    },
    {
        "id": "af8fabd7bd8d8fb2",
        "type": "server-state-changed",
        "z": "0f96bdfeb8c30bfd",
        "name": "Leitura Power Shelly",
        "server": "263571d7.8a05ce",
        "version": 6,
        "outputs": 2,
        "exposeAsEntityConfig": "",
        "entities": {
            "entity": [
                "sensor.shelly_em_channel_2_power"
            ],
            "substring": [],
            "regex": []
        },
        "outputInitially": false,
        "stateType": "str",
        "ifState": "-800",
        "ifStateType": "num",
        "ifStateOperator": "lt",
        "outputOnlyOnStateChange": true,
        "for": "",
        "forType": "num",
        "ignorePrevStateNull": false,
        "ignorePrevStateUnknown": false,
        "ignorePrevStateUnavailable": false,
        "ignoreCurrentStateUnknown": false,
        "ignoreCurrentStateUnavailable": false,
        "outputProperties": [],
        "x": 130,
        "y": 140,
        "wires": [
            [
                "5d857d556bdd831b"
            ],
            []
        ]
    },
    {
        "id": "5d857d556bdd831b",
        "type": "trigger",
        "z": "0f96bdfeb8c30bfd",
        "name": "Mantém 2 min",
        "op1": "ligar",
        "op2": "",
        "op1type": "str",
        "op2type": "str",
        "duration": "2",
        "extend": false,
        "overrideDelay": false,
        "units": "min",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 400,
        "y": 40,
        "wires": [
            [
                "07cd447daa8f9d23"
            ]
        ]
    },
    {
        "id": "07cd447daa8f9d23",
        "type": "api-call-service",
        "z": "0f96bdfeb8c30bfd",
        "name": "Ligar Bomba AQS",
        "server": "263571d7.8a05ce",
        "version": 7,
        "action": "switch.turn_on",
        "entityId": [
            "switch.bomba_de_calor"
        ],
        "data": "{}",
        "dataType": "jsonata",
        "x": 1250,
        "y": 40,
        "wires": [
            []
        ]
    },
    {
        "id": "5b81846dde7b31f2",
        "type": "trigger",
        "z": "0f96bdfeb8c30bfd",
        "name": "Mantém 30s",
        "op1": "desligar",
        "op2": "",
        "op1type": "str",
        "op2type": "str",
        "duration": "30",
        "extend": false,
        "overrideDelay": false,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 390,
        "y": 220,
        "wires": [
            [
                "90e64a90cfc5bf2e"
            ]
        ]
    },
    {
        "id": "14c20cfc50c4b1b2",
        "type": "api-call-service",
        "z": "0f96bdfeb8c30bfd",
        "name": "Desligar Bomba AQS",
        "server": "263571d7.8a05ce",
        "version": 7,
        "debugenabled": false,
        "action": "switch.turn_off",
        "floorId": [],
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "switch.bomba_de_calor"
        ],
        "labelId": [],
        "data": "{}",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "blockInputOverrides": false,
        "domain": "switch",
        "service": "turn_off",
        "x": 1260,
        "y": 220,
        "wires": [
            []
        ]
    },
    {
        "id": "748da4b71b1d4f99",
        "type": "inject",
        "z": "0f96bdfeb8c30bfd",
        "name": "10:00",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "00 10 * * *",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "str",
        "x": 820,
        "y": 140,
        "wires": [
            [
                "07cd447daa8f9d23"
            ]
        ]
    },
    {
        "id": "11858a2cf117d633",
        "type": "inject",
        "z": "0f96bdfeb8c30bfd",
        "name": "15:00",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "00 15 * * *",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "str",
        "x": 840,
        "y": 300,
        "wires": [
            [
                "14c20cfc50c4b1b2"
            ]
        ]
    },
    {
        "id": "sensor_temp",
        "type": "server-state-changed",
        "z": "0f96bdfeb8c30bfd",
        "name": "Leitura Temp DS18B20",
        "server": "263571d7.8a05ce",
        "version": 6,
        "outputs": 2,
        "exposeAsEntityConfig": "",
        "entities": {
            "entity": [
                "sensor.tasmota_ds18b20_2_temperature"
            ],
            "substring": [],
            "regex": []
        },
        "outputInitially": false,
        "stateType": "num",
        "ifState": "30",
        "ifStateType": "num",
        "ifStateOperator": "gte",
        "outputOnlyOnStateChange": true,
        "for": "",
        "forType": "num",
        "ignorePrevStateNull": false,
        "ignorePrevStateUnknown": false,
        "ignorePrevStateUnavailable": false,
        "ignoreCurrentStateUnknown": false,
        "ignoreCurrentStateUnavailable": false,
        "outputProperties": [],
        "x": 860,
        "y": 400,
        "wires": [
            [
                "14c20cfc50c4b1b2"
            ],
            []
        ]
    },
    {
        "id": "55107f61c337e7c1",
        "type": "server-state-changed",
        "z": "0f96bdfeb8c30bfd",
        "name": "Leitura Power Shelly",
        "server": "263571d7.8a05ce",
        "version": 6,
        "outputs": 2,
        "exposeAsEntityConfig": "",
        "entities": {
            "entity": [
                "sensor.shelly_em_channel_2_power"
            ],
            "substring": [],
            "regex": []
        },
        "outputInitially": false,
        "stateType": "str",
        "ifState": "300",
        "ifStateType": "num",
        "ifStateOperator": "gt",
        "outputOnlyOnStateChange": true,
        "for": "",
        "forType": "num",
        "ignorePrevStateNull": false,
        "ignorePrevStateUnknown": false,
        "ignorePrevStateUnavailable": false,
        "ignoreCurrentStateUnknown": false,
        "ignoreCurrentStateUnavailable": false,
        "outputProperties": [],
        "x": 130,
        "y": 280,
        "wires": [
            [
                "5b81846dde7b31f2"
            ],
            []
        ]
    },
    {
        "id": "90e64a90cfc5bf2e",
        "type": "api-current-state",
        "z": "0f96bdfeb8c30bfd",
        "name": "Modo Manual OFF?",
        "server": "263571d7.8a05ce",
        "version": 3,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "input_boolean.aqs_modo_manual",
        "state_type": "str",
        "blockInputOverrides": true,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "string",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "for": 0,
        "forType": "num",
        "forUnits": "minutes",
        "x": 720,
        "y": 200,
        "wires": [
            [
                "07cd447daa8f9d23"
            ],
            [
                "14c20cfc50c4b1b2"
            ]
        ]
    },
    {
        "id": "263571d7.8a05ce",
        "type": "server",
        "name": "Home Assistant",
        "addon": true,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "",
        "connectionDelay": false,
        "cacheJson": false,
        "heartbeat": false,
        "heartbeatInterval": "",
        "statusSeparator": "",
        "enableGlobalContextStore": false
    },
    {
        "id": "b8b8baabd1811a1f",
        "type": "global-config",
        "env": [],
        "modules": {
            "node-red-contrib-home-assistant-websocket": "0.80.3"
        }
    }
]

```

Obrigado  
Cumps
