Event Sunrise / Sunset not working

All,

for some reason I don’t get my automations running with the Sunset/Sunrise event…
Below my code…
I Don’t fully get what I am doing wrong here…
Should I change it to state change (from - to)

- alias: "Shutters Closed - At Sunrise"
  initial_state: true
  hide_entity: true
  trigger:
    - platform: sun
      event: sunset
  condition:
    - condition: or
      conditions:
    - condition: state
      entity_id: input_select.dieter_status
      state: 'Home'
    - condition: state
      entity_id: input_select.dieter_status
      state: 'Away'
    - condition: state
      entity_id: input_select.dieter_status
      state: 'Vacation'
  action:
    - service: cover.close_cover
      data: 
        entity_id: cover.master_shutter_154
    - delay: 00:00:20
    - service: cover.close_cover
      data: 
        entity_id: cover.dressing_shutter_155
    - delay: 00:00:20
    - service: cover.close_cover
      data: 
        entity_id: cover.guest_shutter_153
    - delay: 00:00:20
    - service: cover.close_cover
      data: 
        entity_id: cover.bath_shutter_152

Do you have the sun component loaded? Does your states page include sun.sun?

yes, I have the sun component loaded into my configuration.yaml file.
Do I need to place it somewhere else too?

Your indentation is wrong for your conditions. This is what it should look like.

  condition:
    - condition: or
      conditions:
        - condition: state
          entity_id: input_select.dieter_status
          state: 'Home'
        - condition: state
          entity_id: input_select.dieter_status
          state: 'Away'
        - condition: state
          entity_id: input_select.dieter_status
          state: 'Vacation'

Personally, I dislike these nested conditions because the yaml is confusing and verbose. If you were interested, you could try using a template which would shorten it up. But then you might need to learn some jinja2.

  condition:
    - condition: template
      value_template: "{{ states('input_select.dieter_status') in ['Home','Away','Vacation'] }}"
2 Likes

How can I have overlooked this!
Thanks!

I don’t know if that will fix the automation outright, it’s the only thing I noticed immediately.

I hope it does :slight_smile:
I will see tomorrow morning :slight_smile:

I checked all my other automations, just to be sure - looks like this one I messed up with the indentations…

Then hopefully it works! By the way, i’m curious as to why you even have that condition? Do you have other modes for that input_select?

yes,
I have:

  • Sleeping
  • Home
  • Away
  • Vacation

I am the only one resident in the house, so I linked it to my name.
I will change it once I am happy with all my automations to a “group” base.
(will be a group of one person though, but will be easier in the long run if I need to add somebody to the household)

Ah ok, I was just wondering if there was a way to make it easier to manage.

Petro,
Is there a way to “block” Input Selections from being changed?
Basically I would like to make a kind of “Media Center Page”
TV On/Off
HDMI Selection (1=TV Decoder / 2=Kodi / 3=…)
Channel Selection

I would like to block changes on HDMI Selection and Channel Selection if the TV is not on.

Hmmm, you could do that with lovelace but it you’d need to create input_selects based on context. Then use a conditional card to show the correct input_select. Other than that, I don’t think you can dynamically hide/change input_select options when HA is up and running.

would it be possible to store the previous value and then just overwrite the selected values if the conditions aren’t met?

Petro,
FYI, My Shutters are working now :slight_smile:
Thanks!

1 Like