lovelace-hourly-weather
lovelace-hourly-weather copied to clipboard
Add sensor domain as an allowed entity for use with card.
The forecast entity is going to be deprecated soon in weather templates. The solution to this is to create a separate template entity with a forecast attribute using the weather.get_forecasts service. Using a sensor like this with this card works perfectly except the following error appears in the home assistant log.
ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [281471474635328] Error handling message: Entity ID 'sensor.hourly_weather2' does not belong to domain 'weather' for dictionary value @ data['entity_id']. Got 'sensor.hourly_weather2' (invalid_format) Jason from 192.168.1.250 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36)
This is my sensor template..
template:
- trigger:
- platform: homeassistant
event: start
- platform: event
event_type: event_template_reloaded
- platform: time_pattern
minutes: /15
- platform: state
entity_id: &forecasts
- weather.windsor
- weather.pirateweather
- weather.forecast_home
from:
- unknown
- unavailable
action:
- service: weather.get_forecasts
data:
type: hourly
target:
entity_id: *forecasts
response_variable: hourly
sensor:
- name: "Hourly Weather2"
unique_id: hourly_weather2
state: "{{ now() }}"
attributes:
forecast: >
{% if hourly is defined %}
{% if hourly['weather.pirateweather'] is defined
and hourly['weather.pirateweather']['forecast'] is defined %}
{{ hourly['weather.pirateweather']['forecast'] }}
{% elif hourly['weather.forecast_home'] is defined
and hourly['weather.forecast_home']['forecast'] is defined %}
{{ hourly['weather.forecast_home']['forecast'] }}
{% elif hourly['weather.windsor'] is defined
and hourly['weather.windsor']['forecast'] is defined %}
{{ hourly['weather.windsor']['forecast'] }}
{% endif %}
{% endif %}