Openweathermap weather_code problem

Hello,

I have integrated Openweathermap and I want to have a sensor that shows me the current weather condition.
I created four sensors but only weather_code doesn’t work properly and I don’t understand why.

weather:
  - platform: openweathermap
    api_key: !secret openweather_api
owm_temperature:
      friendly_name: 'Temperature'
      unit_of_measurement: '°C'
      value_template: "{{ state_attr('weather.openweathermap', 'temperature') }}"
      device_class: temperature
     owm_humidity:
      friendly_name: 'Humidity'
      unit_of_measurement: '%'
      value_template: "{{ state_attr('weather.openweathermap', 'humidity') }}"
     owm_weather_code:
      friendly_name: 'Weather Code'
      value_template: "{{ state_attr('weather.openweathermap', 'weather_code') }}"
     owm_weather_wind_speed:
      friendly_name: 'Wind Speed'
      unit_of_measurement: 'km/h'
      value_template: "{{ state_attr('weather.openweathermap', 'wind_speed') }}"

Capture

Thank you for help!
Ciprian

In dev tools have you checked the state and attributes for weather.openweathermap? What does it show for weather_code in there? Your yaml looks ok to me.

Hello @DavidFW1960,

I forgot to check in dev tools.
This is how it looks:

Thx!

I don’t see a weather_code attribute there…

Here is how I set openweathermap up

  - platform: openweathermap
    api_key: !secret openweather_api_key
    monitored_conditions:
      - weather
      - temperature
      - wind_speed
      - humidity
      - pressure
      - clouds
      - rain
      - snow
      - weather_code     

You can add/remove what ever sensors you need. weather ends up being the text version of the weather_code

Hi,

Now I tested your config and I receive the error:

Invalid config for [weather.openweathermap]: [monitored_conditions] is an invalid option for [weather.openweathermap]. Check: weather.openweathermap->monitored_conditions. (See ?, line ?).

My config:

weather:
  - platform: openweathermap
    api_key: !secret openweather_api
    monitored_conditions:
      - weather
      - temperature
      - wind_speed
      - humidity
      - pressure
      - clouds
      - rain
      - snow
      - weather_code

Thank you!

Hi,

I had an error in the code, now everything is fine.

Correct code is looking like this:

weather:
  - platform: openweathermap
    api_key: !secret openweather_api
sensor:
 - platform: openweathermap
   api_key: !secret openweather_api
   monitored_conditions:
     - weather
     - temperature
     - wind_speed
     - humidity
     - pressure
     - clouds
     - rain
     - snow
     - weather_code```

Thank you!

Good! Glad it is working for you.