Need help with MQTT Vacuum


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:


I need to somehow template the “charge” to battery level (I suppose).
I don’t see how to do it.
Can someone help me.

Thank you in advance.

battery_level_topic is part of the Legacy MQTT Protocol (see documentation).

Yes I know that, but not part of the new state configuration. That is the reason I’m asking for help.

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):


is received by this topic:


use this option:

json_attributes_topic: home/vacuum

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:

json_attributes_topic: home/vacuum
json_attributes_template: '{"battery":{{value_json.charge}}}'
1 Like

Thank you that is exacly what I was looking for.

Great! Please mark the post, containing the answer, with the ‘Solution’ flag. This ensures other members can find it easily.

Hi! how are you? can you share your code for mqtt vacuum? Thanks!

I’m running 0.105.2 and the solution is not working for me.
I’m trying to monitor my phones battery level.

  - platform: mqtt
     state_topic: "owntracks/chris/noty"
     name: "Noty battery"
     unit_of_measurement: "%"
     # json_attributes_topic: owntracks/chris/noty
     json_attributes_template: '{"battery":{{value_jason.batt}}}'
     device_class: battery

But I still get the full json string in my sensor displayed:

What am I doing wrong?

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).

Try this:

  - platform: mqtt
    state_topic: "owntracks/chris/noty"
    name: "Noty battery"
    value_template: "{{value_json.batt}}"
    unit_of_measurement: "%"
    device_class: battery

That’s what I had at first.
Set it again and now I just see a ‘-’.

Post the entire JSON payload (formatted) so we can examine it.