Template - why I can't see attribute state?

template - why I can’t see attribute state?

  climate:
    title: HLAJENJE
    subtitle: >
      [[[ 
        return "{{state_attr('sensor.inside_current_humidity','median')}}"; 
      ]]]
    icon: phu:air-conditioner

01

Try

subtitle: "[[[ return states['sensor.inside_current_humidity'].attributes.median ]]]"

or I think the best approach:

subtitle: "{{state_attr('sensor.inside_current_humidity','median')}}"

You can try this but not sure if this works:

subtitle: "[[[ return state_attr['sensor.inside_current_humidity','median'] ]]]"

What card is that? Jinja or JS templates can only be used in a few spots. JS templates are all different as well.

It is JS template.

and what do the docs say for the JS templates? They are all custom, so they all have different syntax for accessing states.

If you link the docs, I can help you write the code. So all you have to do is tell me what card that is, because it’s not listed in your configuration in your post.

I am usig cards form homekit infuse 5

This solution works. Now I can see attribute state.

Ok, so that must be custom button cards.

subtitle: |
  [[[ 
    return states['sensor.inside_current_humidity'].attributes.median; 
  ]]]
1 Like

This solution is perfect. Thx