From cd1d347eb2fa906188df9d54935f0471c5d81f3a Mon Sep 17 00:00:00 2001 From: Robert Groot <8398505+iamrgroot@users.noreply.github.com> Date: Thu, 21 Dec 2023 17:21:54 +0100 Subject: [PATCH] Add Energyzero get_gas_prices and get_energy_price services (#29143) * Update energyzero.markdown * Update energyzero.markdown * Added required parameter * Align wording with easyEnergy * Set incl vat as required --------- Co-authored-by: c0ffeeca7 --- source/_integrations/energyzero.markdown | 97 ++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/source/_integrations/energyzero.markdown b/source/_integrations/energyzero.markdown index 687f0179a70..ee3088d958b 100644 --- a/source/_integrations/energyzero.markdown +++ b/source/_integrations/energyzero.markdown @@ -52,3 +52,100 @@ Every day around **14:00 UTC time**, the new prices are published for the follow For the dynamic gas prices, only entities are created that display the `current` and `next hour` price because the price is always fixed for 24 hours; new prices are published every morning at **05:00 UTC time**. + +## Services + +The energy and gas prices are exposed using [service calls](/docs/scripts/service-calls/). The services populate [Response Data](/docs/scripts/service-calls#use-templates-to-handle-response-data) with price data. + +### Service `energyzero.get_gas_prices` + +Fetches the gas prices. + +| Service data attribute | Optional | Description | Example | +| ---------------------- | -------- | ----------- | --------| +| `incl_vat` | no | Defines whether the prices include or exclude VAT. | false +| `start` | yes | Start time to get prices. Defaults to today 00:00:00 | 2023-01-01 00:00:00 +| `end` | yes | End time to get prices. Defaults to today 00:00:00 | 2023-01-01 00:00:00 + +### Response data + +The response data is a dictionary with the gas timestamps and prices as string and float values. + +{% raw %} + +```json +{ + "prices": [ + { + "timestamp": "2023-09-25 03:00:00+00:00", + "price": 1.1 + }, + { + "timestamp": "2023-09-25 04:00:00+00:00", + "price": 1.05 + } + ] +} + +``` + +{% endraw %} + +### Service `energyzero.get_energy_prices` + +Fetches the energy prices. + +| Service data attribute | Optional | Description | Example | +| ---------------------- | -------- | ----------- | --------| +| `incl_vat` | no | Defines whether the prices include or exclude VAT. | false +| `start` | yes | Start time to get prices. Defaults to today 00:00:00 | 2023-01-01 00:00:00 +| `end` | yes | End time to get prices. Defaults to today 00:00:00 | 2023-01-01 00:00:00 + +### Response data + +The response data is a dictionary with the energy timestamps and prices as string and float values. + +{% raw %} + +```json +{ + "prices": [ + { + "timestamp": "2023-09-25 03:00:00+00:00", + "price": 0.05 + }, + { + "timestamp": "2023-09-25 04:00:00+00:00", + "price": 0.12 + } + ] +} +``` + +{% endraw %} + +### Add response to sensor + +The response data can be added to a template sensor: + +{% raw %} + +```yaml +template: + - trigger: + - platform: time_pattern + hours: "*" + action: + - service: energyzero.get_energy_prices + response_variable: prices + data: + incl_vat: false + sensor: + - name: Energy prices + device_class: timestamp + state: "{{ now() }}" + attributes: + prices: '{{ prices }}' +``` + +{% endraw %}