Help with openweathermap

Simple task I’m sure but I’m struggling as a somewhat newbie. I’m trying to set up openweathermap and when I add the following to my configuration.yaml everything works OK (without the sensor: !include_dir_merge_list sensor I mention below).

weather:
  - platform: openweathermap
    api_key: !secret openweathermap_api_key

And also this in my configuration.yaml

sensor:
  - platform: openweathermap
    api_key: !secret openweathermap_api_key
    monitored_conditions:
      - weather
      - temperature
      - humidity

My issue seems to be that I have the sensor: !include_dir_merge_list sensor also. I have other sensors working in a separate sensor folder and tried to set up a yaml fle there with my owm sensor configuration but I seem to be doing something wrong. My other sensor yaml files in that directory start with a - platform rest or - platform template statement. If I remove the sensor: !include_dir_merge_list sensor and add the sensor: statements from above I get the sensors I need. But this does not work in my sensor folder.

So how do I set up a simple owm yaml in my sensor folder to get this working.

Thanks!

You can only have one sensor: key in your configuration.yaml file.

Put your sensor definition in another file called something like my_sensors.yaml and put that file in the location your sensor: !include points to.

Also remove the first line of that config so it starts with - platform:

I understand that and thought I was clear in my message. With !include_dir_merge_list sensor in my configuration.yaml and no other mentions of sensor: anywhere in that file I have a separate folder called /sensor I have 2 other *.yaml files where the sensors are working properly. I tried to use the following but it would not work. I have tried this and other slightly different variations (based on a existing nws sensor) but it does not work.

- platform: template
  sensors:
    temperature:
      friendly_name: "OWM Temp"
      unit_of_measurement: 'degrees'
      value_template: "{{ state_attr('owm.temperature', 'current_temperature') }}"

What error message do you get in the log when you run the config check?

If you mean here all is good. Does this just check the configuration.yaml or all *.yaml files?

My guess is that since the other sensors I have set up work just fine it is something with how I have theopenweathermap configuration set up. I just haven’t been able to figure it out or find a similar configuration from searching and looking at what other folks are doing. Thanks for the help btw :slight_smile:

I’m confused. Where exactly are you putting this:

- platform: template
  sensors:
    temperature:
      friendly_name: "OWM Temp"
      unit_of_measurement: 'degrees'
      value_template: "{{ state_attr('owm.temperature', 'current_temperature') }}"`

Apologies. I have said a few things I have done. Currently in my configuration.yaml I have these related to openweathewrmaps and my sensor location.

weather:
  - platform: openweathermap
    api_key: !secret openweathermap_api_key

and

sensor: !include_dir_merge_list sensor

In my sensor folder I have a file called owm.yaml with this

- platform: template
  sensors:
    temperature:
      friendly_name: "OWM Temp"
      unit_of_measurement: 'degrees'
      value_template: "{{ state_attr('owm.temperature', 'current_temperature') }}"

In this folder I also have 2 other individual yaml files that are working fine. I’m just looking for how I need to correctly show the configuration for openweathermaps to get sensors.

That all looks ok.

What does the developer tools states menu show for this device’s attributes: owm.temperature

I went back and really compared what I was seeing for sensors on my nws setup to what I was trying to accomplish here with openweathermaps. This is now working for me.

- platform: template
  sensors:
    owm_temperature:
      friendly_name: 'Temperature'
      value_template: "{{ states.weather.openweathermap.attributes.temperature }}"
      device_class: temperature
    owm_humidity:
      friendly_name: 'Humidity'
      unit_of_measurement: '%'
      value_template: "{{ states.weather.openweathermap.attributes.humidity }}"

I really appreciate the help you offered. It seems my value_template statement was not correct. Helps to just stop and really look closely I guess. Good learning experience for me :slight_smile:

Great, you got it sorted. Just FYI you should use this format rather than the dot format to prevent errors while the sensors are initialising:

- platform: template
  sensors:
    owm_temperature:
      friendly_name: 'Temperature'
      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') }}"

Thanks for the tip. I’m changing it now. What kind of errors would I possibly be seeing with the previous configuration? I’m curious…

There are so many ways to get to where you want to go with this platform. I have trouble wrapping my head around it sometimes.

From here: https://www.home-assistant.io/docs/configuration/templating/

Probably a document I should become more familiar with :wink:

1 Like

Am I the only person with problems with API? it stopped to work, I got a new API and I got “unknown error occured” during the configuration