Code Monkey home page Code Monkey logo

node-red-contrib-mytimeout's People

Contributors

brammh avatar linuxha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

node-red-contrib-mytimeout's Issues

unwanted starting of countdown

Everytime I restart the node red server the countdown of mytimeout starts and puts a "1" on the output. I'm working with ubuntu 20.04.2 LTS, Node-RED 1.2.3 and mytimeout 3.2.0. Any help on this is appreciated. Thanks

Timer does not stop for FLOAT timeout values

Hi, I was experimenting a bit further with your timeout.

I have a calculated timeout which is a float value. When passing the float ast msg.timeout into your

  • The timer is accepting the float
  • The timer is counting down
    ->> The counter never stops as it does not reach 0

[{"id":"7dd3409d.0daae","type":"mytimeout","z":"b1d09add.6b04a8","name":"timer","outtopic":"","outsafe":"on","outwarning":"Warning","outunsafe":"off","warning":"5","timer":"20.001","debug":"0","repeat":false,"again":false,"x":510,"y":380,"wires":[["559dcc7d.65e6f4"],["559dcc7d.65e6f4"]]},{"id":"745c54b6.b9a71c","type":"inject","z":"b1d09add.6b04a8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":380,"wires":[["cd407dbc.6a09"]]},{"id":"cd407dbc.6a09","type":"change","z":"b1d09add.6b04a8","name":"timeout","rules":[{"t":"set","p":"timeout","pt":"msg","to":"6.1234567","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":380,"wires":[["7dd3409d.0daae"]]},{"id":"559dcc7d.65e6f4","type":"debug","z":"b1d09add.6b04a8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":710,"y":380,"wires":[]}]

image

Pause?

What's your recommended method of pausing? The 'restarting' obviously can (essentially) become a new timer with the value of the timer when it stopped, but 'stop' setting payload to 0 seems a little counterintuitive to me.

Would you consider 'Stop' retain the payload for restarting, feeding that payload value back in to the node again upon a trigger? Alternatively, would you consider a "pause" action? Would be nicer than needing to maintain my own state of the timer external to the timeout node.

Otherwise Stop and Cancel are essentially the same, just one notifies you about it (on the first output), and the other doesn't.

Inject json to override default values. Odd behavior.

Hi. I'm not sure if I'm doing something wrong but I can't seem to pass the msg directly out of the function node from your example, into the mytimeout timer and have it read the override values correctly. It keeps using the default values.

However if I pass the output of the function through a JSON node and then into mytimeout node, it works.

I couldn't figure this out for a while as your example looks like its passing the function output directly to the mytimeout node.

Is this expected?

Thank you!

This is not working:
https://hastebin.com/nibefacore.json
I pass directly out of function to mytimeout

This is working:
https://hastebin.com/geciwoduka.json
I pass through json node and then to mytimeout

ps: There is a small typo on the info page inside NR.

screen shot 2018-08-20 at 11 11 58 am

Output Topic - not coming out

Hi ,
I'm using your timer for many flows. I had not used the "Output topic" before but in my current flow it does not come to the output and I have to set the "topic" manually. A debug-node was showing empty Topic content.
I'm using your latest version and the node node-red-contrib-simple-gate

image

[{"id":"49c07f1b.63b48","type":"gate","z":"ebaeea0a.a6df68","name":"","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","x":650,"y":240,"wires":[["3bccad86.0811b2","9d9fed9b.0875f"]]},{"id":"9d9fed9b.0875f","type":"mytimeout","z":"ebaeea0a.a6df68","name":"outage","outtopic":"control","outsafe":"close","outwarning":"","outunsafe":"Open","warning":"5","timer":"3600","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":630,"y":180,"wires":[["2864c9f4.bd6b66"],[]]},{"id":"2864c9f4.bd6b66","type":"change","z":"ebaeea0a.a6df68","name":"ctrl","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":180,"wires":[["49c07f1b.63b48"]]},{"id":"3bccad86.0811b2","type":"function","z":"ebaeea0a.a6df68","name":"Set temp","func":"var temp1 = parseInt(msg.payload.tempc);\nvar speed = parseInt((msg.payload.windspeed)*3.6);\nmsg.payload.tempc = temp1;\nmsg.payload.windspeed = speed;\nreturn (msg);","outputs":1,"noerr":0,"x":810,"y":240,"wires":[["791b24dd.eb735c"]]}]

Topic Using Mustache

Is it possible to allow mustache format in the setup of the node, such as setting the topic to be {{msg.topic}} and it would take the input topic and set the outgoing msg topic? Ideally this would apply to all input variables.

Should I pass in a JSON string or a javascript object?

The documentation says that we can pass in JSON containing attributes such as payload and timeout. Does this actually mean that I have to construct a JSON string containing the structure or should it be a javascript object containing the values?

stop or cancel not working

Version [email protected]
When I send the following payload when a timer is already started , the countdown freeze and does not send a cancel payload
{
"payload": "cancel"
}

Also your documentation is wrong its 'timer' instead of 'timeoute'

Thanks for your job

The workspace contains some nodes that are not properly configured ...

I've noticed another minor issue with an error message that pops up on deploy of the new timers.

"The workspace contains some nodes that are not properly configured: ... are you sure you want to deploy."

You can deploy it's harmless and I have a manual fix but I need to figure out how to word it.

This has to do with my change from a text box to a checkbox. I'm trying to work on a solution so we don't need the manual steps.

How to set timeout value dynamically ?

Hi Neil,

In order to optimize and simplify my workflow drastically, I would like to put in the timeout value as part of the payload. I have tried multiple combinations, but I always get a NaN when I start the timer.

I fear the mytimer is unable to accept its timeoute/timeout/timer value from the incoming payload.

Given following example workflow, can you change the switch so the timer can be set to either input value ?

Thanks,
Tran

[{"id":"183764d3.7dc30b","type":"mytimeout","z":"fd7a7f8d.a9edc","name":"","outtopic":"","outsafe":"ON","outwarning":"OFF","outunsafe":"OFF","warning":"1","timer":"","limit":"","repeat":false,"again":false,"x":530,"y":200,"wires":[["a8a646f4.6becc8"]]},{"id":"f0ec29f6.98bf78","type":"inject","z":"fd7a7f8d.a9edc","name":"","topic":"","payload":"30","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":180,"wires":[["cbdc8a80.4524d8"]]},{"id":"8c7644a0.242c38","type":"inject","z":"fd7a7f8d.a9edc","name":"","topic":"","payload":"60","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":220,"wires":[["cbdc8a80.4524d8"]]},{"id":"cbdc8a80.4524d8","type":"change","z":"fd7a7f8d.a9edc","name":"","rules":[{"t":"set","p":"timeoute","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":200,"wires":[["183764d3.7dc30b","a532595b.a40a88"]]},{"id":"a8a646f4.6becc8","type":"debug","z":"fd7a7f8d.a9edc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":730,"y":200,"wires":[]},{"id":"a532595b.a40a88","type":"debug","z":"fd7a7f8d.a9edc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":530,"y":260,"wires":[]}]

Tick interval

I think it would be great if we can setup tick interval value in node settings?

First countdown msg is a string !

Hello,
I get a strange behavior, on second output for the countdown the first sent msg is a string then all next are number than expected. Below a debug log, for a timeout of 600s.
It’s not a big issue, just the first value are not displayed on the dashboard.
Thank you

18.07.2019 à 15:06:13node: MyTimeout
msg.payload : string[3]
"600"
18.07.2019 à 15:06:13node: MyTimeout
msg.payload : number
599
—-> all next output are number format

Timer stop counting down occasionally

Hi I have changed all my timers to your mytimeout timer, and it usually works perfectly.

Frequently , the countdown stops counting down (still showing Running: 45). I had established debug pointers before and after the timer but there was no event/trigger to halt the countdown... it just stopped

Below is a code component I use to trigger my lights and keep them running for period of time.

[{"id":"72b956bb.e1eac8","type":"link in","z":"e9a592e9.83a77","name":"Light GW","links":["d7f70ea2.d4ba7","8ae0c979.c11a78"],"x":75,"y":760,"wires":[["b519e69a.1ea468"]]},{"id":"b519e69a.1ea468","type":"change","z":"e9a592e9.83a77","name":"GW light","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"data\":{\"entity_id\":\"light.gateway_light_f0b4299aaf29\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":220,"y":760,"wires":[["cfec39ae.d15d08"]]},{"id":"cfec39ae.d15d08","type":"api-call-service","z":"e9a592e9.83a77","name":"Light ON","server":"8ad970d8.e2b73","service_domain":"light","service":"turn_on","data":"","mergecontext":"none","x":400,"y":760,"wires":[["a796d525.2bf298","4bd58b26.da5fa4"]],"icon":"node-red-contrib-home-assistant/arrow-right-bold-hexagon-outline.png"},{"id":"a796d525.2bf298","type":"change","z":"e9a592e9.83a77","name":"House Light timer","rules":[{"t":"set","p":"timeout","pt":"msg","to":"House_Light_timer","tot":"global"},{"t":"set","p":"payload","pt":"msg","to":"ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":760,"wires":[["9b5bee98.fe7bb"]]},{"id":"4bd58b26.da5fa4","type":"api-current-state","z":"e9a592e9.83a77","name":"log?","server":"8ad970d8.e2b73","halt_if":"off","override_topic":true,"override_payload":true,"entity_id":"input_boolean.send_telgram_log","x":550,"y":720,"wires":[["683b250f.e1e11c"]]},{"id":"9b5bee98.fe7bb","type":"mytimeout","z":"e9a592e9.83a77","name":"timer","outtopic":"","outsafe":"on","outwarning":"Warning","outunsafe":"off","warning":"5","timer":"30","repeat":false,"again":false,"x":870,"y":760,"wires":[["4ed02376.34a5ec"],[]]},{"id":"77970856.b76e08","type":"link in","z":"e9a592e9.83a77","name":"Light GW off","links":[],"x":435,"y":720,"wires":[["a796d525.2bf298"]]},{"id":"683b250f.e1e11c","type":"change","z":"e9a592e9.83a77","name":"Telegram","rules":[{"t":"set","p":"myMessage","pt":"global","to":"Hallway light ==> ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":720,"wires":[["3d105a9e.82e406"]]},{"id":"4ed02376.34a5ec","type":"switch","z":"e9a592e9.83a77","name":"off ?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1010,"y":760,"wires":[["a952e4aa.bb1868"]]},{"id":"2e8c5de5.fa5362","type":"change","z":"e9a592e9.83a77","name":"off","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":870,"y":720,"wires":[["9b5bee98.fe7bb"]]},{"id":"3d105a9e.82e406","type":"link out","z":"e9a592e9.83a77","name":"Send Msg","links":["ed951e00.620ec"],"x":735,"y":720,"wires":[]},{"id":"a952e4aa.bb1868","type":"change","z":"e9a592e9.83a77","name":"GW light","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"data\":{\"entity_id\":\"light.gateway_light_f0b4299aaf29\"}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1180,"y":760,"wires":[["2b627979.32cfa6"]]},{"id":"161ab6a3.aa1b59","type":"link in","z":"e9a592e9.83a77","name":"Light GW off - now","links":["ed2201a6.5ebd2"],"x":795,"y":720,"wires":[["2e8c5de5.fa5362"]]},{"id":"2b627979.32cfa6","type":"api-call-service","z":"e9a592e9.83a77","name":"Light OFF","server":"8ad970d8.e2b73","service_domain":"light","service":"turn_off","data":"","mergecontext":"none","x":1320,"y":760,"wires":[["2554f049.add85"]],"icon":"node-red-contrib-home-assistant/arrow-right-bold-hexagon-outline.png"},{"id":"2554f049.add85","type":"api-current-state","z":"e9a592e9.83a77","name":"log?","server":"8ad970d8.e2b73","halt_if":"off","override_topic":true,"override_payload":true,"entity_id":"input_boolean.send_telgram_log","x":1450,"y":760,"wires":[["707e1a8b.9a2e64"]]},{"id":"707e1a8b.9a2e64","type":"change","z":"e9a592e9.83a77","name":"Telegram","rules":[{"t":"set","p":"myMessage","pt":"global","to":"Hallway light ==> OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1580,"y":760,"wires":[["b2b43870.523a98"]]},{"id":"b2b43870.523a98","type":"link out","z":"e9a592e9.83a77","name":"Send Msg","links":["ed951e00.620ec"],"x":1675,"y":760,"wires":[]},{"id":"8ad970d8.e2b73","type":"server","z":"","name":"Home Assistant","url":"http://hassio/homeassistant","pass":"2bf95b829c8b4824987dcac37eed662a"}]

Run different instances of timer based on msg.topic

I would like to have a functionality which the original delay node in node-red has, variable delay per message topic which allows us to run multiple instances of the timer based on the msg.topic value passed to the node. I tried doing the same with the mytimeout and new invocations always reset the timer. Would be really nice to keep multiple timers running.

Sample Flow:

[
    {
        "id": "e9c0e6e2.b401f8",
        "type": "mytimeout",
        "z": "d24adb51.bd89f8",
        "name": "",
        "outtopic": "",
        "outsafe": "on",
        "outwarning": "",
        "outunsafe": "off",
        "warning": "5",
        "timer": "30",
        "debug": false,
        "ndebug": false,
        "ignoreCase": false,
        "repeat": false,
        "again": false,
        "x": 1330,
        "y": 220,
        "wires": [
            [
                "28a04c14.1e2fa4"
            ],
            []
        ]
    },
    {
        "id": "37366a80.05b1a6",
        "type": "inject",
        "z": "d24adb51.bd89f8",
        "name": "",
        "topic": "",
        "payload": "{\"payload\":\"on\",\"timeout\":50,\"warning\":30,\"topic\":\"foo\"}",
        "payloadType": "json",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 950,
        "y": 200,
        "wires": [
            [
                "69883483.758bdc"
            ]
        ]
    },
    {
        "id": "28a04c14.1e2fa4",
        "type": "debug",
        "z": "d24adb51.bd89f8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 1540,
        "y": 220,
        "wires": []
    },
    {
        "id": "69f9a286.29315c",
        "type": "inject",
        "z": "d24adb51.bd89f8",
        "name": "",
        "topic": "",
        "payload": "stop",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 1050,
        "y": 320,
        "wires": [
            [
                "e9c0e6e2.b401f8"
            ]
        ]
    },
    {
        "id": "2685c496.bfdf3c",
        "type": "inject",
        "z": "d24adb51.bd89f8",
        "name": "",
        "topic": "",
        "payload": "pause",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 1050,
        "y": 400,
        "wires": [
            [
                "e9c0e6e2.b401f8"
            ]
        ]
    },
    {
        "id": "c665e6ad.370bb8",
        "type": "inject",
        "z": "d24adb51.bd89f8",
        "name": "",
        "topic": "",
        "payload": "{\"payload\":\"on\",\"timeout\":20,\"warning\":10,\"topic\":\"bar\"}",
        "payloadType": "json",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 930,
        "y": 260,
        "wires": [
            [
                "69883483.758bdc"
            ]
        ]
    },
    {
        "id": "69883483.758bdc",
        "type": "change",
        "z": "d24adb51.bd89f8",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "payload.topic",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1120,
        "y": 200,
        "wires": [
            [
                "e9c0e6e2.b401f8"
            ]
        ]
    }
]

strange behaviour, does not turn off , or even turns on instead

I have this system with automatic lights, based on PIR with RF and wall switches with RF .
Timers reset while PIR activity , and when time runs almost out, a warning light starts blinking. Then the lights go off.
That should be the case.
However, the timers do not always send the OFF command.
Sometimes they even send the ON command and not start the timer... so the lights stay on all night.
I am switching to wall light switches with Tasmota and RF soon because of this unreliability.
timersflowexample.json.txt

... edit: I discovered a typo in one of the PIR-RF received data-switches.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.