Skip to content

Commit

Permalink
Merge pull request #177 from FamousWolf/140-support-weather-forecast-…
Browse files Browse the repository at this point in the history
…twice-daily

[FEATURE] Add support for weather entities with twice_daily forecast
  • Loading branch information
FamousWolf authored Nov 7, 2024
2 parents 82ed8a1 + a686fc2 commit eb08049
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,13 @@ See [Actions documentation](https://www.home-assistant.io/dashboards/actions/).

### Weather

| Name | Type | Default | Supported options | Description | Version |
|----------------------|---------|--------------|------------------------------|----------------------|---------|
| `entity` | string | **Required** | `weather.my_weather_service` | Entity ID | 1.1.0 |
| `showCondition` | boolean | true | `false` \| `true` | Show condition icon | 1.1.0 |
| `showTemperature` | boolean | false | `false` \| `true` | Show temperature | 1.1.0 |
| `showLowTemperature` | boolean | false | `false` \| `true` | Show low temperature | 1.1.0 |
| Name | Type | Default | Supported options | Description | Version |
|----------------------|---------|--------------|------------------------------|--------------------------------------------------------------------------------|---------|
| `entity` | string | **Required** | `weather.my_weather_service` | Entity ID | 1.1.0 |
| `useTwiceDaily` | boolean | false | `false` \| `true` | Use twice daily forecast if your weather entity doesn't support daily forecast | 1.9.0 |
| `showCondition` | boolean | true | `false` \| `true` | Show condition icon | 1.1.0 |
| `showTemperature` | boolean | false | `false` \| `true` | Show temperature | 1.1.0 |
| `showLowTemperature` | boolean | false | `false` \| `true` | Show low temperature | 1.1.0 |

## Custom styling using cardmod

Expand Down
7 changes: 6 additions & 1 deletion src/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ export class WeekPlannerCard extends LitElement {
}
}, {
type: 'weather/subscribe_forecast',
forecast_type: 'daily',
forecast_type: this._weather.useTwiceDaily ? 'twice_daily' : 'daily',
entity_id: this._weather.entity
});
}
Expand Down Expand Up @@ -699,6 +699,11 @@ export class WeekPlannerCard extends LitElement {
const weatherState = this._weather ? this.hass.states[this._weather.entity] : null;
let weatherForecast = {};
this._weatherForecast?.forEach((forecast) => {
// Only use day time forecasts
if (forecast.hasOwnProperty('is_daytime') && forecast.is_daytime === false) {
return;
}

const dateKey = DateTime.fromISO(forecast.datetime).toISODate();
weatherForecast[dateKey] = {
icon: this._getWeatherIcon(forecast),
Expand Down

0 comments on commit eb08049

Please sign in to comment.