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

JSON map in data_template

$
0
0

@erikbjork wrote:

I’m trying to control switches etc in HA by sending MQTT messages to HA. I have this automation rule:

- alias: Control switches via MQTT
  trigger:
    platform: mqtt
    topic: homeassistant/to-ha/cmd
  action:
    - service_template: "{{ trigger.payload_json['service'] }}"
      data_template: >
        {{ trigger.payload_json['data'] }}

The payload of my message is going to look like this:

{
  "service": "light.turn_off",
  "data": {
    "entity_id": "group.kitchen_lights"
  }
}

But this is not right. HA doesn’t like the configuration: expected a dictionary for dictionary value @ data['action'][0]['data_template']. Got None.

How do I turn that JSON map to a dictionary?

Posts: 6

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 96123

Trending Articles



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