August Welcome Home Announcement

So I’m sure this is not big deal to many of you but I have been fighting with this to get it just right for a while. Only about 2 weeks into working with HA.

But I was able to get it to when the door operator changes while the door is unlocked, say Welcome Home and only pull in their first name. And if my wife unlocks the door, since she used a nickname it will sat her actual name.

I’m sure there is a better way to write this out, but like I said, I’m new and it works.

- id: '1621462099883'
  alias: Welcome Home
  description: ''
  trigger:
  - platform: state
    entity_id: sensor.main_door_operator
  condition:
  - condition: time
    after: '8:00'
    before: '22:00'
  - condition: device
    device_id: 6c652e113de5451aa323129d81b3b211
    domain: lock
    entity_id: lock.main_door
    type: is_unlocked
  action:
  - condition: template
    value_template: '{{ not is_state(''sensor.main_door_operator'', ''Manual Lock'')
      and not is_state(''sensor.main_door_operator'', ''Manual Unlock'') and not is_state(''sensor.main_door_operator'',
      ''Auto Relock'') and not is_state(''sensor.main_door_operator'', ''One-Touch
      Lock'') }}'
  - service: tts.google_translate_say
    entity_id: media_player.welcome_home
    data:
      message: >
        {% if states('sensor.main_door_operator') == 'XXXXXX' %}
          Welcome home YYYYYYYY
        {% else %}
          Welcome home {{states.sensor.main_door_operator.state.split(' ')[0]}}
        {% endif %}
        
  mode: single
2 Likes