I need your help. I’m trying to integrate a Vorwerk VR200 via MQTT. I’m trying to use the State Configuration since I’ve read that Legacy MQTT Protocol will be descontinued.
At the moment I’m unable to template the battery level to the component. The MQTT payload looks like:
You don’t need to include it. It was optional in the Legacy schema and continues to be optional in the new State schema.
If you want to include it in the new State Configuration schema, as an attribute, you would use the json_attributes_topic option. So if this payload (a JSON dictionary):
It will automatically create an attribute for each key in the JSON dictionary (ts, isCharging, isDocked, etc).
Let’s say you don’t want it to create attributes for all keys in the payload, just for charge. You also want to change the name from charge to battery. To do all that, you need to use the json_attributes_template option:
The sensor’s definition lacks a value_template. Without it, the sensor’s state will be whatever is received in the payload. In your case, that’s the “full json string” you described.
The purpose of json_attributes_template is to extract a value from the received payload and assign it to an attribute (not the sensor’s state).