How to split attributes

Please format your code correctly. This isn’t just to make it look nice — your code could have indentation errors, wrong quote marks (“smart” quotes for example) and we cannot tell with text formatting like that.

There are a number of things we can’t tell from the screenshot:

  • is the attribute called tomorrow or Tomorrow?
  • are the numbers formatted with a European decimal comma or is your front end doing that?

Also recommend you use modern format for template sensors.

Assuming the attribute is called Tomorrow, and you want the first value as a number, this should work if the numbers contain a decimal point. It should go under the top-level template:, not under sensor:.

template:
  - sensor:
      - name: Strompris I Morgen
        state: "{{ state_attr('sensor.nordpool_kwh_oslo_nok_3_10_025', 'Tomorrow')[0] }}"
        unit_of_measurement: "nok"

If that doesn’t work, go to Developer Tools / Templates and paste in:

{{ states.sensor.nordpool_kwh_oslo_nok_3_10_025.attributes }}

Copy and paste the result here, correctly formatted as code.

1 Like