home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
68.78k stars 28.11k forks source link

tomorrow.io integration giving me the data for wrong geography #116187

Open knwpsk opened 1 week ago

knwpsk commented 1 week ago

The problem

Just set up this integration for the first time. Got an API key and entered it. Nowhere did the integration, nor the website, ask me for my geo location.

Now I'm looking at the weather forecast and the pollen index info, and they all look wrong. The temps are all 5-7 degrees cooler than actual (for the next few days), and the pollen index shows "low" while it's actually pretty miserable here. :)

I can't find anywhere in the integration, nor on the tomorrow.io website, where I should enter/update my location.

On the tomorrow.io website, I notice that it gives me a suggested "first API call" and it shows a lat/long for Boston (I'm near Charleston SC). Maybe that's relevant, maybe not.

Any help?

What version of Home Assistant Core has the issue?

2024.4.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

tomorrow.io

Link to integration documentation on our website

https://www.home-assistant.io/integrations/tomorrowio

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 week ago

Hey there @raman325, @lymanepp, mind taking a look at this issue as it has been labeled with an integration (tomorrowio) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `tomorrowio` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign tomorrowio` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


tomorrowio documentation tomorrowio source (message by IssueLinks)

lymanepp commented 1 week ago

It uses the location from the "Home" zone.

http://127.0.0.1:8123/config/zone

knwpsk commented 1 week ago

@lymanepp thank you I checked that and my Home zone is correctly configured. But (as I said above) the current temp, temp forecast, and all of the pollen values are way off.

Any other ideas? How do I troubleshoot this?

lymanepp commented 1 week ago

How do I troubleshoot this?

Add the following lines to your configuration.yaml and restart HA. Merge with existing logger section if it already exists.

logger:
  logs:
    pytomorrowio: debug

The home-assistant.log file will show what data is being passed to the API.

One more thing to check. Make sure the location in the /config/.storage/core.config file matches your Home zone. It should always match unless something is wonky.

knwpsk commented 1 week ago

Copied verbatim from the log. The location is obscured, but the latitude looks right.

2024-04-25 16:44:37.168 DEBUG (MainThread) [pytomorrowio.pytomorrowio] Sending the following payload to tomorrow.io: {'location': '32.90***32255', 'units': 'metric', 'timesteps': ['1h', '1h', '1d'], 'startTime': '2024-04-25T20:44:37+00:00', 'fields': ['temperatureMin', 'temperatureMax', 'dewPoint', 'humidity', 'windSpeed', 'windDirection', 'weatherCode', 'precipitationIntensityAvg', 'precipitationProbability']}

I don't have a homeassistant/config/ directory, is that a problem?

lymanepp commented 1 week ago

I don't have a homeassistant/config/ directory, is that a problem?

The configuration.yaml file is in the /config directory.

Try the following from a command-line. Replace <LAT>, <LONG> and <APIKEY> with your values. The response will be metric.

curl "https://api.tomorrow.io/v4/weather/forecast?location=<LAT>,<LONG>&apikey=<APIKEY>&units=metric&timesteps1h,1h,1d&startTime=2024-04-25T20:44:37+00:00&fields=temperatureMin,temperatureMax,dewPoint,humidity,windSpeed,windDirection,weatherCode,precipitationIntensityAvg,precipitationProbability"
knwpsk commented 1 week ago

I had to step away for a while. More tonight or tomorrow. Thank you.

knwpsk commented 1 week ago

Good morning @lymanepp

OK, so, in /homeassistant/ is where my config.yaml file lives. There is no /storage/ directory there, and there is no /core.config file there. (I'm using the fileEditor integration. I don't see any settings for it to say that it should hide or unhide any directory or file) (I'm not at home during the day, I'm working remotely, so it's a bit tricky to use another tool like ssh directly to my HA machine)

Meanwhile I ran the call using curl as you suggested. I manually entered my lat/long. I'm getting odd values back. I'm going to contact tomorrow.io and see what they say.

lymanepp commented 1 week ago

There is no /storage/ directory there, and there is no /core.config file there.

The directory is ".storage" not "storage".

knwpsk commented 1 week ago

Yeah I know. I don't have either /.storage/ or /storage/

knwpsk commented 1 week ago

Meanwhile... I think the "base weather layer" values that I'm getting back from tomorrow.io (temperature, humidity, etc) seem pretty close to correct. Close enough we can assume they are correct (with different root data sources, maybe). But the Pollen values are way off. I can't see (even in debug mode) what values are returned from tomorrow.io to the integration. And I'm trying to learn enough about tomorrow.io's API to simulate the query, but it takes time. Would mind sending me the curl command for that - assuming it's easier for you than for me!

knwpsk commented 1 week ago

edit: I found an example on github. Ran it. I think tomorrow is just providing bad data on pollen. I'll try to contact them.

curl "https://api.tomorrow.io/v4/timelines?location=32.xxxxx,-79.xxxxx&timesteps=current&fields=treeIndex,grassIndex,weedIndex&apikey=xxxxxxxxxxxxxxxxxxxx"

{"data":{"timelines":[{"timestep":"current","endTime":"2024-04-26T20:40:00Z","startTime":"2024-04-26T20:40:00Z","intervals":[{"startTime":"2024-04-26T20:40:00Z","values":{"grassIndex":1,"treeIndex":1,"weedIndex":0}}]}]}}

lymanepp commented 1 week ago

Yeah I know. I don't have either /.storage/ or /storage/

The File Editor addon is lying to you. The directory is definitely there.