I’ve manually configured MQTT device. For one of the sensors, I’ve used the device attribute, that allows to add additional information about the device. Is there a way to populate device attributes (e.g. sw_version) using the state of another sensor?
In my case, I’d like to update the ‘sw_version’ using the ‘sensor.tesla_version’.
I can think of a hack to build a HASS Discovery block of JSON from the version sensor, then publish to MQTT from HASS, which then injests the auto-discovery config and configures the main Tesla entity replacing the local YAML config.
Here’s a mosquitto_pub example to get you started hacking together a proof of concept:
HASS changes immediately on receiving the publish.
Another example:
I’ve published data to MQTT from HASS automations but not discovery - should work as all are just MQTT payloads.
Don’t know if a more Python-esque API-based solution exists though.