Value_json into float

i have some mqtt sensors like the following.

  - platform: mqtt
    state_topic: tele/electric/SENSOR
    name: 'V1-Voltage'
    scan_interval: '10'
    value_template: "{{ value_json.ENERGY.Voltage[0] | float }}"
    unit_of_measurement: 'V1'
    force_update: 'true'

The issue is that the value of the sensor is not a float. It is a string. The float operation in the value template is not working. Any advise on how to sort this out.

Entity states are always strings. Convert it to a float where you need to use the value.

Entity attributes on the other hand can be any type.

1 Like