Google assistant - switch to light group

Hi All

I just bought a Google assistant mini (Finally supporting danish), and to my surprise I found that all my Sonoff switches is not seen as lights (Dooh)
Reading the forum I found some posts about this issue, but I seem to be missing a way to report state of the switch correctly?

Using below code I can turn it on but I cant turn it off (also no indication on the UI that they are turned on)

light:
  - platform: template
    lights:
      all_livingroom_lights:
        friendly_name: "Stue belysning"
        value_template: '{{ states.switch.switch_1.state }}'
        turn_on:
          service: homeassistant.turn_on
          entity_id: group.livingroom_switches
        turn_off:
          service: homeassistant.turn_off
          entity_id: group.livingroom_switches
      floorlamp_livingroom_lights:
        friendly_name: "Gulvlampe"
        value_template: '{{ states.switch.switch_1.state }}'
        turn_on:
          service: homeassistant.turn_on
          entity_id: switch.sonoff_s202
        turn_off:
          service: homeassistant.turn_off
          entity_id: switch.sonoff_s202
      highlamp_livingroom_lights:
        friendly_name: "Standerlampe"
        value_template: '{{ states.switch.switch_1.state }}'
        turn_on:
          service: homeassistant.turn_on
          entity_id: switch.sonoff_s203
        turn_off:
          service: homeassistant.turn_off
          entity_id: switch.sonoff_s203

What am I missing? and is there an easier way?

best regards
Casperse

How did you integrate your Sonoff switches into Home Assistant? Most people flash Tasmota on it which supports MQTT. When controlled by MQTT you could use MQTT Light instead of MQTT Switch.

light:
  - platform: mqtt
    name: 'Your Sonoff Switch'
    command_topic: 'cmnd/yourSonoffSwitch/POWER'
    state_topic: 'stat/yourSonoffSwitch/POWER'
    availability_topic: 'tele/yourSonoffSwitch/LWT'
    qos: 1
    payload_on: 'ON'
    payload_off: 'OFF'
    payload_available: 'Online'
    payload_not_available: 'Offline'
    retain: false

Aaah GREAT so just copy my entire switch setup to a light:

light:
# Havebelysning
  - platform: mqtt
    name: "Udendørslys"
    command_topic: "cmnd/Sonoff_TH16_1/power"
    state_topic: "stat/Sonoff_TH16_1/POWER"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    retain: true

One thing doing this I get all my light in one big section

If I do groups like this example:

light:
  - platform: group
    name: Kitchen Lights
    entities:
      - light.kitchen_ceiling_lights
      - light.kitchen_under_cabinet_lights
      - light.kitchen_spot_lights
      - light.pendant_lights

and get the naming - light… will it then hide the mqtt lights?

Do most people then hide the switches and just keep the lights on the HA UI?

Thanks again for helping me out! @Florian

you should add the availability_topic and the corresponding payload configurations to your config to have that additional information available in home assistant.

i’m not grouping my lights using the light.group component but to my expectation it does not hide the individual mqtt lights.

you can always hide individual entities by using the customize attribute hidden if you want to have it this way.

# added inside customize.yaml
light.kitchen_ceiling_lights:
  hidden: true

be aware that you don’t need such a group in google assistant. if you assign your lights to the same room (e.g. kitchen) assistant will automatically provide that functionality when you give a command like “kitchen lights on”.

Trying the new group lights didn’t really work since I wanted to create multiple groups for each room
and the - platform: group seem only to work for one group (and it needs to be named group)

light:

  • platform: group
    name: Kitchen Lights
    entities:
    • light.kitchen_ceiling_lights
    • light.kitchen_under_cabinet_lights
    • light.kitchen_spot_lights
    • light.pendant_lights
  • platform: group
    name: Livingroom Lights
    entities:
    • light.livingroom_ceiling_lights

Trying just to add my new light.kitchen to my existing groups with switches didnt work?
they just didn’t show up in any of the groups I already had created for each room?
watched a youtube video where these groups with both switches and light worked?

group:

  Livingroom_switches:
    name: Lys i Stuen
    entities:
      - switch.sonoff_s202
      - switch.sonoff_s203 
      - light.garagelys
      - light.kkklampe

Maybee I am just making this to complicated? - and your right for google I can define the rooms in the settings!
I just wanted the HA UI to be organized in rooms

if you want to have the ui to be grouped by rooms you should have a look at the “general” group component:

that way you can combine your lights, switches, thermostats, window sensors etc. all together. the linked page has some nice examples to get a general understanding how it works.