Extracting attributes out of forecast (Meteorologisk institutt) from an entity forecast_dom

Hi, I would like to extract the temperature and humidity from Meteorologisk institutt (Met.no). I found YAML code that supposedly works but I have problem with sensors line:

  - platform: template
    sensors: 
      norwegian_temperature:
        friendly_name: "forecast_dom"
        unit_of_measurement: '°C'
        value_template: "{{ state_attr('forecast_dom', 'temperature') }}"

It says that: [sensors] is an invalid option for [sensor.template]. Please check the indentation.
Could you please let me know how to fix this so it works?
I’ll be extremely grateful.

You’re missing the domain from the weather entity…

  - platform: template
    sensors: 
      norwegian_temperature:
        friendly_name: "forecast_dom"
        unit_of_measurement: '°C'
        value_template: "{{ state_attr('weather.forecast_dom', 'temperature') }}"
1 Like

You’re right, but still get problem with second line: [sensors] is an invalid option for [sensor.template]. Please check the indentation.

Bez tytułu

Your indentation looks fine for HA config… but that looks like ESPHome device config, not HA config. They are not interchangeable.

Maybe take a step back and explain what is is you are trying to do.

1 Like

In the dashboard I want to make 2 graphs. On one the temperature flow and on the other the humidity. Is it possible to extract attributes from Meteorologisk institutt (Met.no) and make them separate entities? I found Dev Tools/states and YAML code with temperature, humidity etc. I tried to paste this code here but new entity has not been created.

Yes

Where is “here”?

developer-tools/state, I found weather.forecast_dom entity

Template sensor configuration needs to be placed in your configuration.yaml file (or other properly split files). The file system can be accessed using the File Editor or Studio Code Server add-ons.

For a basic template sensor like this you can just use the Template helper. This can be found under Settings > Devices & Services > Helpers. Then click “Create Helper” and select “Template”.

1 Like

See the lines highlighted in yellow? Those lines are not for configuring anything in Home Assistant. They are for configuring an ESPHome device.

That’s why you were asked to identify the name of the file where you placed the Template Sensor configuration, because it doesn’t appear to be the correct file.

2 Likes

Ok I make template, but it’s unavailable.Something else needs to be done or is it my mistake?

The only thing that should be in the State template field is:

{{ state_attr('weather.forecast_dom', 'temperature') }}

And you will want to select Measurement for the State class field.


Make sure you remove the configuration you posted earlier from wherever you pasted it (ESPHome) since it will likely cause issues down the line.

1 Like

You made the same mistake that another person did. You put the full YAML configuration of a Template Sensor into the field where you only need to put the template.

1 Like

Thank you guys, you have taught me a lot today. Thanks for your patience. Best wishes :slight_smile: