Unlock door help

Here is my entry but I’m getting errors and cannot figure out to fix this… what am I missing?

Thank you!

- alias: 02 - Unlock Door Upon Arrival Home
  id: Unlock Door Upon Arrival Home

  trigger:
  - platform: state
    entity_id: sensor.ariela_john_wifi # <- this right here only works 40% of the time, is there a better way??
    to: 'NETGEAR32'

  condition:
    condition: state
    entity_id: device_tracker.john_s_galaxy_note20_ultra_5g
    state:  home

  action:
    - service: lock.unlock
      entity_id: lock.front_door_lock

      #  THIS ISN'T working it only gives me errors.  I spent an hour trying to figure this out
      # the errors are:  

#- service: mqtt.publish   
#  data:  
#    topic: "ariela/tts/android_john's_galaxy_note20_ultra_5g_tts/tts"
#    payload: "Hi John, I've noticed you are arriving at home. I'm now unlocking your door."
  
  trigger:
  - platform: sun
    event: sunset
    offset: '+00:30:00'
  
  action:
  - service: light.turn_on
    entity_id:
      - switch.liv1

This is a screen shot of the issues… trust me I have tried everything…

What is the part after the commented out code? This should be a separate automation, you can’t have two triggers and two action parts.

The error tells you exactly what the problem is the indentation is wrong.

action:
    - service: lock.unlock
      entity_id: lock.front_door_lock
    - service: mqtt.publish   
      data:  
        topic: "ariela/tts/android_john's_galaxy_note20_ultra_5g_tts/tts"
        payload: "Hi John, I've noticed you are arriving at home. I'm now unlocking your door."
1 Like

Thank you for the help but when I do that…I get this:

Your indentation is wrong again. The dashes for the two services need to be on the same level.

You need to share your entire automation with us so we can see where the problem is.
In this screenshot:

  • The indentation is wrong again, the - service: mqtt.publish should be in the same column as the service: lock.unlock, that’s what the colors and lines in your core editor are for.
  • As @Burningstone pointed out, an automation can only have one trigger: section. There seems to be something missing before the lower trigger (alias / id of a new automation)

I’d suggest deleting the automation and setting it up via the UI, that takes care of the formatting and doesn’t require you to reload. Once the automation works, you can take a look at the YAML the UI made.

1 Like

The entire entry is at the top of the post :slight_smile:

Well then remove the surplus trigger and action:

- alias: 02 - Unlock Door Upon Arrival Home
  id: Unlock Door Upon Arrival Home

  trigger:
  - platform: state
    entity_id: sensor.ariela_john_wifi # <- this right here only works 40% of the time, is there a better way??
    to: 'NETGEAR32'

  condition:
    condition: state
    entity_id: device_tracker.john_s_galaxy_note20_ultra_5g
    state:  home

  action:
    - service: lock.unlock
      entity_id: lock.front_door_lock
    - service: mqtt.publish   
      data:  
        topic: "ariela/tts/android_john's_galaxy_note20_ultra_5g_tts/tts"
        payload: "Hi John, I've noticed you are arriving at home. I'm now unlocking your door."

Take a look at the code I posted and then take a look at your code, do you see the difference? My services are aligned, indentation matters in YAML.

Thank you guys for ALL your help!!! Here’s is what I have and no errors now :slight_smile:

- alias: 02 - Unlock Door Upon Arrival Home
  id: Unlock Door Upon Arrival Home

  trigger:
  - platform: state
    entity_id: sensor.ariela_john_wifi # <- this right here only works 40% of the time, is there a better way??
    to: 'NETGEAR32'

  condition:
    condition: state
    entity_id: device_tracker.john_s_galaxy_note20_ultra_5g
    state:  home

  action:
    - service: lock.unlock
      entity_id: lock.front_door_lock

    - service: mqtt.publish
      data:
        topic: "ariela/tts/android_john's_galaxy_note20_ultra_5g_tts/tts"
        payload: "Hi John, I've noticed you are arriving at home. I'm now unlocking your door."
  
  trigger:
  - platform: sun
    event: sunset
    offset: '+00:30:00'
  
  action:
  - service: light.turn_on
    entity_id:
      - switch.liv1

That’s not possible that you don’t have any errors, again, you can’t have 2 triggers and 2 actions in one automation. This whole part belongs in a separate automaiton:

trigger:
  - platform: sun
    event: sunset
    offset: '+00:30:00'
  
  action:
  - service: light.turn_on
    entity_id:
      - switch.liv1

Yes I agree I should be using the UI… I will go now and look at that and make a ‘test’ automation!

Again Thank you guys very much!!!

I’ve gone ahead and checked it with my setup, seems like the Configuration validation doesn’t care if there are duplicated triggers and actions, however reloading that will cause errors…

I will go look at the UI and start over :slight_smile:

I haven’t reloaded and won’t until I go check this out…by 1st deleting the additional trigger and action.

I have marked the issues and now you’re right there are NO errors. I will just run with this until I can find out how to do this the right way! No sense messing things up!! LOL