Automation works until the next day?

This is an evolution of something that used to work rock solid maybe up until some months ago. Since then, I’ve had to correct more and more things, and unfortunately my understanding of the HA yaml is very weak.
Anyways, this seems to work perfectly, for some period of time. But it always fails before about 12 hours.

Can anyone suggest what’s happening? Or even, what’s a good way to troubleshoot this? Ideally I’d like to log triggers and actions, something like that? Here’s my automation yaml. This works after a restart for some period of time, but then fails by the next day.

thanks for any tips

Since the code block doesn’t seem to work very well here’s a pastebin: http://pastebin.com/7Gv7ZuvT

automation:
  - alias: "Set dim level dusk"
    trigger:
      - platform: time
        after: "18:45:00"   #instantaneously at 8pm only, not 'after'
      - platform: state   #implicit OR betwen the two conditions
        entity_id: light.kitchen
        from: 'off'
        to: 'on'
      - platform: sun
        event: sunset          # can be sunrise
        offset: "-00:30:00"

    condition: 
      condition: and
      conditions:
        - condition: state
          entity_id: light.kitchen
          state: 'on'
        - condition: time    #implicit AND
          after: "18:00:00"
          before: "21:59:00"

    action:
      service: light.turn_on
      entity_id: light.kitchen
      data:
        brightness: 50

  - alias: "Set dim level 10pm"
    trigger:
      - platform: time
        after: "22:00:00"   #instantaneously at 8pm only, not 'after'
      - platform: state   #implicit OR betwen the two conditions
        entity_id: light.kitchen
        from: 'off'
        to: 'on'
#      - platform: sun
#        event: sunset          # can be sunrise
#        offset: "-00:30:00"

    condition: 
      condition: and
      conditions:
        - condition: state
          entity_id: light.kitchen
          state: 'on'
        - condition: time    #implicit AND
          after: "22:00:00"
          before: "23:59:00"

    action:
      service: light.turn_on
      entity_id: light.kitchen
      data:
        brightness: 25

  - alias: "Set dim level midnight"
    trigger:
      - platform: time
        after: "00:01:00"   #instantaneously at 8pm only, not 'after'
      - platform: state   #implicit OR betwen the two conditions
        entity_id: light.kitchen
        from: 'off'
        to: 'on'
#      - platform: sun
#        event: sunset          # can be sunrise
#        offset: "-00:30:00"

    condition: 
      condition: and
      conditions:
        - condition: state
          entity_id: light.kitchen
          state: 'on'
        - condition: time    #implicit AND
          after: "00:01:00"
          before: "05:45:00"

    action:
      service: light.turn_on
      entity_id: light.kitchen
      data:
        brightness: 15




  - alias: "Set dim level daytime"
    trigger:
      - platform: time
        after: "06:30:00"   #instantaneously at 8pm only, not 'after'
      - platform: state   #implicit OR betwen the two conditions
        entity_id: light.kitchen
        from: 'off'
        to: 'on'
#      - platform: sun
#        event: sunset          # can be sunrise
#        offset: "-00:30:00"

    condition: 
      condition: and
      conditions:
        - condition: state
          entity_id: light.kitchen
          state: 'on'
        - condition: time    #implicit AND
          after: "06:30:00"
          before: "16:30:00"

    action:
      service: light.turn_on
      entity_id: light.kitchen
      data:
        brightness: 255


this is unreadable, please post the whole thing in code tags

Sorry about that, I thought I had done it properly. I’ve blockquoted instead of "preformatted text"ed it.
Thanks for pointing that out.

Still unreadable.

And you’ve got several actions there.

Have you worked with your states dev tab to see if these are triggering at all?

Be specific about what’s failing - there’s a lot here.

Ok, I switched to a [ code ] block, maybe that will look OK to you guys. I could see it fine in the block quote.

Everything works just fine. Then after … 12 hours ? it just stops working. Nothing triggers. (Well, nothing happens. I don’t know if it triggers, and I don’t know how to find out.)

ih8gates, I have not, although figuring out whether they have stopped triggering is my first goal. Could you detail how I might do that? I’ve looked the /dev-state page, it’s not obvious to me how to use it to determine whether they are triggering or not.

thanks

Maybe you should paste straight from your configuration. There are lots of indentation issues with your code block - that makes it hard to read and also hard to tell if your issue is that of indenting correctly.

The dev tab will show you the last time that each automation has triggered.

Are you seeing anything useful in your log file?

I’ve repasted straight from putty to a code block, I hope that looks better to you.
No, I’m not seeing a thing thing in the log or I would have mentioned. Each time, the behaviour is the same. If I restart home assistant, everything works as expected. Then at some point, usually the next morning, the automations no longer have any effect.

Here’s what my last triggered times say right now - after a restart sometime yesterday - all dims triggered properly last night through midnight, this morning nothing happens.

friendly_name: Set dim level 10pm
last_triggered: 2016-11-07T06:00:03.092051+00:00
automation.set_dim_level_daytime	on	friendly_name: Set dim level daytime
last_triggered: null
automation.set_dim_level_dusk	on	friendly_name: Set dim level dusk
last_triggered: 2016-11-07T02:45:01.776411+00:00
automation.set_dim_level_midnight	on	friendly_name: Set dim level midnight
last_triggered: 2016-11-07T08:01:01.556577+00:00

This is the typical behaviour we’re seeing. I don’t know whether it’s a straight hours-running issue, or whether this is something to do with executing the other automations, or crossing midnight. What’s certain though is if I reset HASS, everything will work as expected again.

EDIT: I pasted out of gedit through vnc so maybe it’ll look better now.
EDIT2: I see what you mean by some of the spacing now. I don’t know why this is happening. It looks fine in gedit, and in nano. ??? Do you have any suggestions on this?
EDIT3: Ok, I’ve done everything I can think of to fix the output, and I’m still seeing lack of indent on the condition: lines being left justified. But when I press edit, it shows the spaces. Am I using the wrong tags on the forum? I am using [ code ] [/ code].

IGNORE: I’m testing the indentation in blocks.

automation:
  - alias: "Set dim level dusk"
    trigger:
      - platform: time
        after: "18:45:00" 
      - platform: state
        entity_id: light.kitchen
        from: 'off'
        to: 'on'
      -  platform: sun
         event: sunset
         offset: "-00:30:00"

    condition:
      condition: and
      conditions:

^^ I just typed that out and it still mangled the “condition” line. I don’t see how this can be me.

Final edit: It sounds like there may be a bug that presents like this for wink. But if anyone can tell me what I’m doing wrong as far as writing text in code blocks, I would be ecstatic to hear. And if there’s any problems with my code, since that still seems a likely fact, if you can see past this stupid indent on condition: then that would be fantastic too.

thanks

Here’s a pastebin of my automation:
http://pastebin.com/7Gv7ZuvT

Let’s make sure this is doing what you think it’s doing. The first automation (set dim level dusk):

There are three things that will trigger (start) the automation:

  1. The time being 18:45
  2. The kitchen light turning on
  3. The time being 30 minutes before sunset

Any of these things becoming true will START the automation.

The automation will stop unless these conditions are met:

  1. The kitchen light is already on
  2. The time is between 18:00 and 21:59

So if that kitchen light is off, this action won’t complete.

This operates completely the way I want it when it’s working. It operates correctly in every time band configured. It does fail though, if left alone for some period of time - like 8 - 12 hours. A restart of HASS resumes the proper functionality. Let’s ignore the sunset thing because that’s not properly or fully implemented. Otherwise:

If one turns on the lights between TIME BAND the corresponding dim level is set.
If the lights are on at TIME trigger exactly, dim level is set.

In other words, I want dim levels depending on time of day, and I don’t want my lights turning on when I’m not there.

So, in what way is this particular part failing. Do you have the lights on all day, then enter that time band, and they don’t dim correctly? Are you checking to make sure that HASS is aware that the light is on (many Zwave devices don’t report on/off status and depend on Zwave’s polling period). In general, when you turn on the light, HASS may not know it’s on for a while.

It just stops taking any action, whether a time threshold is crossed, or someone turns on a light. If I then restart HASS, functionality resumes properly.

I believe what’s happening is this: https://github.com/home-assistant/home-assistant/issues/3989