Invalid config for [automation]: expected a dictionary @ data['condition'][0]

Hi,

I’m staring at my code for quiet some time now, but I can’t find the error.

I want to receive a notification when my washing machine has started and when finished. This is triggered by a Tasmota power sensor via MQTT.
To prevent false notifications I build in a state for the washing machine which I am using as a condition is both automations.

Since I build in the conditions for the washing machine state I get the following error:

Invalid config for [automation]: expected a dictionary @ data['condition'][0]. Got None extra keys not allowed @ data['conditions']. Got None. (See /config/configuration.yaml, line 13)

I got this code for my washing machine:

automation:


- alias: Wasmachine aan
  trigger:
  - above: '100'
    entity_id: sensor.wasmachine_power
    platform: numeric_state
  condition:
  - condition: state
    entity_id: sensor.wasmachine_state
    state: 'off'
  action:
  - service: mqtt.publish
    data:
      topic: home-assistant/wasmachine/state
      payload: on
  - data:
      message: De wasmachine is gestart
      title: Wasmachine
    service: notify.pushbullet


- alias: Wasmachine klaar
  trigger:
  - below: '2'
    entity_id: sensor.wasmachine_power
    platform: numeric_state
  condition: and
  conditions:
    - condition: state
      entity_id: sensor.wasmachine_state
      state: 'on'
    - above: '5'
      condition: numeric_state
      entity_id: sensor.time_online
  action:
  - service: mqtt.publish
    data:
      topic: home-assistant/wasmachine/state
      payload: off
  - data:
      message: De wasmachine is klaar
      title: Wasmachine
    service: notify.pushbullet

and

sensor:
  - platform: mqtt
    name: "Wasmachine State"
    state_topic: "home-assistant/wasmachine/state"

You’re missing the condition: line in the second automation. Should be like this:

  condition:
    condition: and
    conditions:
    ...

Second one…

- alias: Wasmachine klaar
  trigger:
  - below: '2'
    entity_id: sensor.wasmachine_power
    platform: numeric_state

  condition: # this line needs adding
    condition: and # this line and below need indenting another 2 spaces 
    conditions:
      - condition: state
        entity_id: sensor.wasmachine_state
        state: 'on'
      - above: '5'
        condition: numeric_state
        entity_id: sensor.time_online

  action:
  - service: mqtt.publish
    data:
      topic: home-assistant/wasmachine/state
      payload: off
  - data:
      message: De wasmachine is klaar
      title: Wasmachine
    service: notify.pushbullet

Blank lines added to highlight

1 Like

Thanks all! I just saw it myself too

Errr ? No ! …

This works for me …

  - alias: au_light_bath_offdelay
    trigger:
      - platform: state
        entity_id: light.fibdim2_bath_level
        from: 'off'
        to: 'on'
    condition:
      - condition: state
        entity_id: input_boolean.ib_light_bath_timer_enable
        state: 'on'
      - condition: state
        entity_id: input_boolean.ib_light_bath_link_enable
        state: 'on'
    action:

that’s not what op originally had :wink: Yours is working because you’re using the assumed ‘and’. Op was using the hardcoded and and his syntax was wrong

As I say to my kids. Less talking and more listening and reading will serve you far better in the long run and then maybe you’ll understand what you’re talking about.

You know Marc if there are two ways to say something, you always pick the smarmy, sarcastic condescending one.
You are a real joy to work with

/me takes a bow

Thanks, I didn’t know about the input boolean. I now see that’s an easier way to solve this one.
I just come from domoticz where I got used to lovely chains :wink:

Also, to clarify, either this:

  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: sensor.wasmachine_state
        state: 'on'
      - above: '5'
        condition: numeric_state
        entity_id: sensor.time_online

or this:

  condition:
    - condition: state
      entity_id: sensor.wasmachine_state
      state: 'on'
    - above: '5'
      condition: numeric_state
      entity_id: sensor.time_online

will work. Conditions are AND by default, so simply listing multiple conditions functions as AND (which is what @Mutt was saying).

I don’t see how.

You still have to create the additional input booleans and you will likely just create them from the original sensors used in the conditions.

Why would you want to do the extra work and complicate things more when there is no benefit.

I think Mutt was showing an example of the config syntax for the conditions not suggesting you use the input booleans instead of the original sensors.

Yes as I said in the pm to the OP, the bit about input booleans was incidental.
It was more about the nature of syntax for the ‘and’ conditions I was aiming at.

I realise now that it would have been confusing (my ‘and’ conditions) to anyone only familiar with output from the AE

Summary : I endorse finity’s statement (unless you are going to use these booleans in multiple locations and it’s iffy even then)

I know Mutt was aiming at the conditions. I had this because of some copy/pasting and first I want the code to work. Later I will clean up.

The input booleans seem to be easier than the mqtt thing for me.
You mean the input booleans are making it complicated? I indeed don’t use them anywhere else. How can I make it easier then?

Yes, because you will still have to program something to turn the boolean on/off. That’s still going to need to be the MQTT topic information. So in effect you are just moving the MQTT interaction up one more level to a boolean. So it’s more complicated.

I don’t see how you can.

you already have a working automation so you had to have figured out MQTT at least a bit to get there.

I didn’t use MQTT and the input boolean together, I now only use the input boolean.

- alias: Notification Wasmachine aan
  trigger:
  - above: '100'
    entity_id: sensor.wasmachine_power
    platform: numeric_state
  condition:
  - condition: state
    entity_id: input_boolean.wasmachine
    state: 'off'
  action:
  - service: input_boolean.turn_on
    data:
      entity_id: input_boolean.wasmachine
  - service: notify.pushbullet
    data:
      message: De wasmachine is gestart
      title: Wasmachine

Ok what turns the input boolean off?

- alias: Notification Wasmachine klaar
  trigger:
  - below: '1'
    entity_id: sensor.wasmachine_power
    platform: numeric_state
  condition:
    - condition: state
      entity_id: input_boolean.wasmachine
      state: 'on'
  action:
  - service: input_boolean.turn_off
    data:
      entity_id: input_boolean.wasmachine
  - service: notify.pushbullet
    data:
      message: De wasmachine is klaar
      title: Wasmachine

I removed the And condition here because the other condition is not necessary anymore.