How to use groups in home assistant


Today I’m going to give you some examples of how you can use groups in home assistant.

Groups enable you to interact with multiple entities in one action, these can be used in dashboards to turn on multiple lights, to see the status of all sensors and can be used in automations and scripts. In addition you can also expose these groups to voice assistants.

Groups can be created in the groups.yaml file in my example down below I created a sensor for any motion in the home.

If there is motion anywhere this will be on, only if there is no motion anywhere it will turn off.

groups.yaml

motion:
  name: house_motion
  icon: mdi:motion-sensor
  entities:
    - binary_sensor.hallway_sensor_motion
    - binary_sensor.kitchen_motion
    - binary_sensor.landing_sensor_motion
    - binary_sensor.landing_sensor_2_motion
    - binary_sensor.inspiration_motion

Lights should be grouped under the light domain, let me explain:

In configuration.yaml you can create new lights in the same way you convert switches to lights

In the example below, I’m grouping lights together, in this way you can keep using all of the functions and services around lights (brightness, colour) if your bulbs support them.

light:
  #Light Groups
  - platform: group
    name: Kitchen and Dining Lights
    entities:
      - light.kitchen_downlights
      - light.kitchen_tv_light
      - light.kitchen_under_cupboard
      - light.under_cupboard_lightstrip
      - light.dining_lights
  - platform: group
    name: Hallway Lights
    entities:
      - light.hallway_1
      - light.hallway_2
  - platform: group
    name: Ground Floor Lights
    entities:
      - light.kitchen_and_dining_lights
  - platform: group
    name: Living Room Lights
    entities:
      - light.living_1
      - light.living_2
      - light.lamp_1
      - light.lamp_2
  - platform: group
    name: Inspiration Room Lights
    entities:
      - light.inspiration_light
      - light.imac_lamp
  - platform: group
    name: First Floor Lights
    entities:
      - light.inspiration_room_lights
  - platform: group
    name: Master Bedroom Lights
    entities:
      - light.master_1
      - light.master_2
      - light.master_3
      - light.master_4
  - platform: group
    name: Second Floor Lights
    entities:
      - light.master_bedroom_lights
  - platform: group
    name: Kitchen Lights
    entities:
      - light.kitchen_downlights
      - light.kitchen_tv_light
      - light.kitchen_under_cupboard
      - light.under_cupboard_lightstrip

As you can see I created multiple groups, each group starts from the -platform: group line. You can give a group a name and list all the entities that are part of that group.

You can also do group nesting, a group is part of another group. This can be useful for example when you have all kitchen lights and then all ground floor lights.

You can add the all kitchen lights entity in the group floor lights.

 

If you need any help with home assistant check my free home assistant course here

free home assistant course
free home assistant course

Gio

Gio loves rabbits, smart home tech, WWII, travelling to Thailand & my favourite pizza is margherita with parma ham!

Recent Posts