Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #───────────────────────────────────────────────────────────────────────────────
- # Description:
- #───────────────────────────────────────────────────────────────────────────────
- # Card to display solar production forecast for the next 24 hours including
- # details on energy import and export rates.
- #
- # A sensor with the hourly weather forecast stored as attributes is required.
- # As of version 2024.4, the weather integration no longer includes forecast data
- # as attributes. A new template sensor must be created to get the forecast data.
- # See more here:
- #
- # https://community.home-assistant.io/t/update-from-using-weather-attributes-with-the-new-service-weather-get-forecasts/702736/1
- #
- # Solar forecast is based on the Solcast integration:
- #
- # https://github.com/oziee/ha-solcast-solar
- #
- # Energy import and export rates are based on the Energi Data Service
- # integration:
- #
- # https://github.com/MTrab/energidataservice
- #───────────────────────────────────────────────────────────────────────────────
- type: markdown
- content: >
- {%- set import_rates = "sensor.import_rates" -%}
- {%- set export_rates = "sensor.export_rates" -%}
- {%- set solar_forecast0 = "sensor.solcast_pv_forecast_forecast_today" -%}
- {%- set solar_forecast1 = "sensor.solcast_pv_forecast_forecast_tomorrow" -%}
- {%- set hourly_weather = "sensor.weather_hourly" -%}
- <table>
- <tr>
- <th width=35px></th>
- <th align=left width=150px><br>Tidspunkt</th>
- <th align=right width=125px>Timepris for<br>køb / salg</th> <th align=right width=125px>Estimeret <br>produktion</th>
- </tr>
- {% if (state_attr(hourly_weather,"forecast")[0].datetime | as_datetime | as_local).hour != now().hour -%}
- <tr>
- <td><ha-icon icon='mdi:weather-{{states("weather.home") |
- replace('partly','partly-') |
- replace('clear-night','night') |
- replace('clear','') |
- replace('lightning','lightning-') |
- replace('snowyrainy','snowy-rainy')-}}'/></ha-icon></td>
- <td>Nu</td>
- <td align=right> {{ "%.2f"|format(state_attr(import_rates,"raw_today")[now().hour].price)}} /
- {{ "%.2f"|format(state_attr(export_rates,"raw_today")[now().hour].price)}}</td>
- <td align=right> {{"%.0f"|format((state_attr(solar_forecast0,"detailedHourly")[now().hour].pv_estimate*1000))}} W</td>
- </tr>
- {% endif -%}
- {% for w in state_attr(hourly_weather,'forecast') -%}
- {% set h=w.datetime | as_datetime | as_local -%} {% if h.day==now().day -%}
- {% set d='I dag' -%}
- {% else %}
- {% set d='I morgen' -%}
- {% endif -%}
- <tr>
- <td> <ha-icon icon='mdi:weather-{{w.condition |
- replace('partly','partly-') |
- replace('clear-night','night') |
- replace('clear','') |
- replace('lightning','lightning-') |
- replace('snowyrainy','snowy-rainy')-}}'/></ha-icon></td>
- <td>{{ d }} {{w.datetime | as_timestamp | timestamp_custom('%H.00', local=True) -}}</td>
- {% if d=='I dag' %}
- <td align=right>{{ "%.2f"|format(state_attr(import_rates,"raw_today")[h.hour].price)}} /
- {{ "%.2f"|format(state_attr(export_rates,"raw_today")[h.hour].price)}}</td>
- <td align=right>{{ "%.0f"|format((state_attr(solar_forecast0,"detailedHourly")[h.hour].pv_estimate*1000))}} W</td>
- </tr>
- {% else %}
- {% if (state_attr(import_rates,"tomorrow_valid") == true) and (state_attr(export_rates,"tomorrow_valid") == true) %}
- <td align=right>{{ "%.2f"|format(state_attr(import_rates,"raw_tomorrow")[h.hour].price)}} /
- {{ "%.2f"|format(state_attr(export_rates,"raw_tomorrow")[h.hour].price)}}</td>
- {% else %}
- <td></td>
- {% endif %}
- <td align=right>{{ "%.0f"|format((state_attr(solar_forecast1,"detailedHourly")[h.hour].pv_estimate*1000))}} W</td>
- </tr>
- {% endif %}
- {% endfor -%}
- </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement