Automation with MQTT did not trigger correctly in the first time

Hello there,

I have installed home assistant as a docker container on my Synology DS. In addition runs a mosquitto package (from Synocommunity) on my DS to control my Tasmota devices.
These devices did not appear under MQTT in home assistant, but I can use them (switch them or getting information).
Now I started to automate them. When I test it, it works properly several times in a row. But in the morning or in the evening, when an event is triggert, it did not work…I have no clue why.
The devices are reachable and send information about the wlan stauts to my home assistant all the time.

Code in automations.yaml:

# light off in the morning 
trigger:
  - platform: time
    at: "08:00:00"
action:
  - service: switch.turn_off
    entity_id: 
      - switch.steckdose1
      - switch.steckdose2
      - switch.steckdose3
      
# light on in the evening 
trigger:
  - platform: time
    at: "16:45:00"
action:
  - service: switch.turn_on
    entity_id: 
      - switch.steckdose1
      - switch.steckdose2
      - switch.steckdose3
	  
	  
	  
# Later I want to use
   # - platform: sun
    # event: sunset #Sonnenuntergang
    # offset: '-00:30:00'
#but it did not work...

Do you have any idea what might be the issue?

BR
Axel

Are the automations enabled?

Look in the developer tools states menu. Are the automation states shown as ‘on’.

Hello tom_I,

yes they are on. But I think my trigger combination might be a problem. If I only use the starting or ending trigger it works.

BR

If you have more than one automation in your automations.yaml file you need to supply them as a list, like this:

- alias: 'light off in the morning'
  trigger:
    - platform: time
      at: "08:00:00"
  action:
    - service: switch.turn_off
      entity_id: 
        - switch.steckdose1
        - switch.steckdose2
        - switch.steckdose3
      
- alias: 'light on in the evening'
  trigger:
    - platform: time
      at: "16:45:00"
  action:
    - service: switch.turn_on
      entity_id: 
        - switch.steckdose1
        - switch.steckdose2
        - switch.steckdose3

Sort of like the same way you have listed multiple entity_ids in the actions.

Here we go! Thank you very much!

This should work the same way, am I right?

- alias: 'light off'
  trigger:
    - platform: sun
      event: sunrise #Sonnenaufgang
      offset: '00:30:00'
  action:
    - service: switch.turn_off
      entity_id: 
        - switch.steckdose1
        - switch.steckdose2
        - switch.steckdose3

BR and thank you

No. Not at all. Your indentation is way off.

I have corrected the indentation (copied from a testfile…sry), I love the style of yaml :wink:

Still not right. Action is indented too far. Should be:

- alias: 'light on in the evening'
  trigger:
    - platform: sun
      event: sunset
      offset: '-00:30:00'
  action:
    - service: switch.turn_on
      entity_id: 
      - switch.steckdose1
      - switch.steckdose2
      - switch.steckdose3

Thank you!