Turn off power on thermal runaway (mqtt payload)

Hi,

I’ve been printing with my Ender3 for almost 2 years now and have had a lot of fun with it.
However recently the system falls into error mode every now and than, due to “Thermal Runaway”.

As the machine cuts all power to the hot parts due to the firmware, it also goes into a very annoying “beep” sound that doesn’t stop, only if you kill the power.

I’ve added a Sonoff (w/ Tasmota) in front of the power supply and have a RPi running octopi with MQTT providing me with data and control of the printer.

Today the thermal runaway happend again and I’ve checked my MQTT logs, where I found this:

Topic:
octoPrint/event/Error
Payload:
{"_timestamp": 1589456843, "reason": "firmware", "_event": "Error", "error": "Thermal Runaway, system stopped! Heater_ID: 0 - Printer halted. kill() called!"}

As this message is pushed directly as soon as the system gets into “error” mode I would like to use this to automatically turn of the powersupply.

Currently I’ve got this in my automation.yaml:

- alias: Kill printer on Thermal runaway
  trigger:
  - platform: mqtt
    topic: octoPrint/event/Error
  condition:
    condition: template
    payload_template: "{{ trigger.payload_json['error'] == Thermal Runaway, system stopped! Heater_ID: 0 - Printer halted. kill() called!"}}"  
  action:
  - service: switch.turn_off
    entity_id: switch.stroom_ender3

But this doesn’t work.
Could you maybe help me understand how I should address the "payload_template"?

Thanks in advance!
Guy

Small bump?

The payload_template is not using quotes correctly. The inner and outer quotes should be different.

    payload_template: "{{ trigger.payload_json['error'] == 'Thermal Runaway, system stopped! Heater_ID: 0 - Printer halted. kill() called!'}}"