dobrý den, hluboce děkuji za vaši skvěle funkční, užitečnou, rodinný rozpočet šetřící integraci! Jsem lama. Základ YAMLu zvládám jen díky ChatGPT. Rozchodil jsem tak automatizaci tlumení a boostování tepelného čerpadla podle aktuální spotové ceny. A dále automatizaci povolování discharge FVE baterky ve spotově dražších hodinách. Na tohle ale zatím nemám: mořím se s automatizací, která by: když se mezi 00:01 - 5:59 hodinou ranní vyskytuje hodina s cenou (nízkou) X a když se mezi 6:01 - 8:59 hodinou ranní vyskytuje hodina s cenou o více než 2,9 Kč vyšší než cena X, tak se nabije FVE baterka ze sítě za onu nízkou cenu a v onu pozdější ranní hodinu se spotovou cenou o těch více než 2,9 Kč vyšší se začne vybíjet. Lze vubec takovou logiku nasadit do configuration.yaml + automations.yaml nebo by to žádalo nový sensor/y ve vaší integraci?
díky
Ivo
jen pro pobavení přikládám, jak se lama radí s ChatGPT,
je tam asi problém se zamířením na atribut(y) časů/cen v sensor.current_spot_electricity_price
mé pokusné zadání ChatGPT:
I need help with home assistant configuration.yaml and automations.yaml:
I have a sensor with the following attributes: timestamps as keys (example: 2023-03-13T00:00:00+01:00) and prices as values (example: 1,64)
I need to code a sensor, which reads the timestamps and the prices in the following time window A: 00:00 - 05:59.
I need to code a sensor, which reads the timestamps and the prices in the following time window B: 06:01 - 08:59.
If there is a price found in time window B which is higher by more than 2,9 than a price in time window A, then I need to create 2 following time entities:
time_of_2_9lower_price_within_0000_0559
time_of_2_9higher_price_within_0601_0859
odpověď ChatGPT:
To accomplish this task, you can define two Template Sensors in your configuration.yaml file to filter the data from the sensor with timestamps and prices. Then, you can define two Automations in your automations.yaml file to check the conditions and create the two time entities if necessary.
Here is an example of how you can define the Template Sensors in your configuration.yaml file:
platform: template
sensors:
prices_window_a:
friendly_name: "Prices Window A"
value_template: >
{% set start_time = '00:00:00' %}
{% set end_time = '05:59:59' %}
{% set prices = state_attr('sensor.current_spot_electricity_price', 'prices') %}
{% set prices_window_a = {k: v for k, v in prices.items() if start_time <= k[-9:-6] <= end_time} %}
{% set prices_window_a_str = ', '.join([f'{k}: {v}' for k, v in prices_window_a.items()]) %}
{{ prices_window_a_str if prices_window_a else 'No prices in Window A' }}
prices_window_b:
friendly_name: "Prices Window B"
value_template: >
{% set start_time = '06:01:00' %}
{% set end_time = '08:59:59' %}
{% set prices = state_attr('sensor.current_spot_electricity_price', 'prices') %}
{% set prices_window_b = {k: v for k, v in prices.items() if start_time <= k[-9:-6] <= end_time} %}
{% set prices_window_b_str = ', '.join([f'{k}: {v}' for k, v in prices_window_b.items()]) %}
{{ prices_window_b_str if prices_window_b else 'No prices in Window B' }}
Note that you need to replace your_sensor_name with the actual name of your sensor entity.
The Template Sensors use the value_template to extract the prices in the specified time windows from the attributes of the sensor entity. They return a string with the timestamps and prices found, or a message indicating that there are no prices in the corresponding time window.
Next, you can define two Automations in your automations.yaml file to check the conditions and create the time entities:
automation:
alias: "Check price difference"
trigger:
platform: state
entity_id: sensor.prices_window_b
condition:
condition: template
value_template: >
{% set start_time = '00:00:00' %}
{% set end_time = '05:59:59' %}
{% set prices_a = state_attr('sensor.current_spot_electricity_price', 'prices') | selectattr('timestamp', '>=', start_time) | selectattr('timestamp', '<=', end_time) | list %}
{% set prices_b = state_attr('sensor.current_spot_electricity_price', 'prices') | selectattr('timestamp', '>=', '06:01:00') | selectattr('timestamp', '<=', '08:59:59') | list %}
{% set prices_a_max = prices_a | max(attribute='price') %}
{% set prices_b_max = prices_b | max(attribute='price') %}
{% if prices_b_max - prices_a_max > 2.9 %}
{% set time_lower_2_9 = prices_a | selectattr('price', '<=', prices_b_max - 2.9) | map(attribute='timestamp') | list | first %}
{% set time_higher_2_9 = prices_b | selectattr('price', '==', prices_b
dobrý den, hluboce děkuji za vaši skvěle funkční, užitečnou, rodinný rozpočet šetřící integraci! Jsem lama. Základ YAMLu zvládám jen díky ChatGPT. Rozchodil jsem tak automatizaci tlumení a boostování tepelného čerpadla podle aktuální spotové ceny. A dále automatizaci povolování discharge FVE baterky ve spotově dražších hodinách. Na tohle ale zatím nemám: mořím se s automatizací, která by: když se mezi 00:01 - 5:59 hodinou ranní vyskytuje hodina s cenou (nízkou) X a když se mezi 6:01 - 8:59 hodinou ranní vyskytuje hodina s cenou o více než 2,9 Kč vyšší než cena X, tak se nabije FVE baterka ze sítě za onu nízkou cenu a v onu pozdější ranní hodinu se spotovou cenou o těch více než 2,9 Kč vyšší se začne vybíjet. Lze vubec takovou logiku nasadit do configuration.yaml + automations.yaml nebo by to žádalo nový sensor/y ve vaší integraci? díky Ivo
jen pro pobavení přikládám, jak se lama radí s ChatGPT, je tam asi problém se zamířením na atribut(y) časů/cen v sensor.current_spot_electricity_price
mé pokusné zadání ChatGPT: I need help with home assistant configuration.yaml and automations.yaml: I have a sensor with the following attributes: timestamps as keys (example: 2023-03-13T00:00:00+01:00) and prices as values (example: 1,64) I need to code a sensor, which reads the timestamps and the prices in the following time window A: 00:00 - 05:59. I need to code a sensor, which reads the timestamps and the prices in the following time window B: 06:01 - 08:59. If there is a price found in time window B which is higher by more than 2,9 than a price in time window A, then I need to create 2 following time entities: time_of_2_9lower_price_within_0000_0559 time_of_2_9higher_price_within_0601_0859
odpověď ChatGPT:
To accomplish this task, you can define two Template Sensors in your configuration.yaml file to filter the data from the sensor with timestamps and prices. Then, you can define two Automations in your automations.yaml file to check the conditions and create the two time entities if necessary. Here is an example of how you can define the Template Sensors in your configuration.yaml file:
platform: template sensors: prices_window_a: friendly_name: "Prices Window A" value_template: > {% set start_time = '00:00:00' %} {% set end_time = '05:59:59' %} {% set prices = state_attr('sensor.current_spot_electricity_price', 'prices') %} {% set prices_window_a = {k: v for k, v in prices.items() if start_time <= k[-9:-6] <= end_time} %} {% set prices_window_a_str = ', '.join([f'{k}: {v}' for k, v in prices_window_a.items()]) %} {{ prices_window_a_str if prices_window_a else 'No prices in Window A' }}
prices_window_b: friendly_name: "Prices Window B" value_template: > {% set start_time = '06:01:00' %} {% set end_time = '08:59:59' %} {% set prices = state_attr('sensor.current_spot_electricity_price', 'prices') %} {% set prices_window_b = {k: v for k, v in prices.items() if start_time <= k[-9:-6] <= end_time} %} {% set prices_window_b_str = ', '.join([f'{k}: {v}' for k, v in prices_window_b.items()]) %} {{ prices_window_b_str if prices_window_b else 'No prices in Window B' }}
Note that you need to replace your_sensor_name with the actual name of your sensor entity. The Template Sensors use the value_template to extract the prices in the specified time windows from the attributes of the sensor entity. They return a string with the timestamps and prices found, or a message indicating that there are no prices in the corresponding time window. Next, you can define two Automations in your automations.yaml file to check the conditions and create the time entities:
automation: