While adding more & more switches into my Home Assistant setup, I’ve needed to group the items together in a logical manner.

I have switches controlling our geysers, general “playground” switches and I’m also implementing a solution to control our garden irrigation [details to follow soon].

I first split out the switch configuration into their own switches.yaml file:

[code]

– platform: mqtt
name: “Bedroom Geyser”
command_topic: “cmnd/Sonoff1/power1”
state_topic: “stat/Sonoff1/POWER1”
qos: 1
payload_on: “ON”
payload_off: “OFF”
retain: true
– platform: mqtt
name: “Upstairs Geyser”
command_topic: “cmnd/Sonoff1/power2”
state_topic: “stat/Sonoff1/POWER2”
qos: 1
payload_on: “ON”
payload_off: “OFF”
retain: true
– platform: mqtt
name: “Switch3”
command_topic: “cmnd/Sonoff2/power1”
state_topic: “stat/Sonoff2/POWER1”
qos: 1
payload_on: “ON”
payload_off: “OFF”
retain: true
– platform: mqtt
name: “Switch4”
command_topic: “cmnd/Sonoff2/power2”
state_topic: “stat/Sonoff2/POWER2”
qos: 1
payload_on: “ON”
payload_off: “OFF”
retain: true
– platform: mqtt
name: “Garden Zone 1”
command_topic: “lazyhome/garden/output/zone1/set”
state_topic: “lazyhome/garden/input/zone1”
qos: 1
payload_on: “ON”
payload_off: “OFF”
retain: true
– platform: mqtt
name: “Garden Zone 2”
command_topic: “lazyhome/garden/output/zone2/set”
state_topic: “lazyhome/garden/input/zone2”
qos: 1
payload_on: “ON”
payload_off: “OFF”
retain: true
– platform: mqtt
name: “Garden Zone 3”
command_topic: “lazyhome/garden/output/zone3/set”
state_topic: “lazyhome/garden/input/zone3”
qos: 1
payload_on: “ON”
payload_off: “OFF”
retain: true
– platform: mqtt
name: “Garden Zone 4”
command_topic: “lazyhome/garden/output/zone4/set”
state_topic: “lazyhome/garden/input/zone4”
qos: 1
payload_on: “ON”
payload_off: “OFF”
retain: true
[/code]

I then created a groups.yaml file with the following:

[code]
Geysers:

name: Geysers
entities:
– switch.bedroom_geyser
– switch.upstairs_geyser

Garden:
name: Garden
entities:
– switch.Garden_Zone_1
– switch.Garden_Zone_2
– switch.Garden_Zone_3
– switch.Garden_Zone_4
[/code]

Finally I added the following to my configuration.yaml file:

[code]
# Add switch config in separate file
switch: !include switches.yaml
# Add group config in separate file
group: !include groups.yaml
[/code]

The end result looks great !

Groups.png

More info on the Home-Assistant.io GROUP option here – https://www.home-assistant.io/components/group/