node-red-contrib-schedex icon indicating copy to clipboard operation
node-red-contrib-schedex copied to clipboard

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

Open JohnAndrewPurio opened this issue 3 years ago • 1 comments

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;

JohnAndrewPurio avatar Nov 02 '21 11:11 JohnAndrewPurio

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.

biddster avatar Nov 05 '21 21:11 biddster