Hi!
I am trying to implement a automation script that allow me to more or less call all hass services from MQTT without needing to design an automation for each service.
My first try was this:
- alias: 'MQTT service' trigger: platform: mqtt topic: "ha/service/+" action: service_template: "{{ trigger.topic.split('/')[-1] }}" data_template: entity_id: "{{ trigger.payload }}"
That makes it possible for example to light a hass connected light by sending a mqtt message with
topic: "ha/service/light.turn_on
payload: “light.mylight”
But that is quite limited to only sending entity_id:s. I would like to do the same by sending a Json instead like:
topic: "ha/service/light.turn_on
payload: “{ entity_id: light.mylight, brightness: 48 }”
Tried different things but always fails, anyone with ideas?