Automations not triggered maybe for my errors

I have these two animations fro notify me when someone is at home or nobody at home, but maybe for my errors it is not working as expected…
Can somebody help me to find where is the problem?

- alias: 'Set non a Casa'
  condition:
    condition: state
    entity_id: input_boolean.mauhome
    state: 'on'
  trigger:
    platform: state
    entity_id: group.famiglia
    to: 'not_home' 
    for:
      minutes: 2
  action:
    - service: homeassistant.turn_off
      entity_id: input_boolean.mauhome
    - service: telegram_bot.send_message
      data_template:
        target: "{{ trigger.event.data.user_id }}"
        message: "Nessuno a casa."

- alias: 'Set a Casa'
  condition:
    condition: state
    entity_id: input_boolean.mauhome
    state: 'off'
  trigger:
    platform: state
    entity_id: group.famiglia
    to: 'home'  
  action:
    - service: homeassistant.turn_on
      entity_id: input_boolean.mauhome
    - service: telegram_bot.send_message
      data_template:
        target: "{{ trigger.event.data.user_id }}"
        message: "Qualcuno a casa."

“{{ trigger.event.data.user_id }}”

You’re not using event triggers, you’re using state triggers, so that template will never be populated.

But that aside, what do you mean by ‘not working’?

I don’t receive any notification to telegram, so i don’t know when out of home if that automation is working or not…
Can you please correct it?

But does it switch the boolean on and off correctly?

Yes, it seems so… but no notification…

OK, when you set up your telegram bot did you also set up a notify entry? Something like:

telegram_bot:
  platform: polling
  api_key: !secret telegram_bot_api_key
  parse_mode: html
  allowed_chat_ids:
    - 11111
    - 22222

notify:
  - platform: telegram
    name: maurizio
    chat_id: 111111

  - platform: telegram
    name: mrs_maurizio
    chat_id: 22222

Yes, correct…

Excellent, the action parts of your two automations should be like this…

  action:
    - service: homeassistant.turn_on
      entity_id: input_boolean.mauhome
    - service: notify.YOUR_TELEGRAM_NAME
      data:
        message: "Qualcuno a casa."
1 Like

Thanks a lot… you are my GURU ! :grinning:

1 Like

That’s another slogan for a tee-shirt that they’ll all be wearing in the future :stuck_out_tongue_winking_eye:

1 Like

I’d like to be the first…

1 Like