Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95919

Automation trigger and templating with mqtt json payload

$
0
0

@thanksmister wrote:

I am trying to set my HUE light bulbs from an mqtt automation trigger. I am sending the payload as JSON and trying to parse the json using the service_template and data_template to set the light entity state and brightness.

I am not using the light component because my purpose is a little more complicated, I have an Android application that is talking with HASS through MQTT and I want to control a dimmer light connected to HASS from the application.

This is the JSON I am sending as the payload:

{'topic':'room/dimmer/set', 'payload': '{"state":"on", "brightness":10}'}

Here is my automation:

- id: '1577995477209'
  alias: MQTT Dimmer
  description: ''
  trigger:
  - platform: mqtt
    topic: room/dimmer/set
  condition: []
  action:
  - data_template:
      brightness: '{{ trigger.payload_json.brightness }}'
      entity_id: light.living_room
    service_template: > 
      light.turn_{{ trigger.payload_json.state }}

Nothing is happening of course, but is there a way to test this with the dev tools or if anyone has something similar they would share.

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>