I’m “migrating” over to Homey from Domoticz and Blockly and need help with understanding the logic in Flows, specifically how I can achieve turn on / off lights at sunset / sunrise IF it is between a set time.
Ie in Blockly I had a flow that went
If
Virtual device Night == TRUE
AND Time > 06.00 AND < 08:00
AND Light switch == OFF
Do
Light switch == ON
Meaning by this is that sunrise can occur at 02.00 in the morning and I have no need for it to turn on at 02, I want it to turn on at 06. Equally the other way around, sometimes sunset is at 22.00 in the evening, I do not need it to turn on then.
I tried mimic above with a Homey flow but failed. I setup the experimental Virtual Devices and I tried adding the Better Logic app, but I got so far that I failed on the “AND Light Switch == OFF” in the flow, I could only select “Activated”, or “On” I assume it means, in the And… part of the flow when I selected my dimmer light.
How can I make sure that the flow isn’t firing ON triggers constantly between the hours of 06 and 08?
Or perhaps the logic is just different in Homey… Willing to learn new ways without Virtual Devices if I get pointers in the right direction.
Hi Peter,
there is absolut no need for the Better Logic Library App.
For what is the “Virtual device Night”? How is it defined? Between sunset and sunrise?
I ask, because I think it can also be done by a build in time flow card. For example this one:
Translation:
It’s daytime (or nighttime)
Definition: When it is between dawn and dusk.
@PeterSWE
Very interesting to see how your previous logic works differently.
If I understood you correctly, you want the lights on between 6-8am if its dark.
There is the daytime (invert for nighttime) option, but there is an app Sun events that can do more.
In addition, testing the position of a light switch may sometimes be a solution (use the AND card, select logic and search for the switch, but it may not exist), but in Homey we mostly test the light itself. There usually is a card for that, but you also have the option to use the logic card. Both shown in the below example.
Below two options: one set of flows with a light and one set of flows for a zone that allows you to switch one or more lights.
@Rmb Thanks for the suggestion and example. I was unclear in my previous post, sorry about that. The logic I’m after is that if it is Night and the Time is between 06 and 08 I want the light to turn on, if it is Day time when it is 06 I do not want it to turn on, and if day time happens somewhere in between 06 and 08 I need to be able to turn the light off.
@DirkG Thanks for the welcome to the forum. The virtual device gives me (and which I replicated in Homey but I guess that isn’t the correct way forward) gives me an opportunity to check against if the device is set to ON or OFF. I.e. when sunset happens set Virtual Device Night to ON - I can then check if the Night value equals ON and if Virtual Device Day value equals FALSE (or vice versa).
I saw the “It is after sunrise” as a “And” option (I assume this is the “Day option” mentioned). I tried using that with the trigger of “check every one minute” together with the “time is between 06 and 08” - but then I was back at the issue that my aeotec nano dimmer only has the option of “Is activated / Is turned on”. That would mean that the ON command would be sent 120 times during those 2 hours since I can’t have a check to make sure it isn’t turned on before trying to turning it on. A bit unnecessary… And definitely me being silly and doing it wrong by not understanding Homey’s logic.
@Rrrr Thanks of the excellent response and suggestion. I guess I could fall back to and only trigger it once at a specific time, but I’m still faced with the fact that I cannot do a check if the light is turned off. I have no card for that for my aeotec nano dimmer.
By looking at the suggestions in here I see that perhaps I need to fix that underlying issue first. Might have to create another thread for that.
That needs a little trick, Peter: Select that card “Nano dimmer är på” anyways, and then use the ‘invert’ switch → now the card becomes inverted: is off (är av in Swedish)
I still think your use case is unclear. You want the light on between 6 and 8 when it is dark. But the sun might rise between 6 and 8. So maybe you can think in terms when to switch on the light and when to switch of the light. As every flow starts at an event/trigger. You probably want to switch it on at 6 o’clock when it is still dark (or before sunrise) and then switch it of at sunrise if sunrise is after 6 o’clock.
Use a logic card to test if the light is on, and invert it. So use one flow to switch it on and one flow to switch it off.
Thanks everyone for your valuable input and effort spent. I will try the invert “trick” and use the things I’ve learned in here to try and build something.
Just another hint, i had to come over when i started with homey.
Some of your comments seem to imply that you want something to happen if any of x conditions come true.
This is not possible in homey.
The logic is always that you need a trigger first and then you can add more conditions.
e.g.
in my case i wanted to switch the lights on, if
i’m awake and time is between x and y but not before time z and only if x> sunset
i need multiple flows for that each triggered by another condition
Or you can get a light sensor and use the lux value to turn on/off the lights.
Tried the sunrise sunset approach myself in the beginning, but living up north where sunrise sunset not necessary is on the same day, it just got a bit cumbersome.
I have a lux sensor located in window to read the outdoor brighness, and use that for my outdoor lights, and some indoor lights.