Excellent !! I missed the “action” part of it. Working like a charm now. THANKS
Hi!
Thank you for the great integration into Home Assistant.
I integrated two entities via the region code, and my entities were named by these codes:
The sensor names were like this one:
sensor.dwd_weather_warnings_114713000_aktuelle_warnstufe
Today I updated to Home Assistant 2024.07 and after the update my DWD maps no longer work. I have checked the errors and the names of the entities:
What has happened here? Is it something that came from older changes (and was eventually changed with the restart of HA Update) or something that was triggered by the update itself?
I can change my Markdown cards to update to the new entity names, but I’m wondering why this happened and how to avoid these entity name changes in the future?
Hi,
it seems like you have mistaken the integration. My integration does not provide a “Warnstufe” so I guess this comes from another integration. Can you please confirm this?
Best regards
Hm, yeah. I use this integration: Deutscher Wetterdienst (DWD) Weather Warnings - Home Assistant - so, it’s another one - sorry.
Hello, I tried to install the HACS integration dwd_weather ( GitHub - FL550/dwd_weather: Deutscher Wetterdienst integration for Home-Assistant ). I can see it on the file system after installing it:
\homeassistant\config\custom_components\dwd_weather with all the files.
And also I see the integration in HACS view.
But I have no entities, nothing on the dashboard (only AccuWeather and Openweathermap) -( ok dashboard doesn’t matter,)
it seems to me like something failed to install.
I have already restarted and updated several times.
i run core-2024.7.2 but also did not work on 2024.6.x for me
What am I doing wrong? Thanks for the support!
(I am looking for a better sun_duration_hours prediction for the current day. AccuWeather does not work well for Germany. I quickly checked using
simple_dwd_weatherforecast with SUN_DURATION = “SunD1” # Unit: s property and it seems really good to me!)
With HACS you install the integration. Next step is to enable and configure it.
Go to Einstellungen > Geräte & Dienste
(Settings > Devices & Services
), click on the blue button in the right down corner, and enter “DWD” into the search field.
Noted here in the documentation:
ah, damn. I missed the point that said I should install it like a normal integration after adding it in HACS
Thanks!
You’re welcome!
Btw. I forgot before, if you’re after other things sun related, take a look at this great integration:
Thanks! Looks cool as well - I might need it in the future!
For now I only needed the Sunhours for current day (sum over the whole day). I didn’t find an easy way to extract it from dwd_weather. so I created this python script as a service (setting a helper numerical value) to sum up the “hourly sunhours” to a day total.
EDIT: Actually I noticed that the prediction will decrease during the course of the day because the past forecast hours will drop from the “data” object
To fix this I use another helper variable (type input_text) that stores the sunhours per hour so that the python script can take it from there (last known value) if it has dropped from the forecast data object in the meantime. It’s definitely not so nice to do this without being able to define functions, use json library and other standard python features, but it works (and for me was much easier to do than in jinja)
New Python Script
# From Automation maybe not possible to pass in data?! hardcode IDs here
aggregate_sensor_id = 'sensor.dresden_flughafen_sun_duration'
ha_storevar_string_hourly_id = 'input_text.dwd_current_day_data_storevar'
output_entity_id = 'input_number.sunhours_today_dwd_python_aggregate'
# Read Forecast data
mystate = hass.states.get(aggregate_sensor_id)
mydata = mystate.attributes['data']
# Get Handle to input_text Variable that saves the sunhours per hour in format:
# 00:0.0,01:0.0,02:0.0,03:0.0,04:0.23333333333333334,05:0.48333333333333334,06:0.6666666666666666,07:0.7666666666666667,08:0.8833333333333333,09:0.9,10:0.85,11:0.85,12:0.8,13:0.7666666666666667,14:0.7333333333333333,15:0.6833333333333333,16:0.6833333333333333,17:0.65,18:0.5666666666666667,19:0.36666666666666664,20:0.0,21:0.0,22:0.0,23:0.0
# to save this string, an attribute "data" is used because the state seems to be limited to 255 characters
ha_storevar_string_hourly_obj = hass.states.get(ha_storevar_string_hourly_id)
ha_storevar_string_hourly = ha_storevar_string_hourly_obj.attributes['data']
# Get Data for Today from DWD
matchstr = str(datetime.datetime.now())[:10] + "T" # Today
predictions_today_list = [hourdict for hourdict in mydata if hourdict["datetime"].startswith(matchstr)]
# Create Dict to read values easier: key:hour_str_2digit, value = sunhours_h (for respective hour)
predictions_today_dict = {hourdict["datetime"][11:13]:hourdict["value"]/3600.0 for hourdict in predictions_today_list}
# Iterate over each hour of today
sunhours = {}
for hour in range(24):
hour_2digit = str(hour).zfill(2)
# check if this hour in dwd data
if hour_2digit in predictions_today_dict:
# then use it from there
sunhours[hour_2digit] = predictions_today_dict[hour_2digit]
else:
# take from variable
# sunhours[hour_2digit] = read_from_varstring(ha_storevar_string_hourly, hour_2digit)
# doing this without defining a function (function not possible?)
startpos = ha_storevar_string_hourly.index(hour_2digit + ":")
remaining_string = ha_storevar_string_hourly[startpos:]
if "," in remaining_string:
# case: not last item of string
stoppos = remaining_string.index(",")
hour_sunvalue = float(remaining_string[3:stoppos])
else:
# case: last item of string
hour_sunvalue = float(remaining_string[3:])
# print(hour_sunvalue)
sunhours[hour_2digit] = hour_sunvalue
# update the HA variable - Finally output sunhours result to numerical variable
duration_today_h = sum(sunhours.values())
duration_today_h_rounded = round(duration_today_h, 1)
hass.states.set(output_entity_id, duration_today_h_rounded)
# save today sunhours data string in hass variable (update)
inputState = ha_storevar_string_hourly_obj.state
savestring = ",".join([f"{hourstr}:{value}" for hourstr,value in sunhours.items()])
new_attributes = {"data" : savestring}
hass.states.set(ha_storevar_string_hourly_id, inputState, new_attributes)
Old Script (decreasing-sunhours-issue)
# From Automation maybe not possible to pass in data?! hardcode it therefore
aggregate_sensor_id = 'sensor.dresden_flughafen_sun_duration'
output_entity_id = 'input_number.sunhours_today_dwd_python_aggregate'
mystate = hass.states.get(aggregate_sensor_id)
mydata = mystate.attributes['data']
matchstr = str(datetime.datetime.now())[:10] + "T" # Today, # building without forbidden strftime
sun_durations_today = [hourdict["value"]/3600.0 for hourdict in mydata if hourdict["datetime"].startswith(matchstr)]
duration_today_h = sum(sun_durations_today)
duration_today_h_rounded = round(duration_today_h, 1)
# set state
hass.states.set(output_entity_id, duration_today_h_rounded)
Hi!
I’m getting a log entry for a few days now (can’t say since when, sorry!), that tells me I should open an issue.
It’s not really dramatic, so I thought I’ll just post it here:
Logger: homeassistant.helpers.entity
Quelle: helpers/entity.py:1183
Erstmals aufgetreten: 18:43:12 (1 Vorkommnisse)
Zuletzt protokolliert: 18:43:12Updating state for sensor.xxx_stundlich_sonnenscheindauer (<class ‘custom_components.dwd_weather.sensor.DWDWeatherForecastSensor’>) took 0.421 seconds. Please create a bug report at Issues · FL550/dwd_weather · GitHub
As I said, I don’t see this as dramatic, as the time is not really that much, but if you want me to investigate this further, please let me know!
Thanks, I’ll will look into this.
How i can use the new Charts Feature?