freakent / node-red-contrib-sunevents

A node for node-red that generates events based on the position of the Sun at the appropriate time of day.
Apache License 2.0
15 stars 13 forks source link

Problem turning off lights #16

Closed backnblack69 closed 3 years ago

backnblack69 commented 3 years ago

Is it possible to post your flow for turning off lights? I seem to be having an issue turning off my lights, turning on seems ok. This is 99.9% my problem i'm sure, not your code. I take the sun-events and pipe it thru a switch to turn on at sunset, off at sunrise. I'm using hue so the hue node wants msg.payload.on: false (or true) with msg.payload.brightness set also. If i just run the switch output to a change node to setup the hue payload i get payload not an object so I have to also set up front msg.payload to json {} {} first then it seems to pass the payload ok to hue. Since sun-events only fires events at the event time it takes hours to troubleshoot. I added an inject node to simulate msg.payload of sunset but that doesn't' work at all, It just turns lights on again. Reading your docs your just setting msg.payload to sunset for instance, my inject node is doing the same thing unless I'm just missing a concept here. Thanks for your time.

freakent commented 3 years ago

This is my flow. image

You might notice I don't use suncalc to turn off my lights. Our lights go on at sunset then switch of just after the late night TV news ! So I use a timer to turn off my lights. image

You might also notice I push all my events into a persistent topic in MQQT so that if Raspberry Pi is rebooted the current state is maintained.

backnblack69 commented 3 years ago

I redid alot of what i was doing and its now working great. The main issue i had was my Hue lights (node-red-contrib-huemagic) want to see the payload as true/false so i just did a function to write out what it needs after the switch statement from your sun-events. What i had before was just adding on and brightness to the sun-events message flow, why my lights would not work properly. Thanks for your code. I also just added the events to mqtt

freakent commented 3 years ago

To try the V3 Beta follow the link to this issue:

21 V3 Beta Testers

Thanks!

freakent commented 3 years ago

More example flows in the latest 3.0 release. Feel free to check it out.