biddster / node-red-contrib-schedex

Scheduler for node-red which allows you to enter on/off times as 24hr clock (e.g. 01:10) or suncalc events (e.g. goldenHour). It also allows you to offset times and randomise the time within the offset.
22 stars 17 forks source link

Is it possible to pass the location coordinates as a payload to dynamically change the location? #92

Open JohnAndrewPurio opened 2 years ago

JohnAndrewPurio commented 2 years ago

I'm trying to change the location for sunrise and sunset events depending on the user's location. I've tried setting the latitude and longitude to empty values but the sunrise and sunset event is being based on UTC so now I'm trying to pass the latitude and longitude values inside the payload but it is not working on my end.

Here's a snippet of my function node with the input payload for the schedex node with a latitude and longitude included for a country on UTC+8:

const ontime = 'sunsetStart'
const offtime = 'sunset'

const onpayload = 'The sun is starting to set'

const offpayload = 'The sun has set'

const onoffset = 0
const offoffset = 0

const day_selected = {
    mon: true,
    tue: true,
    wed: true,
    thu: true,
    fri: true,
    sat: true,
    sun: true
}

const latitude = 12.8797207
const longitude = 121.7740173

const schedex_input = {
    ontime, 
    offtime, 
    onpayload, 
    offpayload,
    onoffset,
    offoffset,
    day_selected,
    latitude,
    longitude
}

msg.payload = schedex_input

return msg;
biddster commented 2 years ago

You can do this by setting lat and lon on your schedex_input object.

It's an omission in the docs. Leave this open so I make sure to update the docs.