Code Monkey home page Code Monkey logo

Comments (10)

jensrossbach avatar jensrossbach commented on July 3, 2024

Hi, can you please give some more details, especially which node you are talking about?

Have you already read the docs? There you can find a lot of information as well as examples.

from node-red-contrib-chronos.

kuradi avatar kuradi commented on July 3, 2024

i have readed all docs but i cant find info suitable for me, maybe you can point me to right direction :)
scheduler node.
image

from node-red-contrib-chronos.

jensrossbach avatar jensrossbach commented on July 3, 2024

Ok, so if I understand you correctly, you want to insert the contents of 'flow.boo' using some kind of templating language? This is not supported by the node, but why don't you just put a change node behind the scheduler node and replace payload by the contents of the flow variable? Or use a template node instead of the change node and pass the template to that node.

from node-red-contrib-chronos.

kuradi avatar kuradi commented on July 3, 2024

i dont want template anything if possible. i have stored ON/OFF commands for each hour and want them pass as payload. i just looked your example at docs https://github.com/jensrossbach/node-red-contrib-chronos/wiki/images/node_scheduler_output_fullmsg_json.png and thougth i can replace hardcoded payload to flow, global etc...
image

from node-red-contrib-chronos.

jensrossbach avatar jensrossbach commented on July 3, 2024

But your example of your initial description seems to be Mustache-like templates (using e.g. {{...}}) and this is not supported by the scheduler node. You can only load a complete schedule from a context variable as described here. In this case one of your context variables should look like this:

// boiler_today_14
{
    "trigger":
    {
        "type": "time",
        "value": "14:00",
        "offset": 0,
        "random": false
    },
    "output":
    {
        "type":  "fullMsg",
        "value":
        {
            "topic": "topic/POWER1",
            "payload": "ON"
        }
    }
}

In your node configuraton, you should then have something like this (just one schedule as example; the configured output is ignored / overridden by the context variable):
image

As already indicated earlier, I see additional alternatives:

  1. Use a change node to replace the msg.payload of the scheduler node output with the content of the flow variable:
[{"id":"68f53a5762cecd74","type":"tab","label":"Using change node","disabled":false,"info":"","env":[]},{"id":"ca4a493c254d90a4","type":"chronos-scheduler","z":"68f53a5762cecd74","name":"","config":"9c6224aade162652","schedule":[{"trigger":{"type":"time","value":"14:00","offset":0,"random":false},"output":{"type":"fullMsg","value":"{\"topic\": \"topic/POWER1\", \"payload\": \"\"}"}}],"multiPort":false,"disabled":false,"outputs":1,"x":270,"y":220,"wires":[["c438c5f3a945c98d"]]},{"id":"c438c5f3a945c98d","type":"change","z":"68f53a5762cecd74","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"boiler_today_14","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":220,"wires":[[]]},{"id":"9c6224aade162652","type":"chronos-config","name":"Home","sunPositions":[]}]
  1. Use a template node to replace the placeholder set in scheduler node by the content of the flow variable:
[{"id":"68f53a5762cecd74","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"ca4a493c254d90a4","type":"chronos-scheduler","z":"68f53a5762cecd74","name":"","config":"9c6224aade162652","schedule":[{"trigger":{"type":"time","value":"14:00","offset":0,"random":false},"output":{"type":"fullMsg","value":"{\"topic\":\"topic/POWER1\",\"template\":\"{{flow.boiler_today_14}}\"}"}}],"multiPort":false,"disabled":false,"outputs":1,"x":270,"y":220,"wires":[["e3855f6589b2456c"]]},{"id":"e3855f6589b2456c","type":"template","z":"68f53a5762cecd74","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"","output":"str","x":430,"y":220,"wires":[[]]},{"id":"9c6224aade162652","type":"chronos-config","name":"Home","sunPositions":[]}]

from node-red-contrib-chronos.

kuradi avatar kuradi commented on July 3, 2024

thanx for your input, appreciate it.
tried both suggestions. i really dont get how should i use change node if stored value and variable changing every hour :( in template node... i have now correct payload, but this solution is not passing topic to mqtt... pls advise.
edit: template still working. so all good for now. but i would love to see in the future possibility to use stored values as i explained.

from node-red-contrib-chronos.

jensrossbach avatar jensrossbach commented on July 3, 2024

Yes, you are right. The template node unfortunately does not passthrough the msg.topic.

Could you maybe provide me a basic flow of what you want to achieve because it is not 100% clear to me how to evaluate the flow variable to be used.

from node-red-contrib-chronos.

kuradi avatar kuradi commented on July 3, 2024

but i got it working, i had just some typo... its working :)
image

trying to explain. we have electricity price which is changing every hour, depending price is low or high system calculates best hours to use for heat etc, i'm storing those values as on/off for every hour. 15.00 "ON", 16.00 "OFF" etc etc....

from node-red-contrib-chronos.

jensrossbach avatar jensrossbach commented on July 3, 2024

Great that it's working now. So what is your conclusion? Do you see this topic solved? If yes, could you please close the issue?

One hint for the future: topics like this here should better be placed into the discussion forum. Issues should only be used for bugs and feature requests.

from node-red-contrib-chronos.

jensrossbach avatar jensrossbach commented on July 3, 2024

@kuradi Please have a look at release 1.16.0 which I published today. Now you can specify the output using a JSONata expression which in fact allows you to include content from context variables.

For instance, taking your example from the beginning of this discussion, you can write something like this:

{
    "topic": "topic/POWER1",
    "payload": $flowContext("boo")
}

from node-red-contrib-chronos.

Related Issues (20)

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.