Cronplus node, location as an environment or context variable

Hi there,

I would like to assign an environment or context variable to the location in solar events mode.
Having had no success with it myself so far, I need your help. Can anyone tell me if that is possible? An example would be nice.

Thanks

Hello ..

this can achieved by sending a command to Cronplus to create a dynamic schedule.
With the use of a Function node you can pick up the environment variables (with the location information) and construct the add command for the cronplus schedule.

Based on the example in the cronplus Help tab :

let longitude = env.get("longitude")  // or  flow.get("longitude")
let latitude = env.get("latitude")

msg.payload = {
  "command": "add",
  "name": "alarm1",
  "expressionType": "solar",
  "solarType": "selected",
  "solarEvents": "civilDawn,sunrise,sunset",
  "location": `${longitude} ${latitude}`,
  "offset": "-60",
  "payloadType": "str",
  "payload": "In 60 mins, it will be a great time to take photographs",
  "limit": null
}

return msg;

image

Example Flow

[{"id":"a19651639c4f34d0","type":"inject","z":"54efb553244c241f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":260,"y":1200,"wires":[["4b72bfadd34ef45e"]]},{"id":"4b72bfadd34ef45e","type":"function","z":"54efb553244c241f","name":"add dynamic schedule","func":"let longitude = env.get(\"longitude\")\nlet latitude = env.get(\"latitude\")\n\n\nmsg.payload = {\n  \"command\": \"add\",\n  \"name\": \"alarm1\",\n  \"expressionType\": \"solar\",\n  \"solarType\": \"selected\",\n  \"solarEvents\": \"civilDawn,sunrise,sunset\",\n  \"location\": `${longitude} ${latitude}`,\n  \"offset\": \"-60\",\n  \"payloadType\": \"str\",\n  \"payload\": \"In 60 mins, it will be a great time to take photographs\",\n  \"limit\": null\n}\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":1200,"wires":[["4a59d86d8f101651","b6a7d932dd04df8f"]]},{"id":"fded7029d539533e","type":"debug","z":"54efb553244c241f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":870,"y":1200,"wires":[]},{"id":"4a59d86d8f101651","type":"cronplus","z":"54efb553244c241f","name":"","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[],"x":640,"y":1200,"wires":[["fded7029d539533e"]]},{"id":"b6a7d932dd04df8f","type":"debug","z":"54efb553244c241f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":640,"y":1100,"wires":[]}]
1 Like

Hi there,
Great! That's exactly what I was looking for.
Thanks very much

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.