jaydeethree / Home-Assistant-weatherdotcom

Home Assistant custom component/integration for Weather.com
GNU General Public License v3.0
35 stars 5 forks source link

Update to work with hourly weather forecast card #3

Closed klopyrev closed 10 months ago

klopyrev commented 11 months ago

These are the changes necessary for the hourly forecast card on a dashboard.

  - show_current: true
    show_forecast: true
    type: weather-forecast
    entity: weather.home_hourly
    forecast_type: hourly
    name: Weather.com
jaydeethree commented 11 months ago

Thanks for this PR! I didn't know that Home Assistant was making these changes, but it looks like they recently made a post about it on the developer blog:

https://developers.home-assistant.io/blog/2023/08/07/weather_entity_forecast_types/

This PR looks good to me, but I'd like to test it first before I commit it. I should have time to test it in the next 1-2 days, and I'll let you know if I see any problems.

klopyrev commented 10 months ago

Thanks. At this point, I'm actually not sure that I need the updated API. Just the datetime update was probably enough for what I'm doing, but in any case I think it's a change in the right direction.

I didn't follow the new design for WeatherEntity exactly. Specifically, it's still 2 classes and implements the forecast attribute. I'm using the lovelace-hourly-weather frontend custom card, which I think still requires the forecast attribute which means 2 classes. This is the bit of Javascript code in the card implementation: "const s=d.entity,l=this.hass.states[s],{forecast:c}=l.attributes"

jaydeethree commented 10 months ago

I tested this and it looks good. Do you know if this will still work with older versions of Home Assistant, like 2023.7? I'm concerned that if I create a new release with this PR, it could break the integration for people who haven't updated to 2023.8 yet.

Thanks for your contribution!

klopyrev commented 10 months ago

I don't know if it works with old version, but it doesn't feel like a change that would break older versions. It doesn't change any existing methods. It just adds new ones.

jaydeethree commented 10 months ago

Yeah, my main concern is that the WeatherEntityFeature enum did not exist in older versions of Home Assistant - it was added in 2023.8:

https://github.com/home-assistant/core/commit/4e300568303c34019ed26f25881591af80e60f99#diff-24c976a75de8af8419fd8031a79c5437a3f4e3d70edb60c9895ae1990be73154R23

So with this PR we're importing a constant that only exists in 2023.8 or later. For now I'll mention this in the release notes and update the minimum version in the README so that people on older versions of Home Assistant hopefully won't update.

Thanks again for your contribution!