Home next hub speech when I return home

Hi all, i’d like my home next hub say something when I came into home.
I have a door sensor.
I’d like it to speak when i open the door and for example my wifi is connected form few seconds and the track of my phone is changed from not_home to home from few minutes.

Anyone can help me?

The first things to check are:

  1. Is that a Nest Home Hub? If so is it already connected to Home Assistant?
  2. Do you already have presence detection set up for your phone?
  3. Is the door sensor already integrated in Home Assistant?

Yes I have all set

Then you want something like this:

automation:
- alias: "Welcome home"
  trigger:
  # Front door opens
  - platform: state
    entity_id: binary_sensor.front_door
    to: 'on'
  condition:
  # You are home
  - condition: state
    entity_id: person.zola
    state: 'home'
  # But only became home in the last two minutes
  - condition: template
    value_template: >-
      {{ ((now() - states.person.zola.last_changed).seconds < 120 ) }}
  action:
  - service: tts.cloud_say
    data:
      entity_id: media_player.whatever
      message: "Welcome home"

You’ll need to update all the entities in there to reflect your own. This also won’t cause a Welcome home if you aren’t home when the front door opens. Handling that is another step.

Thanks sorry but it will trigger also if i’m at home from for example one hour and I open the door…
Is there the possibility to check the change from not_home to home in the last few minutes?
Thanks

or if the wifi connection is changed from not connected to connected in the last few seconds?

It requires that the state of person.zola is both home and changed state in the last two minutes. You can’t check the historical state.

Depends on whether that made it something other than home - you need to investigate that.

The best thing to do is to try it. If it works, you’re done. If it doesn’t then you have a starting point for improvements.

i tried and if I came out the home nest speaks… so it’s not my goal

What did you try?

Without seeing your automation (use either a code share site or code markup) it’s hard to know what’s going on…

‘’’

  • id: ‘1620554892604’
    alias: Messaggio arrivo casa Ale
    description: ‘’
    trigger:
    • type: opened
      platform: device
      device_id: 231e46a0ea1741c1b091ace46aa59a79
      entity_id: binary_sensor.door_window_sensor_158d00033a9289
      domain: binary_sensor
      condition:
    • condition: state
      entity_id: person.ale
      state: home
      for: 00:02:00
      action:
    • service: tts.google_say
      data:
      entity_id: media_player.nesthub
      message: Ciao ben arrivato Alessandro
      ‘’’

Wrong ticks for code markup

- id: '1620554892604'
  alias: Messaggio arrivo casa Ale
  description: ''
  trigger:
  - type: opened
    platform: device
    device_id: 231e46a0ea1741c1b091ace46aa59a79
    entity_id: binary_sensor.door_window_sensor_158d00033a9289
    domain: binary_sensor
  condition:
  - condition: state
    entity_id: person.ale
    state: home
    for: 00:02:00
  action:
  - service: tts.google_say
    data:
      entity_id: media_player.nesthub
      message: Ciao ben arrivato Alessandro

That will run only if you’ve been home for two minutes already. That’s not what I gave you :wink:

So sorry…changed I’ll try
Thanks

You need both conditions I shared, not just one of them

I have this error

Error evaluating condition in ‘Messaggio arrivo casa Ale’: In ‘condition’ (item 2 of 2): In ‘template’ condition: UndefinedError: ‘None’ has no attribute ‘last_changed’

Please share the current automation, using code markup, so we can help you

- id: '1620554892604'
  alias: Messaggio arrivo casa Ale
  description: ''
  trigger:
  - type: opened
    platform: device
    device_id: 231e46a0ea1741c1b091ace46aa59a79
    entity_id: binary_sensor.door_window_sensor_158d00033a9289
    domain: binary_sensor
  condition:
  - condition: state
    entity_id: person.ale
    state: home
  - condition: template
    value_template: '{{ ((now() - states.person.zola.last_changed).seconds < 180 )
      }}'
  action:
  - service: tts.google_say
    data:
      entity_id: media_player.nesthub
      message: Ciao ben arrivato Alessandro
  - service: notify.apertura_porta
    data:
      message: Ale è entrato in casa
      title: Cambio stato porta di casa
  mode: single

Does person.zola exist?

From what you have in the line above it should be person.ale

yes person.ale exists

:joy: :joy: :joy:

Sorry…understand the error…I fixed it…I’ll check if now it works…