I have a new MQTT sensor defined which reading as a 3 digit number such as 721. I need this to become a % such as 72%. I’ve tried a few value templates and can get it to work under developer tools but does not work in the configuration.yaml.
mqtt:
sensor:
- name: "Victron State of Charge"
unique_id: "Victron State of Charge"
state_topic: "SMARTBMS/SOC"
value_template: "{{value}}"
unit_of_measurement: "%"
device_class: "battery"
Under Dev Tools Value Template I have this and I get a good result, just not in the configuration file for the sensor:
Once if have this in the configuration.yaml, it becomes a 0 for output. No errors.
The only time I get the value from the mqtt sensor is with this config.
- name: "Victron State of Charge"
unique_id: "Victron State of Charge"
state_topic: "SMARTBMS/SOC"
value_template: "{{value}}"
unit_of_measurement: "%"
device_class: "battery"
the number off the raw sensor is 721 which needs to be 72.1%.