Automation with template and normal conditions

Hey,

I bought a xiaomi switch and I want to use it in an automation.

The idea is that when I press the switch and the input boolean mode_cooking is turned off it will turn it on.

When I try that with the following automation:

- id: switch_cooking_mode_on
  alias: Enable cooking mode if cooking is off
  trigger:
    platform: mqtt
    topic: 'zigbee2mqtt/xxxx'
  condition:
    - condition: template
      value_template: '{{ "single" == trigger.payload_json.click }}'
    - condition: state
      entity_id: input_boolean.mode_cooking
      state: off
  action:
    entity_id: input_boolean.mode_cooking
    service: input_boolean.turn_on

I get the following error when checking the config:

Configuration invalid
Invalid config for [automation]: extra keys not allowed @ data['condition'][0]['state']. Got None
not a valid value for dictionary value @ data['condition'][0]['condition']. Got None. (See /config/configuration.yaml, line xxx). Please check the docs at https://home-assistant.io/components/automation/

It goes wrong when I added the second condition, I have searched the documentation but couldn’t find template conditionals with normalconditions. Is that correct?
And so do I need to create a switch in between?

Can you post your config using the instructions in the blue box at the top of the post.

My bad I have fixed the fomatting

Try this:

  condition:
    - condition: template
      value_template: "{{ 'single' == trigger.payload_json.click }}"
    - condition: state
      entity_id: input_boolean.mode_cooking
      state: 'off'
1 Like

Thanks man, that worked I tried almost everything!