This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.

The Homey Community has been moved to https://community.athom.com.

This forum is now read-only for archive purposes.
Closed

Flow between two times

I'm probably overlooking something and the search function is not being very helpfull either. I want to create a simple flow that will switch a socket on if it's 17:00 and switch it back off again if it's 23:00. As it looks I'm gonna need two flows for this but I'd like to do this in a single flow to keep things clean.

Comments

  • Maybe it's possible to add a second action card and delay it with 360 minutes?
  • Interesting workaround. I'd like to see a proper solution but will try this.

    Now I'm digging into the flows I run into similar questions. What I seem to miss is some sort of exit criteria. If I compare it with Tasker, a automation plugin for Android, you can trigger a action of a specific event but you can also set a action once the event is no longer valid (for instance, turn on GPS when application Maps is running, once Maps is shut down the GPS is disabled again as well). Would be great to have similar functionality with the Homey Flow™ .
  • UrandayUranday Member
    edited February 2016
    What would work is if you could add a boolean as an imput of a socket.

    if time is 17:00 set LightsOn to true

    if time is 23:00 set LightsOn to false

    if lightson is changed, pass bool value to switch (socket) 

    Then, let the socket turn on on true and turn off on false.

    The big advantage is that you now also can add a button of a remote in a flow

    If button X is pressed flip the bool value of LightsOn (true to false or false to true). 

    (ps, trying to make this)
  • JaapPeltJaapPelt Member
    edited February 2016
    The current way flows are setup has advantages and disadvantages. The main advantage is that it is very easy for new users to manage flows. The main disadvantage is that for the more experienced users, the number of flows become difficult to manage. 

    Some options to better manage flows would be a folder structure to manage flows and have a function to duplicate a flow. I'm sure the developers have some good ideas themselves. So far I'm really impressed at the how the UI works. It's absolutely beautiful. It will take time to further develop flow management features. 

    Uranday: You can use variables. I generally use integer values. 
    As I describe here: https://forum.athom.com/discussion/comment/9606/#Comment_9606 I prefer to separate my "Events" from "Actions".

    Here is an example how to "toggle" the lights and use timers. This example can be easily extended with more "Event triggers". Also, instead of controlling one light, you can set multiple lights to a specific "scene".

    Timer:
    IF time = 19:00 THEN set LightsOn to 1
    IF time = 23:00 THEN set LightsOn to 0

    Remote:
    IF button was pushed AND LightsOn is 0 THEN set LightsOn to 1
    IF button was pushed AND LightsOn is 1 THEN set LightsOn to 0

    Note: you need both flows, one setting 0 to 1 and the other setting 1 to 0.

    Execute Action:
    IF LightsOn changed AND LightsOn = 1 THEN turn lights on
    IF LightsOn changed AND LightsOn = 0 THEN turn lights off


    Simple, Elegant, Beautiful... I love my Homey...

    Bonus feature:
    You can use this pattern to cycle though colors with your remote by using more numbers:
    Remote: 0 -> 1, 1 -> 2, 2 -> 3, 3 -> 0
    Execute action: 0 = off, 1 = red, 2 = green, 3 = blue.
    The possibilities are endless. 
  • Nice example Jaap, I already read your suggestion a couple of days ago and had the intention to do a similar setup. I guess I have to accept that the number of flows will increase rapidly.
  • PhuturistPhuturist Member
    edited February 2016
    @JaapPelt  I'm using a setup similar to your example above but I'm experiencing some strange behaviour which might be a bug in the logic cards. Perhaps you can confirm this out of your own experiences.

    I have multiple "Timer" and "Execute" flows based on different variables. For instance:
    1.  a timer flow set at 23:00 that sets a variable "lightsOff" and a trigger flow that listens to this variable and actually turns the light off.
    2.  a timer flow set at 23:30 that sets a variable "mediaOff" and a trigger flow that listens to this variable and actually turns all media equipment off (through it's sockets).

    What I'm experiencing is that the execute flow that listens to the variable "mediaOff" gets triggers when the variable "lightsOff" is changed. So at 23:00 both my lights and media is switched off. I have gone over my flows a couple of times and all looks to be configured correctly, so seems like a bug to me. Can you perhaps confirm this?
  • @Phuturist I've seen the same behaviour with 2 variables. Didn't test it fully yet to have any conclusions if this is a bug or an error on my end. 
  • @Phuturist ; I'm also having some trouble with this. Haven't had the time to find the case. I have done some tests with triggers on changing variables andere it works fine. 

    Perhaps Homey prevents changing a variabele which is also A trigger to preventief infinate loops. 

    I will let you all know een I have a full pattern working.
  • TheoDeKoningTheoDeKoning Member
    edited February 2016
    With a remote and 6 flow I can confirm that it is indeed not working this way.
    The variable lightsOff and mediaOff set and reset each other.

    Edit
    If I make lightsOff 5 instead of 1 mediaOff become also 5.
  • TheoDeKoningTheoDeKoning Member
    edited February 2016
    This way you can hear what the value is.

  • EmileEmile Administrator, Athom
    Oops, that trigger is indeed always fired. I've fixed it, will be included in 0.8.20.
  • Emile said:
    Oops, that trigger is indeed always fired. I've fixed it, will be included in 0.8.20.
    Thanx Emile, do you still want me to report it on github so it can be assigned to this milestone?
  • And do I have to put my 6 flows also over to github?
  • EmileEmile Administrator, Athom
    Nah it's okay :-)
  • is there a way to put the lights on 45 minutes before sunset, there is only a trigger for sunset.
  • Direct trigger on a sun event is not working yet properly. 
    https://github.com/athombv/homey/issues/182




  • Uranday: You can use variables. I generally use integer values. 
    As I describe here: https://forum.athom.com/discussion/comment/9606/#Comment_9606 I prefer to separate my "Events" from "Actions".

    Here is an example how to "toggle" the lights and use timers. This example can be easily extended with more "Event triggers". Also, instead of controlling one light, you can set multiple lights to a specific "scene".

    Timer:
    IF time = 19:00 THEN set LightsOn to 1
    IF time = 23:00 THEN set LightsOn to 0

    Remote:
    IF button was pushed AND LightsOn is 0 THEN set LightsOn to 1
    IF button was pushed AND LightsOn is 1 THEN set LightsOn to 0

    Note: you need both flows, one setting 0 to 1 and the other setting 1 to 0.

    Execute Action:
    IF LightsOn changed AND LightsOn = 1 THEN turn lights on
    IF LightsOn changed AND LightsOn = 0 THEN turn lights off


    Simple, Elegant, Beautiful... I love my Homey...

    Ok, I don't have a Homey, so cannot test this... but suppose LightsOn = 0 and somebody pushes the button on the remote.

    IF button was pushed AND LightsOn is 0 THEN set LightsOn to 1
    IF button was pushed AND LightsOn is 1 THEN set LightsOn to 0
    Wouldn't your Remote Actions run both, switching LightOn to 1 (first line), then to 0 again in the second line?

    I would change the remote to:
    IF button was pushed THEN set LightsOn to 1-LightsOn

    or, in the multiple colorcycling version (say: LightsOn 0,1,2, or 3):

    Set LightsOn to LightsOn+1
    IF LightsOn > 3 THEN set LightsOn  to 0


  • @batteries4ever : Excellent suggestion. I tried to configure it, but Emile told me math on variables is not yet supported until 0.8.19.

    Also, I noticed that a KaKu remote triggered the flow twice. The "variable changed" flow is however only triggered once. This seems to be a nice feature to prevent infinite loops.
  • edited February 2016
    Hi Jaap, sounds like we could have some fun figuring out the exact  syntax rules of this!
    Toobad that Homey takes so long to process speech, otherwise I was going to build an English butler (Jeeves) with some random functions and quite a bit of conversation.

    Such as "Jeeves, I am going to sleep"
    "Very well Sir, I will switch off the lights in the living as soon as you left" "Wake up at (+8 hours)?" You have your first appointment with Mrs. So and So at 10:00, but it will take an estimated 3 hours by car or 4 hours by train. Also their is construction work going on and local freezing may cause additional delays" " May I wish you a pleasant night, Sir?"
    etc. etc.
This discussion has been closed.