Help with my 1st automation using xiaomi devices

Hi guys, so i’m trying to create my 1st automation and i get the error:

Message malformed: Integration ‘’ not found

I’m using an example taken from here;

So basically this is my YAML:

alias: Test
  trigger:
    platform: state
    entity_id: binary_sensor.motion_sensor_xxxxx
    from: off
    to: on
  condition:
    condition: numeric_state
    entity_id: sensor.illumination_xxxxx
    below: 50
  action:
     service: light.turn_on
      target:
        entity_id: light.gateway_light_xxxxx
      data:
        brightness: 1
     service: automation.turn_on
      target:
        entity_id: automation.MOTION_OFF

I’ve obviously replaced the xxxx with the correct ids on my devices, but when i try to save i always get that error:

Message malformed: Integration ‘’ not found

Basically what I’m trying to do is have the gateway light turn on when motion is detected, but only if its dark in that corridor and light only a dim light.

Any help would be appreciated.
Thx in advance

You need to quote these states:

    from: 'off'
    to: 'on'

off and on (unquoted) are reserved words that equate to false/0 true/1 respectively. You need the strings ‘off’ and ‘on’. States are always strings.

Also if you have more than one action you need to make them a list with -

  action:
    - service: light.turn_on
        target:
          entity_id: light.gateway_light_xxxxx
        data:
          brightness: 1
    - service: automation.turn_on
        target:
          entity_id: automation.motion_off

Note also that entity ids have no capital letters.

alias: test
description: ''
mode: single
trigger:
  - platform: state
    entity_id: binary_sensor.upstairs_motion_sensor_up_active
    from: 'off'
    to: 'on'
condition:
  - condition: numeric_state
    entity_id: sensor.bedroom_motion_sensor_illuminance
    below: '50'
action:
  - service: automation.turn_on
    target:
      entity_id: automation.1_test
  - service: light.turn_on
    target:
      entity_id: light.office_light

The automation’s syntax errors have been identified so perhaps you can explain why you have chosen to follow the dubious design pattern of having one automation control another automation.

Thanks, I’ve tried before with the ’ but i got the same error. I think the problem was the capital letters and the list.
However that didn’t solve it as I get a different error:

Message malformed: required key not provided @ data[‘action’]

Show what you have now.

alias: Test
  trigger:
    platform: state
    entity_id: binary_sensor.motion_sensor_xxxxx
    from: 'off'
    to: 'on'
  condition:
    condition: numeric_state
    entity_id: sensor.illumination_xxxxx
    below: 50
 action:
    - service: light.turn_on
        target:
          entity_id: light.gateway_light_xxxxx
        data:
          brightness: 1
    - service: automation.turn_on
        target:
          entity_id: automation.motion_off

You really have to watch your indentation. It is very important in YAML.

action: is not indented far enough. It should be in line with trigger and condition.

If you continue having trouble with this perhaps try the UI automation editor instead.

You’re right I did this with UI and got it right the 1st try.
Home assistant is way more complex than I was counting on, but I’ll get there.
Thx for your help.
And if someone needs it in the future here’s my YAML:

alias: Turn Upstairs Light on Dark
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.motion_sensor_xxxxxx
    from: 'off'
    to: 'on'
condition:
  - condition: and
    conditions:
      - condition: numeric_state
        entity_id: sensor.illumination_xxxxxx
        below: '50'
action:
  - service: light.turn_on
    target:
      device_id: xxxxxx
    data:
      brightness_pct: 1
      rgb_color:
        - 0
        - 0
        - 255
      transition: 120
mode: single

This turns the light on in a dimm blue color if the GW is in the dark and motion is detected.
Then i made another one to turn it of when no motion is detected

The automation’s condition contains only one condition so there’s no need to use condition: and.

why don’t you use UI, you wouldn’t be bothered with these at all.

I used UI, that’s the code generated by it, it it’s not “up to code” then there’s something wrong with the UI.

I just used the Automation Editor (in version 2021.6.6) to create a simple automation with a singlecondition. It did not automatically include condition: and within the condition. You have to explicitly select “And” from the “Condition type” menu to get condition: and.

Screenshot_20210627-084023~2