From a27ed17e99e15de1dd4c3e3fc2527da6a019cc16 Mon Sep 17 00:00:00 2001 From: fwestenberg <47930023+fwestenberg@users.noreply.github.com> Date: Sat, 15 Feb 2025 09:17:44 +0000 Subject: [PATCH 1/5] Add Stookwijzer forecast service description --- source/_integrations/stookwijzer.markdown | 79 +++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/source/_integrations/stookwijzer.markdown b/source/_integrations/stookwijzer.markdown index e5198521c606..3a048794fa76 100644 --- a/source/_integrations/stookwijzer.markdown +++ b/source/_integrations/stookwijzer.markdown @@ -30,3 +30,82 @@ Additionally, various sensor entities are provided: - **Air Quality Index**: Sensor containing the air quality index at the selected location. {% include integrations/config_flow.md %} + +## Action `stookwijzer.get_forecast` + +This action populates [response data](/docs/scripts/perform-actions#use-templates-to-handle-response-data) +with a mapping of the Stookwijzer advice forecast. + +```yaml +action: stookwijzer.get_forecast +target: + entity_id: + - sensor.stookwijzer_advice_code +response_variable: stookwijzer_forecast +``` + +The response data field is a mapping of called target entities, each containing the `forecast` field. +`forecast` is a list of forecasted advices at a given point in time: + +| Response data | Description | Example | +| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- | +| `datetime` | The time of the forecasted advice. | 2025-01-14T14:00:00+00:00 | +| `advice` | The forecasted advice code. | code_yellow | +| `final` | Indicator whether the advice is final or can still change. | True | + +## Examples + +{% details "Example template sensor using get_forecast" %} + +Example template sensors containing the Stookwijzer forecast for 6 and 12 hours from now. + +{% raw %} + +```yaml +template: + - trigger: + - trigger: time_pattern + hours: /1 + action: + - action: stookwijzer.get_forecast + target: + entity_id: sensor.stookwijzer_advice_code + response_variable: advice_forecast + sensor: + - name: Stookwijzer forecast 6 hours + unique_id: stookwijzer_forecast_6_hours + state: "{{ advice_forecast['sensor.stookwijzer_advice_code'][0]['advice'] }}" + attributes: + final: "{{ advice_forecast['sensor.stookwijzer_advice_code'][0]['final'] }}" + timestamp: "{{ advice_forecast['sensor.stookwijzer_advice_code'][0]['datetime'] }}" + - name: Stookwijzer forecast 12 hours + unique_id: stookwijzer_forecast_12_hours + state: "{{ advice_forecast['sensor.stookwijzer_advice_code'][1]['advice'] }}" + attributes: + final: "{{ advice_forecast['sensor.stookwijzer_advice_code'][1]['final'] }}" + timestamp: "{{ advice_forecast['sensor.stookwijzer_advice_code'][1]['datetime'] }}" +``` + +{% endraw %} + +{% enddetails %} + +{% details "Example action response" %} + +```yaml +sensor.stookwijzer_advice_code: + - datetime: "2025-02-12T17:00:00+01:00" + advice: code_yellow + final: "True" + - datetime: "2025-02-12T23:00:00+01:00" + advice: code_yellow + final: "True" + - datetime: "2025-02-13T05:00:00+01:00" + advice: code_orange + final: "False" + - datetime: "2025-02-13T11:00:00+01:00" + advice: code_red + final: "False" +``` + +{% enddetails %} From aa912d3f3877be52be42acaea292986cd0591ba7 Mon Sep 17 00:00:00 2001 From: fwestenberg <47930023+fwestenberg@users.noreply.github.com> Date: Sun, 16 Feb 2025 16:26:19 +0000 Subject: [PATCH 2/5] Update service get_forecast description --- source/_integrations/stookwijzer.markdown | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/source/_integrations/stookwijzer.markdown b/source/_integrations/stookwijzer.markdown index 3a048794fa76..27183fd652ce 100644 --- a/source/_integrations/stookwijzer.markdown +++ b/source/_integrations/stookwijzer.markdown @@ -39,13 +39,12 @@ with a mapping of the Stookwijzer advice forecast. ```yaml action: stookwijzer.get_forecast target: - entity_id: - - sensor.stookwijzer_advice_code + config_entry_id: 12345 response_variable: stookwijzer_forecast ``` -The response data field is a mapping of called target entities, each containing the `forecast` field. -`forecast` is a list of forecasted advices at a given point in time: +The response data field contains the `forecast` field. +`forecast` is a list of forecast advice entries at a given moment in time: | Response data | Description | Example | | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- | @@ -74,16 +73,16 @@ template: sensor: - name: Stookwijzer forecast 6 hours unique_id: stookwijzer_forecast_6_hours - state: "{{ advice_forecast['sensor.stookwijzer_advice_code'][0]['advice'] }}" + state: "{{ advice_forecast['forecast'][0]['advice'] }}" attributes: - final: "{{ advice_forecast['sensor.stookwijzer_advice_code'][0]['final'] }}" - timestamp: "{{ advice_forecast['sensor.stookwijzer_advice_code'][0]['datetime'] }}" + final: "{{ advice_forecast['forecast'][0]['final'] }}" + timestamp: "{{ advice_forecast['forecast'][0]['datetime'] }}" - name: Stookwijzer forecast 12 hours unique_id: stookwijzer_forecast_12_hours - state: "{{ advice_forecast['sensor.stookwijzer_advice_code'][1]['advice'] }}" + state: "{{ advice_forecast['forecast'][1]['advice'] }}" attributes: - final: "{{ advice_forecast['sensor.stookwijzer_advice_code'][1]['final'] }}" - timestamp: "{{ advice_forecast['sensor.stookwijzer_advice_code'][1]['datetime'] }}" + final: "{{ advice_forecast['forecast'][1]['final'] }}" + timestamp: "{{ advice_forecast['forecast'][1]['datetime'] }}" ``` {% endraw %} @@ -93,7 +92,7 @@ template: {% details "Example action response" %} ```yaml -sensor.stookwijzer_advice_code: +forecast: - datetime: "2025-02-12T17:00:00+01:00" advice: code_yellow final: "True" From 26e870a0e1325aecf1282510d8527c1dc27c8b85 Mon Sep 17 00:00:00 2001 From: fwestenberg <47930023+fwestenberg@users.noreply.github.com> Date: Sun, 16 Feb 2025 17:36:45 +0000 Subject: [PATCH 3/5] Update Stookwijzer service description --- source/_integrations/stookwijzer.markdown | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/_integrations/stookwijzer.markdown b/source/_integrations/stookwijzer.markdown index 27183fd652ce..f831dd0413f9 100644 --- a/source/_integrations/stookwijzer.markdown +++ b/source/_integrations/stookwijzer.markdown @@ -44,7 +44,7 @@ response_variable: stookwijzer_forecast ``` The response data field contains the `forecast` field. -`forecast` is a list of forecast advice entries at a given moment in time: +`forecast` is a list of forecast advice entries at a given time: | Response data | Description | Example | | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- | @@ -95,16 +95,16 @@ template: forecast: - datetime: "2025-02-12T17:00:00+01:00" advice: code_yellow - final: "True" + final: True - datetime: "2025-02-12T23:00:00+01:00" advice: code_yellow - final: "True" + final: True - datetime: "2025-02-13T05:00:00+01:00" advice: code_orange - final: "False" + final: False - datetime: "2025-02-13T11:00:00+01:00" advice: code_red - final: "False" + final: False ``` {% enddetails %} From 2451408faff29ea4079c101191b33d6a9aa33f48 Mon Sep 17 00:00:00 2001 From: fwestenberg <47930023+fwestenberg@users.noreply.github.com> Date: Wed, 26 Feb 2025 20:43:26 +0000 Subject: [PATCH 4/5] Improve Stookwijzer documentation --- Gemfile.lock | 12 +++-- source/_integrations/stookwijzer.markdown | 53 ++++++++++++----------- 2 files changed, 36 insertions(+), 29 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2f024225dd98..3236e85987df 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -27,9 +27,13 @@ GEM eventmachine (>= 0.12.9) http_parser.rb (~> 0) eventmachine (1.2.7) + ffi (1.17.1-aarch64-linux-gnu) ffi (1.17.1-arm64-darwin) ffi (1.17.1-x86_64-linux-gnu) forwardable-extended (2.6.0) + google-protobuf (4.29.3-aarch64-linux) + bigdecimal + rake (>= 13) google-protobuf (4.29.3-arm64-darwin) bigdecimal rake (>= 13) @@ -85,6 +89,8 @@ GEM multi_json (1.15.0) mustermann (3.0.3) ruby2_keywords (~> 0.0.1) + nokogiri (1.18.2-aarch64-linux-gnu) + racc (~> 1.4) nokogiri (1.18.2-arm64-darwin) racc (~> 1.4) nokogiri (1.18.2-x86_64-linux-gnu) @@ -139,10 +145,9 @@ GEM ruby2_keywords (0.0.5) safe_yaml (1.0.5) sass (3.4.25) - sass-embedded (1.83.4-arm64-darwin) - google-protobuf (~> 4.29) - sass-embedded (1.83.4-x86_64-linux-gnu) + sass-embedded (1.83.4) google-protobuf (~> 4.29) + rake (>= 13) sass-globbing (1.1.5) sass (>= 3.1) sassc (2.1.0) @@ -169,6 +174,7 @@ GEM webrick (1.9.1) PLATFORMS + aarch64-linux arm64-darwin-23 x86_64-linux diff --git a/source/_integrations/stookwijzer.markdown b/source/_integrations/stookwijzer.markdown index f831dd0413f9..dba7e3c626a4 100644 --- a/source/_integrations/stookwijzer.markdown +++ b/source/_integrations/stookwijzer.markdown @@ -31,9 +31,9 @@ Additionally, various sensor entities are provided: {% include integrations/config_flow.md %} -## Action `stookwijzer.get_forecast` +## Action: Get Forecast -This action populates [response data](/docs/scripts/perform-actions#use-templates-to-handle-response-data) +The `stookwijzer.get_forecast` action populates [response data](/docs/scripts/perform-actions#use-templates-to-handle-response-data) with a mapping of the Stookwijzer advice forecast. ```yaml @@ -46,11 +46,31 @@ response_variable: stookwijzer_forecast The response data field contains the `forecast` field. `forecast` is a list of forecast advice entries at a given time: -| Response data | Description | Example | -| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- | -| `datetime` | The time of the forecasted advice. | 2025-01-14T14:00:00+00:00 | -| `advice` | The forecasted advice code. | code_yellow | -| `final` | Indicator whether the advice is final or can still change. | True | +| Response data | Description | Example | +|--------------|-----------------------------------------------------------------------------|---------------------------| +| `datetime` | The time of the forecasted advice. | 2025-01-14T14:00:00+00:00 | +| `advice` | The forecasted advice code. | code_yellow | +| `final` | Indicator whether the advice is final or can still change. | True | + +{% details "Example action response" %} + +```yaml +forecast: + - datetime: "2025-02-12T17:00:00+01:00" + advice: code_yellow + final: True + - datetime: "2025-02-12T23:00:00+01:00" + advice: code_yellow + final: True + - datetime: "2025-02-13T05:00:00+01:00" + advice: code_orange + final: False + - datetime: "2025-02-13T11:00:00+01:00" + advice: code_red + final: False +``` + +{% enddetails %} ## Examples @@ -89,22 +109,3 @@ template: {% enddetails %} -{% details "Example action response" %} - -```yaml -forecast: - - datetime: "2025-02-12T17:00:00+01:00" - advice: code_yellow - final: True - - datetime: "2025-02-12T23:00:00+01:00" - advice: code_yellow - final: True - - datetime: "2025-02-13T05:00:00+01:00" - advice: code_orange - final: False - - datetime: "2025-02-13T11:00:00+01:00" - advice: code_red - final: False -``` - -{% enddetails %} From b0817c9abac87debad4786e5791e1899a0f351fe Mon Sep 17 00:00:00 2001 From: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com> Date: Thu, 27 Feb 2025 05:45:40 +0100 Subject: [PATCH 5/5] revert changes to gemfile --- Gemfile.lock | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 29daaba46832..09fd5b582775 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -27,13 +27,9 @@ GEM eventmachine (>= 0.12.9) http_parser.rb (~> 0) eventmachine (1.2.7) - ffi (1.17.1-aarch64-linux-gnu) ffi (1.17.1-arm64-darwin) ffi (1.17.1-x86_64-linux-gnu) forwardable-extended (2.6.0) - google-protobuf (4.29.3-aarch64-linux) - bigdecimal - rake (>= 13) google-protobuf (4.29.3-arm64-darwin) bigdecimal rake (>= 13) @@ -149,7 +145,6 @@ GEM google-protobuf (~> 4.29) sass-embedded (1.85.1-x86_64-linux-gnu) google-protobuf (~> 4.29) - rake (>= 13) sass-globbing (1.1.5) sass (>= 3.1) sassc (2.1.0) @@ -176,7 +171,6 @@ GEM webrick (1.9.1) PLATFORMS - aarch64-linux arm64-darwin-23 x86_64-linux