Closed KotBayun69 closed 9 months ago
Called the service for hourly forecast and get also forecast for two past hours. E.g current time is 18:15 so first forecast should be for 18:00 but got for 16:00 and 17:00
So, not exactly. The results value of get_forecast is just what the api returns (e.g. https://ims.gov.il/he/full_forecast_data/2)
You may have some point that I should filter only the current/future values
You may have some point that I should filter only the current/future values
So, the actual problem is at API side. Not a surprise we usually get rain forecast for sunny day :)
Now via API I've got rain only, and I see rain only in 2 days... API probably not broken
@chepa92 - can you elaborate? Is there anything in the logs?
This is what I see:
I saw:
2024-01-29 12:54:41.152 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up ims platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 360, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/ims/sensor.py", line 283, in async_setup_entry
for condition in conditions:
TypeError: 'NoneType' object is not iterable
I found a problem, if I select English language, I've got data back 2 days and HA thinks today is -2 days, if select Hebrew everything good.
as weather I don't see rain and if I use sensors I see rain.. so problem yes exists
@chepa92 - I think you can write in Hebrew since I can't understand the problem?
@chepa92 - I think I found what you're describing: Data from IMS comes in weather codes - This is the weather_code table (code to description)
Here is the translation from code to:
Note that there's some discrepency, e.g. code 1530
is ATTR_CONDITION_PARTLYCLOUDY
(HomeAssistant "Partly Cloudy") but also is with icon mdi:weather-partly-rainy
.
This is the mix-up, I think - as there's an inherent mismatch between Home Assistant conditions (list here) and MDI (here)
If you want to suggest some different mappings, please do.
For reference -- what @chepa92 described can be seen here:
(Template:)
Weather: {{ states("weather.ims") }}
Sensor: {{ state_attr('sensor.ims_forecast_today', '16:00').weather.value }}
Results in:
Weather: partlycloudy
Sensor: Cloudy, possible rain
More over - the code to description is coming from here
@GuyKh yeap, this is probably a problem, on their site they have 2 icons with 1 drop and 3 drops (weather-rainy, weather-partly-rainy) so yes probably mismatch, I think weather code 1540, 1530 should be a rain with 1 drop
@chepa92 the issue is with MDI icons, I can't find any "3 drop" one which suits
@GuyKh I think statuses 1540 and 1530 should be weather-partly-rainy icon (official IMS icons have 3 drops not MDI icons, 1 drop is for statuses 1540 and 1530)
but why day is sunny, and hourly is rain?
Let's make sure you understand how this works.
The py package / component calls IMS every period of time to a single endpoing:
https://ims.gov.il/he/city_portal/2 - (language: he
and city: 2
= Tel Aviv).
There it gets 3 types of data.
Under analysis
field - is the current weather = no forecast.
under forecast_data
- you get two types of forecasts:
daily
hourly
This is self explainatory really, but in your picture you compare the hourly
data (need to mention that not all hours are with weather_code
status and if it's missing and it's the first hour, the "current" weather code from analysis
would be used) and the analysis/current
fields - which may be different.@GuyKh so Weather: {{ states("weather.ims_weather") }}
should give me real time data? And not today forecast?
It should give the analysis value, not forecast
And analysis:"weather_code":null
.... I just thinking that weather.ims_weather should return weather right now or forecast for today otherwise data is not relevant to show on any dashboard
@chepa92 This - is how the WeatherEntity condition is being calculated - some fallback flow there too
@GuyKh Everything says it's rainy today, but WeatherEntity still telling it's cloudy, sorry, I don't know how debug this component
Checked again with city = 7 (Netanya): Everything says "Rainy" ![Uploading image.png…]()
Both of my HA instances don't see any rain :(
@chepa92 - are you talking about city 7 (Netanya)?
@GuyKh yes
@chepa92 - The only thing I can think of is that this is a sync issue - Can you try to: A) Restart HomeAssistant and see if this changes? B) Remove the integration, restart and re-add it again and see if this changes?
@GuyKh same issue here after I tried to restart HA and re-install integration.
according to HA forecast it is partlycloudy
all week when it should also be raining (city code: 20)...
HA
IMS
Ok, so, once again - @eyarz and @chepa92 Please don't compare the icons in IMS site and the icons in the integration, that's two systems which implement "weather_code - to - icon" individually.
I'm looking at city = 20 = Ramla. Looking at the data that IMS exposes: https://ims.gov.il/en/city_portal/20
https://ims.gov.il/en/city_portal/20
^^^ ^^^
Language CityCode
I'm getting in Json:
// Current Weather
data.analysis.weather_code = 1540
// Hourly Forecast
data.forecast_data.hourly."11:00".weather_code = 1540
Looking at the mapping I mentioned above - 1540
is translated to: mdi:weather-partly-rainy
(see here)
In the sensor description (sensor.ims_today
) - I'm seeing:
11:00:
weather:
value: Cloudy, possible rain
icon: mdi:weather-partly-rainy
temperature:
value: 15.3
unit: °C
About WeatherSensor.
You can see here - that 1540
is translated to HomeAssistant condition ATTR_CONDITION_PARTLYCLOUDY
- This is all the variants in HomeAssistant conditions.
Looking at the IMS weather_code description - when checking 1540
:
{
"id": "14",
"desc_en": "Cloudy, possible rain",
"weather_code": "1540",
"ims_order": "14",
"night": "0",
"display": "1",
"desc": "Cloudy, possible rain"
},
So "Cloudy, possible rain" - could be translated to a different condition - but that's a whole different discussion than the saying "Wrong Data" - you're putting on here. Also - as you can see in the SensorDescription "Cloudy, Possible Rain" is there
thank you for the detailed answer!
so basically I should ignore the icons at weather.ims_weather
because they are not translated correctly.
Is there a recommended way to create a card that can show me a weather forecast correctly?
@eyarz I actually suggest you to do the opposite and suggest a fix, i.e. What mapping should we correct?
@eyarz @chepa92 - I've done some changes in the icon mapping. Can you update to 0.1.24 and give it a try?
Wow, that was a quick fix! I updated to version 0.1.24 and the icons looks the same as the IMS forecast 🤩
I believe the new get_forecast service reports forecast shifted to one day to the past in Your integration. I mean the first day in the forecast should be today, but actually it is for yesterday.
I accidentally noticed it when called the service from developers tools in Home Assistant. Returned forecast has first entry dated day before at T21:00:00+00:00 , but probably should be at midnight on the current day. It make sense because Israeli local time is UTC+3.
My guess you are using local time when calling the service, but the service is using UTC