What is wrong with this automation?

this automation seems to have all the required fields:

- id: '1633285214111'
  alias: my kitchen motion
  description: Kitchen motion done right
  trigger:
      - platform: state
        entity_id: group.kitchen_motion
        to: 'on'
      - platform: numeric_state
        entity_id: sensor.shelly_motion_luminosity
        below: 40
  condition:
      - condition: and
        conditions:
            - condition: numeric_state
              entity_id: sensor.shelly_motion_luminosity
              below: 40
            - condition: state
              entity_id: group.kitchen_motion
              state: 'on'
  action:
      - service: light.turn_on
        target: group.kitchen_lights
      - wait_for_trigger:
            - platform: state
              entity_id: group.kitchen_motion
              from: 'on'
              to: 'off'
      - service: light.turn_off
        target: group.kitchen_lights

I am constantly getting this error:

Invalid config for [automation]: expected a dictionary for dictionary value @ data['action'][0]['target']. Got None. (See ?, line ?).

I don’t know what it means. As far as I know, action[0].target has a value, so I can’t figure what it’s wrong with it.

You should only use light.turn_ services on light entities. Either use a light group for your lights, which creates a light entity, or use homeassistant.turn_ service.

I’d also double check that group.kitchen_lights actually exists…

Remove the illumination trigger since the motion is the real trigger here.
Remove the motion from you condition since light below is you only condition.

I just realised I have to provide an entity id to the target, it is not enough to just put the value there:

      - service: light.turn_on
        target:
            entity_id: group.kitchen_lights

If I do that then it will not properly pick the lux updates, that are coming from the same motion sensor. HA is (shamesly) failing at getting both states updated at the same time, therefore many times the automation checks a stale value

What are the advantages of that? It looks totally redundant to normal groups, and I don’t see any benefit for it

Groups for light only allow turn on/off. With light groups you can set all attributes that exist for a normal light.

1 Like

Just to put the final working solution (maybe can be improved, but this works) here it is:

- id: '1633285214111'
  alias: Manual kitchen motion
  description: Kitchen motion done right
  trigger:
  - platform: state
    entity_id: group.kitchen_motion
    to: 'on'
  - platform: numeric_state
    entity_id: sensor.shelly_motion_luminosity
    below: '40'
  condition:
  - condition: and
    conditions:
    - condition: numeric_state
      entity_id: sensor.shelly_motion_luminosity
      below: '40'
    - condition: state
      entity_id: group.kitchen_motion
      state: 'on'
  action:
  - service: homeassistant.turn_on
    target:
      entity_id: group.kitchen_lights
  - wait_for_trigger:
    - platform: state
      entity_id: group.kitchen_motion
      from: 'on'
      to: 'off'
  - service: homeassistant.turn_off
    target:
      entity_id: group.kitchen_lights
  mode: restart

Can I put the different groups into a package all together rather than scattered all over the place?

Yes you can.