I am trying to separate out some sensors on this and just can’t make it work.
For instance the fordpass_battery sensor has attributes of “battery voltage”, but I can’t seem to
template that? Any ideas?
I think it should be {{state_attr ( 'sensor.fordpass_battery', 'battery voltage' )}}"
but no luck.
thanks
1 Like
tom_l
September 12, 2023, 5:39pm
2
harfordhawk:
state_attr (
Remove the space, should be state_attr(
This is a function that gets an attribute of an entity:
state_attr()
This is an undefined variable and some parentheses:
state_attr ()
thank you for trying to help. yes you are right, and it still makes no difference. without the space it still does not work.
I have other templated sensors that do work and using the same format,etc but the sensors under the fordpass will not work for some reason
tom_l
September 12, 2023, 6:44pm
4
The template can be tested in Developer Tools → Templates.
Post s secrreshot of sensor.fordpass_battery from Developer Tools → States showing the right hand attributes column.
Post the whole sensor config too.
- platform: template sensors: truck_battery: friendly_name: "truck battery voltage" value_template: "{{ state_attr('sensor.fordpass_battery', 'battery_voltage') }}"
this is inside a sensors.yaml file other templates in the file work fine.
tom_l
September 12, 2023, 6:58pm
6
value_template: "{{ state_attr('sensor.fordpass_battery', 'Battery Voltage') }}"
yes that should work, but no worky
tom_l
September 12, 2023, 7:03pm
8
Try restarting home assistant after changing ‘battery_voltage’ to ‘Battery Voltage’.
tom_l
September 12, 2023, 7:04pm
9
Can you post this with the correct indentation too?
tom_l
September 12, 2023, 7:05pm
10
One final thing, what does this return in the template editor:
{{ state_attr('sensor.fordpass_battery', 'Battery Voltage') }}
- platform: template
sensors:
truck_battery:
friendly_name: "truck battery voltage"
value_template: "{{ state_attr('sensor.fordpass_battery', 'Battery Voltage') }}"
that works!! i thought i had tried every combination of battery_voltage, Battery_Voltage, etc but I must not have tried cas, with a space
before we close this, and thank you by the way for helping me, Do you know how to make
sensors like this show a graph of the data instead of this? I have other sensors that for some reasomn will not display the timeline in terms of the value…
tom_l
September 12, 2023, 7:32pm
14
Add unit_of_measurement: V
to your sensor config.
Sensors with a unit are recognised as numeric and are plotted on an x-y chart instead of the state strip chart.
You could add device_class: voltage
too. https://www.home-assistant.io/integrations/sensor/#device-class
1 Like