Hi there.
I’m pretty new on HA and I’m discovering the templating…
Here is a snippet of config in my configuration.yaml :
rest:
- resource: http://###.###.###.###:55555/
sensor:
- name: "CPU Temp"
value_template: "{{value_json
| selectattr('SensorClass', 'equalto', 'CPU [#0]: Intel Core i7-14700K: DTS')
| selectattr('SensorName', 'equalto', 'CPU Entier')
| map(attribute='SensorValue')
| first}}"
unit_of_measurement: "°C"
- name: "CPU Conso"
value_template: "{{value_json
| selectattr('SensorClass', 'equalto', 'CPU [#0]: Intel Core i7-14700K: Enhanced')
| selectattr('SensorName', 'equalto', 'CPU Conso')
| map(attribute='SensorValue')
| first}}"
unit_of_measurement: "W"
verify_ssl: false
timeout: 60
scan_interval: 6
When I check the logs my issue is :
ValueError: could not convert string to float: '32,9164541194986'
The scrapped json part from my server is :
{
"SensorApp": "HWiNFO",
"SensorClass": "CPU [#0]: Intel Core i7-14700K: Enhanced",
"SensorName": "CPU Conso",
"SensorValue": "32,9164541194986",
"SensorUnit": "W",
"SensorUpdateTime": 1716806569
},
After many researches I didn’t find how to float my json value to a rounded 2 decimals float value.
Any one to help on this little thing ?
Thanks in advance for your time and help