Setting a climate entity's set-point temperature from MQTT

Hi
I’m trying to develop an automation that sets a thermostat’s set-point from the payload of an incoming mqtt message. The automation currently looks like:

- alias: remote_shack_thermostat_control
  trigger:
    - platform: mqtt
      topic: "hassio_2/climate/horstmann_secure_meters_hrt4_zw_thermostat_transmitter_heating_1_2/command"
  action:
    - service: "climate.set_temperature"
      data_template:
        entity_id: climate.horstmann_secure_meters_hrt4_zw_thermostat_transmitter_heating_1_2
        temperature: '{{trigger.payload}}'
        hvac_mode: heat

The automation triggers correctly but I get an error:

2019-10-21 17:09:36 ERROR (MainThread) [homeassistant.helpers.service] Error rendering data template: UndefinedError: 'trigger' is undefined

I chose trigger.payload on the basis of other, working, automations.

Any clues?

In your testing procedure, are you publishing a payload to the topic or are you manually triggering the automation via the Services page (by calling the automation.trigger service)?

If you manually trigger the automation, the trigger object is undefined.

Thanks for the response.
I was triggering using MQTTLens.

Config looks okay to me. Are you on the latest version of homeassistant?

Yes. There must have been a glitch somewhere because it worked after a full reboot.