I’m new to Home Assistant and the template syntax so apologies if this question has been asked before, or the answer is easily searchable.
I have a scenario in which I want to externally control many switches provisioned on Home Assistant through MQTT JSON strings.
Is there a way to do select the entity ID through a json string? Or is this an incorrect understanding on how the configuration.yaml file works? If so could anyone point me in the right direction documentation wise?
It isn’t necessary to publish the payload in JSON format. If you simply publish light.kitchen you can just use trigger.payload to get the payload. The advantage of using JSON is if you wish to pass additional information (brightness, color, etc) and then modify the automation’s action section to use it accordingly.
Thanks for the replies, I think my core issue is I’m struggling with the syntax. I am also trying to check in the trigger or condition sections if there is a key present in the received json string, as I don’t want this script to run for every mqtt message received.
Is there a succinct way to do this? Essentially the goal is to have these devices controllable/query-able for an external MQTT source.
It can’t be completely arbitrary. The template must have some means of determining the entity’s type so it can intelligently select the appropriate attribute.
Do you have examples of the entities the template should handle?
Yes, I am looking to access information from a TP-Link Smart Plug. I am not sure of what specific device I will need until I receive the identifier (to be determined) from a MQTT Json packet.