Try something like this:
- id: openhasp_image
alias: openhasp time
trigger:
- platform: time_pattern
minutes: /1
action:
- service: mqtt.publish
data:
topic: hasp/plate01/command/p3b2.src
payload: '{%- if not is_state('weather.forecast_home','unavailable') %}
L:/z-32-{{ state_attr('weather.forecast_home','forecast')[2]['condition'] }}.png
{%- endif %}}'
This thread may help you with templating json payloads: Construction of JSON payload in automation action - #6 by Wingnut