Problems with Harmony Based Automations

Hi,

I’m trying to base some automations on some really simple harmony logic (basically state trigger from ‘on’ to ‘off’ and ‘off’ to ‘on’). For some reason this just won’t work.

The two automations in question basically follow the same format as the following, the only difference being ‘on’ to ‘off’ and the lights should turn on in that case. Note that I can just run the automation and it controls the light fine, so it has to be in the trigger or condition.

I also see the state transition for the remote within States in Developer Tools when I use it, so it feels like it should work, but no dice.

I’m running v0.89.1.

- id: '1546658220023'                                                           
  alias: Turn Off Lights When TV On                                             
  trigger:                                                                      
  - entity_id: remote.family_room                                               
    from: 'off'                                                                 
    platform: state                                                             
    to: 'on'                                                                    
  condition:                                                                    
  - after: '20:00:00'                                                           
    before: 06:00:00                                                            
    condition: time                                                             
  action:                                                                       
  - alias: ''                                                                   
    data: {}                                                                    
    entity_id:                                                                  
    - light.kitchen_main_lights                                                 
    - light.kitchen_table_lights                                                
    - light.front_foyer_main_lights                                             
    service: light.turn_off

Your before condition is missing the commas before and after. Not sure if that is causing the issue.

I’m not sure if the order of things matter either. In your condition, you have condition: time at the end. All examples I have seen have that line at the top of the condition. Same with your trigger and platform: state.

In action, you don’t need alias: '' (Not sure what this does, never seen it in action) or data: {} as you are just turning the lights on/off.

I think you mean quotes?

This doesn’t matter, it’s a product of using the automation builder inside the GUI

Also, doesn’t matter. More byproduct of the automation builder.

@phrique

@cjsimmons is correct about your missing quotes on the before: 06 line. That is most likely your problem:

- id: '1546658220023'                                                           
  alias: Turn Off Lights When TV On                                             
  trigger:                                                                      
  - entity_id: remote.family_room                                               
    from: 'off'                                                                 
    platform: state                                                             
    to: 'on'                                                                    
  condition:                                                                    
  - after: '20:00:00'                                                           
    before: '06:00:00'                                                    
    condition: time                                                             
  action:                                                                       
  - alias: ''                                                                   
    data: {}                                                                    
    entity_id:                                                                  
    - light.kitchen_main_lights                                                 
    - light.kitchen_table_lights                                                
    - light.front_foyer_main_lights                                             
    service: light.turn_off

LOL Yes, I had a mind blank moment and couldn’t think of the exact word…

I thought this might be the case, but I just wasn’t 100% sure and not sure if the order makes a difference. Learnt something new.:smiley:

1 Like

Cool, I’m going to try adding the quotes. Will follow up with results!

Ok, so fun times. I think the actual problem is in the reloading of automations, but I’m not 100% sure at this point. Here’s why:

  1. I tried just adding the quotes around the time, no dice, didn’t fix it.
  2. I then just removed the time constraint all together to verify that it wasn’t just something with the condition, still didn’t work.
  3. I then tried just reordering to make it more legible/intelligible, like @cjsimmons recommended, still didn’t work.
  4. I then, as a lark, thought, “Well, maybe this just isn’t reloading properly, so I’ll change the name and then reload it so I can verify that it reloaded through the UI.” Well, then it started working.
  5. I had already re-ordered the other similar automation to make it easier to see what’s happening, but basically the same thing occurred; the automation didn’t start working until I changed the name. It’s almost like it just wasn’t reloading.

Not sure if anyone has ever seen anything similar.

Are you restarting home assistant? Or just reloading automations?

Just reloading automations.

That may or may not work all the time. Better off restarting.

Cool, good to know for future reference, thanks @petro