Automations rules with conditions

Hi,

I have a doubt about automations in home assistant.

In my case i have an automation that is the motion sensor activate and i’m not at home, send me a notification by telegram and works well

the automation is this one:

    alias: SensorMovComedorCocina
    hide_entity: True
    trigger:
      platform: state
      entity_id: binary_sensor.motion_sensor_15xxxxxxx
      to: 'on'
    condition:
      condition: and
      conditions:
        - condition: state
          entity_id: device_tracker.phone_m
          state: 'not_home'
        - condition: state
          entity_id: device_tracker.xxxxxx
          state: 'not_home'
        - condition: state
          entity_id: input_boolean.limpieza
          state: 'off'
        - condition: state
          entity_id: input_boolean.alarma
          state: 'on'
    action:
      service: notify.telegram
      data_template:
        title: "Sensor Cocina: "
        message: "Activado"

In this automation, i want to add more conditions with other devices, and add this:

alias: SensorMovComedorCocina
hide_entity: True
trigger:
  platform: state
  entity_id: binary_sensor.motion_sensor_15xxxxxxx
  to: 'on'
condition:
  condition: and
  conditions:
    - condition: state
      entity_id: device_tracker.phone_m
      state: 'not_home'
    - condition: state
      entity_id: device_tracker.xxxxx
      state: 'not_home'
    - condition: state
      entity_id: device_tracker.telf_n
      state: 'not_home'
    - condition: state
      entity_id: device_tracker.telf_m
      state: 'not_home'
    - condition: state
      entity_id: input_boolean.limpieza
      state: 'off'
    - condition: state
      entity_id: input_boolean.alarma
      state: 'on'
action:
  service: notify.telegram
  data_template:
    title: "Sensor Cocina: "
    message: "Activado"

But in this case, the automation didn’t worked (not send me the notification by telegram).

I checked and service telegram in HA worked, because i received other notifications, but not this one.

Do you know if the is a limit about conditions in HA like 4 maximum?

There is a possibility to add more conditions? In the case about triggers and action, also the maximum are 4?

thanks,

Any reason not to make a group with all of those, and simply check the group (which will be home as long as at least one member of the group is home)?

Hi,

Any reason not to make a group with all of those, and simply check the group (which will be home as long as at least one member of the group is home)?

Can you explain me in detail about this? con you give me a little example?

because maybe you are right.

I don’t understand exacly, when you say:

(which will be home as long as at least one member of the group is home)

thanks

Groups are documented here. If you create a group of multiple entities that you’re tracking the home/away status of, then the group is home if any member of that group is home. Since you want to know if all devices are away, you can group all of those.

group:
  my_devices:
    entities:
      - device_tracker.phone_m
      - device_tracker.xxxxx
      - device_tracker.telf_n
      - device_tracker.telf_m

Then you just monitor the state of the group:

condition:
  condition: and
  conditions:
    - condition: state
      entity_id: group.my_devices
      state: 'not_home'
    - condition: state
      entity_id: input_boolean.limpieza
      state: 'off'
    - condition: state
      entity_id: input_boolean.alarma
      state: 'on'

Hi @Tinkerer,

First thanks for explanation.

Well in my case i used groups in my HA configuration, but i never thought that is possible to add a group into a condition, so in that case it will be easy to me.

thanks