Fordpass integration templating sensors- need help

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

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

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.

value_template: "{{ state_attr('sensor.fordpass_battery', 'Battery Voltage') }}"

yes that should work, but no worky

Try restarting home assistant after changing ‘battery_voltage’ to ‘Battery Voltage’.

Can you post this with the correct indentation too?

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…

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