Change mqtt value

Hi.
I’m trying to convert the output value from an mqtt sensor.

This is the sensor:

  • platform: mqtt
    name: “MQTT Power Usage Play1”
    state_topic: “homeseer/mcsMQTT/1st/Stue/StikkSonosP1/Power”
    unit_of_measurement: ‘W’

This works fine and gives me an value:

I want to convert the comma to dot and that works find if I use this code in the dev-template:

"{{ states.sensor.mqtt_power_usage_play1.state | replace(',', '.') }}"

But how do I implement that in my config? I have read about value_template etc. but have not find the correct solution. Glad if anyone can help me with this.

have you tried adding the following (with correct indentation) to your sensor?

value_template: “{{ value | replace(’,’, ‘.’) }}”

Thank you! It worked perfectly.

Initially I tried with this:

value_template: "{{ states.sensor.mqtt_power_usage_play1.state | replace(',', '.') }}"