Hi,
I am currently trying to set up a voice-activation schema, where any voice command is published to an HTTP Sensor, and then from there sent as MQTT - and may or may not match an existing MQTT trigger. This idea is how I want to easily expand a wide variety of voice activation, based on minimal trigger setup.
Where I am having some difficulty, is defining the MQTT payload and topic from the HTTP Sensor attributes. I can’t make any progress on the data template approach, and trial and error via restarts is SLOW
The automation runs fine; it detects the sensor state switch from off to on, and will run other simpler actions. The MQTT publish part fails, as I don’t know how to write the template part. If anyone could point me in the right direction, I would be very happy
The HTTP sensor, with MQTT data as attributes:
The automation, which uses the HTTP sensor for state-change trigger, and MQTT data:
#Process HTTP sensor data, send MQTT
- alias: HTTP Sensor to MQTT
id: httpsensormqtt
trigger:
platform: state
entity_id: sensor.mqttsensor
from: 'off'
to: 'on'
action:
- service: mqtt.publish
data_template:
topic: '{{ sensor.mqttsensor.topic }}'
payload: '{{ sensor.mqttsensor.payload }}'
qos: 1