fellinga / node-red-contrib-ui-time-scheduler

Easily power on/off any kind of device based on a schedule that you can easily create at the node-red-dashboard frontend.
MIT License
37 stars 17 forks source link

Manual override #62

Closed pjgrun closed 2 years ago

pjgrun commented 2 years ago

Excellent function. I have started to use it in a number of automations. The one thing I am missing, is a manual override possibility to manually force a condition (On or Off) independently of programmed schedule. I have tried to use a separate switch node, and feeding in a disableDevice command for the affected device to the UI scheduler, but it occurs that when the device is "disabled" the scheduler will still force an off output for the disabled device, furthermore, the off output is refreshed as per refresh rate. I would like to be able to have have output refreshes (On or Off) while the device is enabled in the scheduler (as currently is the case), but would like to have the possibility of output being blocked (no output at all, no refreshes) when corresponding device is disabled.
Alternatively, I think it would be a good enhancement to have manual override button option included in the UI.

fellinga commented 2 years ago

Hi @pjgrun,

thanks for reaching out to me.

If you want to manually override timers, you would want to choose out of 3 possible state: always on, always off and automatic mode. A single switch won't be enough. I was facing the same issue a while ago and I ended up adding a dropdown node to the flow that handles that. I don't have the exact flow here at the moment but I quickly created something similar.

[ { "id": "a9184512.6d0338", "type": "file", "z": "578568e428e989a8", "name": "WriteFile", "filename": "/home/ubuntu/Documents/time-schedule0.txt", "appendNewline": true, "createDir": true, "overwriteFile": "true", "encoding": "none", "x": 700, "y": 120, "wires": [ [] ] }, { "id": "4d5aed99.b82234", "type": "inject", "z": "578568e428e989a8", "name": "FireAfterReboot", "props": [ { "p": "payload", "v": "", "vt": "date" }, { "p": "topic", "v": "", "vt": "string" } ], "repeat": "", "crontab": "", "once": true, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 140, "y": 160, "wires": [ [ "efd15a17.372ff8" ] ] }, { "id": "efd15a17.372ff8", "type": "file in", "z": "578568e428e989a8", "name": "ReadFile", "filename": "/home/ubuntu/Documents/time-schedule0.txt", "format": "utf8", "chunk": false, "sendError": false, "encoding": "none", "allProps": false, "x": 320, "y": 160, "wires": [ [ "dec834a4.768678" ] ] }, { "id": "dec834a4.768678", "type": "ui_time_scheduler", "z": "578568e428e989a8", "group": "bfe48a3e.1b0f4", "name": "", "startDay": "0", "refresh": 60, "devices": [ "Device 1" ], "singleOff": false, "onlySendChange": false, "customPayload": false, "eventMode": false, "eventOptions": [], "sendTopic": false, "lat": "", "lon": "", "customContextStore": "", "outputs": 2, "order": 3, "width": 0, "height": 0, "x": 490, "y": 160, "wires": [ [ "a9184512.6d0338" ], [ "ca90d620de307740" ] ] }, { "id": "66700bc4098e37cb", "type": "ui_dropdown", "z": "578568e428e989a8", "name": "", "label": "", "tooltip": "", "place": "Select option", "group": "bfe48a3e.1b0f4", "order": 1, "width": 0, "height": 0, "passthru": true, "multiple": false, "options": [ { "label": "automatic", "value": "auto", "type": "str" }, { "label": "always on", "value": true, "type": "bool" }, { "label": "always off", "value": false, "type": "bool" } ], "payload": "", "topic": "topic", "topicType": "msg", "className": "", "x": 480, "y": 60, "wires": [ [ "1c39700a56f26eb4" ] ] }, { "id": "ab6fca2294420b8f", "type": "function", "z": "578568e428e989a8", "name": "", "func": "msg.enabled = false;\n\nif (msg.payload != \"auto\") {\n return msg;\n}\n\nmsg.payload = flow.get(\"device1status\") || false;\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 960, "y": 60, "wires": [ [ "9ae2aade43e441b3" ] ] }, { "id": "1c39700a56f26eb4", "type": "change", "z": "578568e428e989a8", "name": "", "rules": [ { "t": "set", "p": "device1control", "pt": "flow", "to": "payload", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 740, "y": 60, "wires": [ [ "ab6fca2294420b8f" ] ] }, { "id": "9ae2aade43e441b3", "type": "ui_switch", "z": "578568e428e989a8", "name": "", "label": "MyDevice", "tooltip": "", "group": "bfe48a3e.1b0f4", "order": 2, "width": 0, "height": 0, "passthru": true, "decouple": "false", "topic": "", "style": "", "onvalue": "true", "onvalueType": "bool", "onicon": "", "oncolor": "", "offvalue": "false", "offvalueType": "bool", "officon": "", "offcolor": "", "x": 1140, "y": 60, "wires": [ [] ] }, { "id": "ca90d620de307740", "type": "change", "z": "578568e428e989a8", "name": "", "rules": [ { "t": "set", "p": "device1status", "pt": "flow", "to": "payload", "tot": "msg" }, { "t": "set", "p": "payload", "pt": "msg", "to": "device1control", "tot": "flow" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 720, "y": 160, "wires": [ [ "ab6fca2294420b8f" ] ] }, { "id": "68d5d0daae35bf53", "type": "inject", "z": "578568e428e989a8", "name": "FireAfterReboot", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": true, "onceDelay": 0.1, "topic": "", "payload": "auto", "payloadType": "str", "x": 140, "y": 60, "wires": [ [ "66700bc4098e37cb" ] ] }, { "id": "bfe48a3e.1b0f4", "type": "ui_group", "name": "Scheduler", "tab": "2936b813.6cde68", "order": 1, "disp": true, "width": "6", "collapse": false }, { "id": "2936b813.6cde68", "type": "ui_tab", "name": "Scheduler Demo", "icon": "dashboard", "order": 1, "disabled": false, "hidden": false } ]

Please let me know if this helps.

fellinga commented 2 years ago

I am going to close this for now, please let me know if there are any other questions!