My first MQTT Trigger not working

I am trying to set up my first MQTT automations. It’s a Zigbee2MQTT.

When I push the button on my switch, in the zigbee2mqtt log it says the following:

zigbee2mqtt:info 2018-10-13 07:40:49 MQTT publish, topic: 'zigbee2mqtt/0x00158d0001e7932d', payload: '{"battery":"100.00","voltage":3045,"linkquality":55,"click":"single"}'

Using the above above information and other people’s templates, I have attempted to write the following:

  alias: MQTT Bathroom Light
  trigger:
  - platform: mqtt
    topic: 'zigbee2mqtt/0x00158d0001e7932d'
  condition:
  - condition: template
        value_template: "{{ 'click' in trigger.payload }}"
  action:
  - data:
      entity_id: light.0x0017880104007590
    service: light.toggle

Unfortunately when I enter this into my automations.yaml it returns the error:

Error loading /config/configuration.yaml: mapping values are not allowed here
  in "/config/automations.yaml", line 126, column 23

Line 126 in particular is complaining about:

value_template: "{{ 'click' in trigger.payload }}"

I then attempted to create the automation using the front end drop down menus and this created the following in the automations.yaml

  alias: New Automation
  trigger:
  - payload: click
    platform: mqtt
    topic: '''zigbee2mqtt/0x00158d0001e7932d'''
  condition: []
  action:
  - data:
      entity_id: light.0x0017880104007590
    service: light.toggle

Unfortunately this did not work either.

Any pointers please?

your first attempt should work. Just looks like a formatting issue (spacing)

Try:

  alias: MQTT Bathroom Light
  trigger:
    - platform: mqtt
      topic: 'zigbee2mqtt/0x00158d0001e7932d'
  condition:
    - condition: template
      value_template: "{{ 'click' in trigger.payload }}"
  action:
    entity_id: light.0x0017880104007590
    service: light.toggle
2 Likes

Thank you very much. So simple. :slight_smile: