FL550 / dwd_weather

Deutscher Wetterdienst integration for Home-Assistant
MIT License
173 stars 11 forks source link

Forecasted data as triggers #46

Closed sk365 closed 2 years ago

sk365 commented 2 years ago

Hi, thank you for programming this excellent integration. Please allow me a newbie question: How do I use forecasts delivered by the sensor as triggers? For example, I want my window blinds to open if the maximum of forecasted wind speeds within the next n hours exceed a certain threshold. So, how would I access the wind speed in n hours from now? Thank you for your help. Stefan

diplix commented 2 years ago

you’ll have to use a template sensor , i did that to create an alarm if the temperature drops below 0°C.

template:
  - sensor:
      - name: Tiefsttemperatur in 24 h
        unique_id: E74013A7-348C-44F8-B4B1-93E5992C1840
        unit_of_measurement: °C
        state: >-
            {% set tomorrow = (as_timestamp(now() + timedelta(hours=24)) | timestamp_local) %}
            {% set today = state_attr('sensor.temperature_berlin_tegel', 'data')| selectattr('datetime', 'lt', tomorrow) | map(attribute='value') | list %}
            {{ today | min }}

this should also work to get a sensor to show the highest wind speed in the next n hours which can then be used as an automation trigger.

sk365 commented 2 years ago

Oh, thank you so much for your superquick reply, Felix!

Now, how do use of this sensor?

I tried to paste the code below into my configuration.yaml (using my DWD integration cell which happens to be sensor.temperature_berlin_alex) but I cannot see it in my entities list.

Please excuse my probably trivial question - I am really new to Home Assistant.

Thank you so much for your help!

Am 15.03.2022 um 18:48 schrieb felix schwenzel @.***>:

you’ll have to use a template sensor , i did that to create an alarm if the temperature drops below 0°C.

  • sensor:
    • name: Tiefsttemperatur in 24 h unique_id: E74013A7-348C-44F8-B4B1-93E5992C1840 unit_of_measurement: °C state: >- {% set tomorrow = (as_timestamp(now() + timedelta(hours=24)) | timestamp_local) %} {% set today = state_attr('sensor.temperature_berlin_tegel', 'data')| selectattr('datetime', 'lt', tomorrow) | map(attribute='value') | list %} {{ today | min }} this should also work to get a sensor to show the highest wind speed in the next n hours which can then be used as an automation trigger.

— Reply to this email directly, view it on GitHub https://github.com/FL550/dwd_weather/issues/46#issuecomment-1068276659, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALNM4ESWBE3GV3HNNMC5QULVADEP5ANCNFSM5QZI625Q. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.

diplix commented 2 years ago

sorry, i did an incomplete copy&paste missing the template: line. i corrected the code above and hope it works like this.

sk365 commented 2 years ago

Hi Felix,

thank you again. It works now, also with wind and other parameters. But strangely it works only timedelta is set to 12 hours or more. If timedelta is set to a lesser amount, the template sensor yield either 0 or „not available“ I did set the DWD weather integration to 1 hour sampling interval. Any idea what to do?

Best, Stefan

Am 15.03.2022 um 21:42 schrieb felix schwenzel @.***>:

sorry, i did an incomplete copy&paste missing the template: line. i corrected the code above and hope it works like this.

— Reply to this email directly, view it on GitHub https://github.com/FL550/dwd_weather/issues/46#issuecomment-1068449305, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALNM4EVAOF5DQVDOURL6RATVADY4NANCNFSM5QZI625Q. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.

diplix commented 2 years ago

seems to work for me, at least with the temperature.

image
sk365 commented 2 years ago

now working for me, too no idea why it didn’t before thanks again

Am 16.03.2022 um 18:39 schrieb felix schwenzel @.***>:

seems to work for me, at least with the temperature. https://user-images.githubusercontent.com/4541494/158653171-cc7b969e-4aaa-43c7-bd05-4bccae0dc846.png — Reply to this email directly, view it on GitHub https://github.com/FL550/dwd_weather/issues/46#issuecomment-1069389188, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALNM4EQB5Z5LOKPXAB5FFG3VAIMFVANCNFSM5QZI625Q. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.

FL550 commented 2 years ago

Is the sensor showing the forecast data in the correct interval? You can check this in the developer tab

sk365 commented 2 years ago

Yes it is

Am 16.03.2022 um 19:34 schrieb FL550 @.***>:

Is the sensor showing the forecast data in the correct interval?

— Reply to this email directly, view it on GitHub https://github.com/FL550/dwd_weather/issues/46#issuecomment-1069437334, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALNM4EQUVX4M2KIMSJMNTYLVAISUBANCNFSM5QZI625Q. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.

FL550 commented 2 years ago

oh, I oversaw your last comment 😅 glad everything is working now!