Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add support for weather entities with twice_daily forecast #177

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading