Timer with UI feedback

Thank you, Craig.
Peter replied that’s normal behavior of BigTimer.
So, as solution, I just over-passed the BigTimer node, connecting parse_timeout straight to switch control. All works now, every day :slight_smile:

Code here, maybe helpful for someone.

[
    {
        "id": "6491080e.1afc78",
        "type": "ui_switch",
        "z": "669e4b2e.c077d4",
        "name": "enable_water",
        "label": "Enable Watering",
        "group": "e6e9e9c5.46a0c8",
        "order": 1,
        "width": 0,
        "height": 0,
        "passthru": true,
        "decouple": "false",
        "topic": "shm/garden/water/enable",
        "style": "",
        "onvalue": "on",
        "onvalueType": "str",
        "onicon": "",
        "oncolor": "",
        "offvalue": "off",
        "offvalueType": "str",
        "officon": "",
        "offcolor": "",
        "x": 120,
        "y": 720,
        "wires": [
            [
                "82219b7f.5ef6e8"
            ]
        ]
    },
    {
        "id": "82219b7f.5ef6e8",
        "type": "change",
        "z": "669e4b2e.c077d4",
        "name": "switch2timer",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "off",
                "fromt": "str",
                "to": "stop",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "on",
                "fromt": "str",
                "to": "auto",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 150,
        "y": 760,
        "wires": [
            [
                "45189448.b43a1c",
                "339a41b2.52fd0e",
                "a6e8ed21.e3a26"
            ]
        ]
    },
    {
        "id": "9752622f.768e6",
        "type": "inject",
        "z": "669e4b2e.c077d4",
        "name": "water_sch_on",
        "topic": "shm/garden/water/enable",
        "payload": "on",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "x": 100,
        "y": 680,
        "wires": [
            [
                "6491080e.1afc78"
            ]
        ]
    },
    {
        "id": "b8860b8c.1579e8",
        "type": "inject",
        "z": "669e4b2e.c077d4",
        "name": "init_off",
        "topic": "",
        "payload": "off",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "0.05",
        "x": 370,
        "y": 920,
        "wires": [
            [
                "c413f53e.29ef58",
                "c5ae1192.32ff4",
                "b52a0805.d13df8"
            ]
        ]
    },
    {
        "id": "c413f53e.29ef58",
        "type": "exec",
        "z": "669e4b2e.c077d4",
        "command": "actuators/valve.py -i 2 ",
        "addpay": true,
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "oldrc": false,
        "name": "",
        "x": 560,
        "y": 920,
        "wires": [
            [
                "fcd2d087.c8a49"
            ],
            [],
            []
        ]
    },
    {
        "id": "fcd2d087.c8a49",
        "type": "debug",
        "z": "669e4b2e.c077d4",
        "name": "watering",
        "active": true,
        "tosidebar": true,
        "console": true,
        "tostatus": false,
        "complete": "payload",
        "x": 770,
        "y": 960,
        "wires": []
    },
    {
        "id": "a138f48e.2bbb08",
        "type": "mqtt out",
        "z": "669e4b2e.c077d4",
        "name": "",
        "topic": "",
        "qos": "",
        "retain": "",
        "broker": "2bd2afca.e962e",
        "x": 810,
        "y": 1020,
        "wires": []
    },
    {
        "id": "339a41b2.52fd0e",
        "type": "bigtimer",
        "z": "669e4b2e.c077d4",
        "outtopic": "shm/garden/water_tree/state",
        "outpayload1": "on",
        "outpayload2": "off",
        "name": "TreeTimer",
        "lat": "32",
        "lon": "34",
        "starttime": 5001,
        "endtime": "10090",
        "startoff": 0,
        "endoff": 0,
        "offs": 0,
        "outtext1": "on",
        "outtext2": "off",
        "timeout": 1440,
        "sun": false,
        "mon": false,
        "tue": true,
        "wed": false,
        "thu": false,
        "fri": false,
        "sat": true,
        "jan": false,
        "feb": false,
        "mar": false,
        "apr": false,
        "may": true,
        "jun": true,
        "jul": true,
        "aug": true,
        "sep": true,
        "oct": true,
        "nov": false,
        "dec": false,
        "day1": 0,
        "month1": 0,
        "day2": 0,
        "month2": 0,
        "day3": 0,
        "month3": 0,
        "day4": 0,
        "month4": 0,
        "day5": 0,
        "month5": 0,
        "d1": 0,
        "w1": 0,
        "d2": 0,
        "w2": 0,
        "d3": 0,
        "w3": 0,
        "d4": 0,
        "w4": 0,
        "d5": 0,
        "w5": 0,
        "suspend": false,
        "random": false,
        "repeat": false,
        "atstart": true,
        "odd": false,
        "even": false,
        "x": 380,
        "y": 980,
        "wires": [
            [],
            [],
            [
                "3ce33470.31935c",
                "a138f48e.2bbb08",
                "c413f53e.29ef58"
            ]
        ]
    },
    {
        "id": "3ce33470.31935c",
        "type": "ui_switch",
        "z": "669e4b2e.c077d4",
        "name": "",
        "label": "Water Trees",
        "group": "e6e9e9c5.46a0c8",
        "order": 6,
        "width": "5",
        "height": "1",
        "passthru": false,
        "decouple": "true",
        "topic": "shm/garden/water_tree/state",
        "style": "",
        "onvalue": "on",
        "onvalueType": "str",
        "onicon": "nature",
        "oncolor": "green",
        "offvalue": "off",
        "offvalueType": "str",
        "officon": "nature",
        "offcolor": "grey",
        "x": 120,
        "y": 1020,
        "wires": [
            [
                "d6f61713.adc4b8"
            ]
        ]
    },
    {
        "id": "d6f61713.adc4b8",
        "type": "function",
        "z": "669e4b2e.c077d4",
        "name": "parse_timeout",
        "func": "// Outputs:\n// Counter_to_display, GPIO control via BigTimer, Counter_to_process\n\ntry{\n    var delay = flow.get('get_water_timeout');\n} catch (er) {\n    var delay = 10;\n}\n\n// Block loop of messages when off\nvar prev = flow.get('prev_tree_msg') || {payload: 'ignore'};\nnode.status({fill:\"green\",shape:\"ring\",text: delay+','+prev.payload+','+msg.payload});\nif ('off' == msg.payload && 'off' == prev.payload) return [null, null, null];\nnode.status({fill:\"green\",shape:\"dot\",text: delay+','+prev.payload+','+msg.payload});\n\n// Keep msg for next round\nflow.set('prev_tree_msg', msg);\nif ('on' == msg.payload) {\n    // Set delay, start countdown, on load\n    var m1 = {payload: delay};\n    return [m1, msg, m1];  \n} else if (('off' == msg.payload) || (msg.payload <= 1)) {\n    var m1 = {payload: 0};\n    if ((msg.payload <= 1) && (0 == delay)) { // request never off\n        return [m1, null, m1];\n    } else {\n        // off load, reset clear counter\n        return [{payload: ' '}, {payload: 'off'}, null];\n    }\n} else if (msg.payload > 1) {\n    // decrement countdown\n    var m1 = {payload: parseInt(msg.payload)-1};\n    return [m1, null, m1];\n}\n",
        "outputs": 3,
        "noerr": 0,
        "x": 170,
        "y": 1080,
        "wires": [
            [
                "d25b362a.630378"
            ],
            [
                "3ce33470.31935c",
                "c413f53e.29ef58"
            ],
            [
                "a1168f85.09676"
            ]
        ]
    },
    {
        "id": "d25b362a.630378",
        "type": "ui_text",
        "z": "669e4b2e.c077d4",
        "group": "e6e9e9c5.46a0c8",
        "order": 7,
        "width": "1",
        "height": "1",
        "name": "counter",
        "label": "",
        "format": "{{msg.payload}}",
        "layout": "row-right",
        "x": 390,
        "y": 1060,
        "wires": []
    },
    {
        "id": "a1168f85.09676",
        "type": "trigger",
        "z": "669e4b2e.c077d4",
        "op1": "",
        "op2": "",
        "op1type": "nul",
        "op2type": "pay",
        "duration": "1",
        "extend": false,
        "units": "min",
        "reset": "",
        "bytopic": "all",
        "name": "",
        "x": 190,
        "y": 1140,
        "wires": [
            [
                "d6f61713.adc4b8"
            ]
        ]
    },
    {
        "id": "7cd4b83b.e9d328",
        "type": "function",
        "z": "669e4b2e.c077d4",
        "name": "UI_to_flow_context",
        "func": "flow.set(\"get_water_timeout\", msg.payload);\nreturn null;",
        "outputs": 1,
        "noerr": 0,
        "x": 740,
        "y": 1280,
        "wires": [
            []
        ]
    },
    {
        "id": "7998052f.fd021c",
        "type": "ui_slider",
        "z": "669e4b2e.c077d4",
        "name": "timeout",
        "label": "Stop in {{value}} min",
        "group": "e6e9e9c5.46a0c8",
        "order": 3,
        "width": 0,
        "height": 0,
        "passthru": true,
        "topic": "/shm/garden/timeout",
        "min": 0,
        "max": "90",
        "step": 1,
        "x": 550,
        "y": 1280,
        "wires": [
            [
                "7cd4b83b.e9d328"
            ]
        ]
    },
    {
        "id": "aff2deab.9a23a",
        "type": "inject",
        "z": "669e4b2e.c077d4",
        "name": "",
        "topic": "",
        "payload": "10",
        "payloadType": "num",
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "x": 400,
        "y": 1280,
        "wires": [
            [
                "7998052f.fd021c"
            ]
        ]
    },
    {
        "id": "e6e9e9c5.46a0c8",
        "type": "ui_group",
        "z": "",
        "name": "Garden: Watering",
        "tab": "531ef1f0.9a426",
        "order": 3,
        "disp": true,
        "width": "6",
        "collapse": false
    },
    {
        "id": "2bd2afca.e962e",
        "type": "mqtt-broker",
        "z": "",
        "name": "",
        "broker": "localhost",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": true,
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": ""
    },
    {
        "id": "531ef1f0.9a426",
        "type": "ui_tab",
        "z": "",
        "name": "MyDashboard",
        "icon": "home"
    }
] 

The valve/switch control script is here.

An alternative solution was:
Every time the UI control is taken, the parse_timeout should send 2 messages to the BigTimer: Manual + On or Off + Auto respectively.
This can be done with node.send() command (async messaging).
Advantage of this method versus current solution: MQTT receives manual on/off commands too for registration.
Disadvantage: more code, longer run time.