SergiuToporjinschi / node-red-contrib-heater-controller

Heater controller for node-red dashboard
GNU General Public License v3.0
18 stars 17 forks source link

Scheduling not working for some reason #47

Closed aretakisv closed 4 years ago

aretakisv commented 4 years ago

It seems like scheduling is not currently working. Heater Is not posting payloads to change temperature. And this leads to a stuck thermostat

Running Version 2.0.2 of palette and nodered is 1.0.4 based on node 12 Docker image: 1.0.4-12-minimal-arm64v8

my subflow is:

[
    {
        "id": "85e8397c.17a368",
        "type": "switch",
        "z": "6c5980ce.3bf92",
        "name": "",
        "property": "payload.targetValue",
        "propertyType": "msg",
        "rules": [
            {
                "t": "neq",
                "v": "#:(disk)::currentSetTemp",
                "vt": "flow"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 830,
        "y": 100,
        "wires": [
            [
                "2889bfd9.acfaf"
            ]
        ]
    },
    {
        "id": "c7dc4c89.df946",
        "type": "change",
        "z": "6c5980ce.3bf92",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "#:(disk)::currentSetTemp",
                "pt": "flow",
                "to": "payload.value",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 350,
        "y": 340,
        "wires": [
            []
        ]
    },
    {
        "id": "6eab0d6c.49cab4",
        "type": "change",
        "z": "6c5980ce.3bf92",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "#:(disk)::userTargetValue",
                "pt": "flow",
                "to": "payload.userTargetValue",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "#:(disk)::isUserCustom",
                "pt": "flow",
                "to": "payload.isUserCustom",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "#:(disk)::changeTimestamp",
                "pt": "flow",
                "to": "",
                "tot": "date"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 760,
        "y": 180,
        "wires": [
            []
        ]
    },
    {
        "id": "262b48a9.30a978",
        "type": "inject",
        "z": "6c5980ce.3bf92",
        "name": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "60",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 230,
        "y": 520,
        "wires": [
            [
                "21a8456.e9a97ba"
            ]
        ]
    },
    {
        "id": "ec43a8d.79f1c58",
        "type": "switch",
        "z": "6c5980ce.3bf92",
        "name": "",
        "property": "($flowContext(\"changeTimestamp\", \"disk\") + ($globalContext(\"heatingDelay\", \"disk\")*(60*60*1000) )) < payload",
        "propertyType": "jsonata",
        "rules": [
            {
                "t": "true"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 530,
        "y": 520,
        "wires": [
            [
                "44183c92.48f004"
            ]
        ]
    },
    {
        "id": "21a8456.e9a97ba",
        "type": "switch",
        "z": "6c5980ce.3bf92",
        "name": "",
        "property": "#:(disk)::isUserCustom",
        "propertyType": "flow",
        "rules": [
            {
                "t": "true"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 390,
        "y": 520,
        "wires": [
            [
                "ec43a8d.79f1c58"
            ]
        ]
    },
    {
        "id": "44183c92.48f004",
        "type": "change",
        "z": "6c5980ce.3bf92",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "userConfig",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{ \"isUserCustom\": false }",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 700,
        "y": 520,
        "wires": [
            [
                "f1a84f6f.64012"
            ]
        ]
    },
    {
        "id": "f1a84f6f.64012",
        "type": "link out",
        "z": "6c5980ce.3bf92",
        "d": true,
        "name": "",
        "links": [
            "d4f7b6c2.ba47f8"
        ],
        "x": 815,
        "y": 520,
        "wires": []
    },
    {
        "id": "d4f7b6c2.ba47f8",
        "type": "link in",
        "z": "6c5980ce.3bf92",
        "name": "",
        "links": [
            "f1a84f6f.64012"
        ],
        "x": 355,
        "y": 140,
        "wires": [
            [
                "301bbaf5.b2cb96"
            ]
        ]
    },
    {
        "id": "2889bfd9.acfaf",
        "type": "change",
        "z": "6c5980ce.3bf92",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.targetValue",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 980,
        "y": 100,
        "wires": [
            []
        ]
    },
    {
        "id": "c28153cd.23c79",
        "type": "switch",
        "z": "6c5980ce.3bf92",
        "name": "Payload Routing",
        "property": "payload.class_id",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "49",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "67",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 140,
        "y": 260,
        "wires": [
            [
                "258bcd3a.80a202"
            ],
            [
                "c7dc4c89.df946"
            ]
        ]
    },
    {
        "id": "258bcd3a.80a202",
        "type": "change",
        "z": "6c5980ce.3bf92",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "#:(disk)::roomTemp",
                "pt": "flow",
                "to": "payload.value",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "currentTemp",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "#:(disk)::roomTemp",
                "tot": "flow"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 380,
        "y": 220,
        "wires": [
            [
                "301bbaf5.b2cb96"
            ]
        ]
    },
    {
        "id": "9bedb55b.394308",
        "type": "inject",
        "z": "6c5980ce.3bf92",
        "name": "",
        "topic": "currentTemp",
        "payload": "#:(disk)::roomTemp",
        "payloadType": "flow",
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "0.1",
        "x": 300,
        "y": 80,
        "wires": [
            [
                "301bbaf5.b2cb96"
            ]
        ]
    },
    {
        "id": "301bbaf5.b2cb96",
        "type": "ui_heater_controller",
        "z": "6c5980ce.3bf92",
        "name": "heater",
        "group": "fbed6f0b.6a621",
        "unit": "C",
        "order": 1,
        "width": "0",
        "height": "0",
        "topic": "",
        "title": "$(TRV_UI_TITLE)",
        "logLengthType": "days",
        "logLength": 1,
        "sliderMinValue": 10,
        "sliderMaxValue": 28,
        "sliderStep": 0.5,
        "thresholdRising": "10",
        "thresholdFalling": 0,
        "calendar": "${SCHEDULE}",
        "x": 530,
        "y": 140,
        "wires": [
            [
                "6eab0d6c.49cab4",
                "bef4d86f.832e38"
            ]
        ]
    },
    {
        "id": "bef4d86f.832e38",
        "type": "delay",
        "z": "6c5980ce.3bf92",
        "name": "",
        "pauseType": "delay",
        "timeout": "3",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 700,
        "y": 100,
        "wires": [
            [
                "85e8397c.17a368"
            ]
        ]
    },
    {
        "id": "16927bd2.e2fb44",
        "type": "inject",
        "z": "6c5980ce.3bf92",
        "name": "",
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "2",
        "x": 530,
        "y": 460,
        "wires": [
            [
                "44183c92.48f004"
            ]
        ]
    },
    {
        "id": "dde4e932.70adf8",
        "type": "inject",
        "z": "6c5980ce.3bf92",
        "name": "schedule",
        "topic": "setCalendar",
        "payload": "SCHEDULE",
        "payloadType": "env",
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "0.1",
        "x": 280,
        "y": 40,
        "wires": [
            [
                "301bbaf5.b2cb96"
            ]
        ]
    },
    {
        "id": "fbed6f0b.6a621",
        "type": "ui_group",
        "z": "",
        "name": "Heating",
        "tab": "dee0def.c82102",
        "order": 1,
        "disp": true,
        "width": "10",
        "collapse": false
    },
    {
        "id": "dee0def.c82102",
        "type": "ui_tab",
        "z": "",
        "name": "Heating",
        "icon": "dashboard",
        "order": 2,
        "disabled": false,
        "hidden": false
    }
]

I am using input from Zwave2mqtt and outputing to zwave2mqtt The flow has some comparisons in order to avoid an "endless loop" of setting and receiving temperature, which will drain the batteries and increase Zwave traffic.

At my latest attempts instead of using just Env Variable for the schedule, I also inject it some seconds after startup/deployment.

SergiuToporjinschi commented 4 years ago

Hi, the node will operate the status only when receives a new temperature value so you have to make sure that the new value is coming regular to this node.

SergiuToporjinschi commented 4 years ago

you can find this in documentation

Inputs This controller accepts one main input which has to have topic as "currentTemp" and payload needs to be a float The entire control is not functional until this message is received The heater status is recalculated when this message received, or when the user is changing the target temperature.

aretakisv commented 4 years ago

so, schedule will not work if there is no regular temperature (currentTemp) update?

SergiuToporjinschi commented 4 years ago

yes will not work you have to make sure that is getting at least a value on regular bases

SergiuToporjinschi commented 4 years ago

I want to avoid having timeouts and send value out, because if there is a bug will not have any control on it, will keep send value and can look randomly.

SergiuToporjinschi commented 4 years ago

In fact you are the second person that is asking for this behavior. You know!?!? I think I will set a ticket as a new feature. But don't expected to soon .... I've started to refactor this and I would like to finish the refactoring. After that I will see if I can set something that can be configured to work like that.