Hello together,
I tried to setup up starting the dishwasher with lowest prices with the help of this:
I changed the code a little bit to be able to play with some values.
- trigger:
- trigger: state
entity_id: switch.siemens_geschirrspueler_powerstate
from: "off"
to: "on"
for: "00:00:10"
sensor:
- name: Starte Geschirrspueler
unique_id: sensor.starte_geschirrspueler
device_class: timestamp
state: >
{% set start = states('input_datetime.cheap_power_start') %}
{% set end = states('input_datetime.cheap_power_end') %}
{% set sensor = 'sensor.epex_spot_data_net_price' %}
{% set hours = states('sensor.programmdauer_geschirrspueler') | float %}
{% if states('input_boolean.cheap_power_tomorrow') == 'on' %}
{% set tomorrow = true %}
{% else %}
{% set tomorrow = false %}
{% endif %}
{#{ tomorrow }#}
{#{ start}#}
{#{ end }#}
{#{ hours }#}
{% if hours >= 0 %}
{% from 'cheapest_energy_hours.jinja' import cheapest_energy_hours %}
{% set startingtime = cheapest_energy_hours(sensor='sensor.epex_spot_data_net_price', hours=hours, start=start, end=end, look_ahead=true, include_tomorrow=tomorrow) %}
{{ as_timestamp(startingtime) | timestamp_custom('%H:%M', true) }}
{% else %}
False
{% endif %}
availability: >
{{
not is_state('sensor.siemens_geschirrspueler_operationstate','BSH.Common.EnumType.OperationState.Run')
}}
“hours” come from here:
- trigger:
- trigger: state
entity_id: switch.siemens_geschirrspueler_powerstate
from: "off"
to: "on"
for: "00:00:05"
sensor:
- name: "Programmdauer Geschirrspueler"
unique_id: sensor.programmdauer_geschirrspueler
state: >
{% set date1 = as_timestamp(now()) %}
{#{ date1 | timestamp_custom('%D-%H:%M', local=True) }#}
{% set date2 = as_timestamp(states('sensor.siemens_geschirrspueler_remainingprogramtime')) %}
{#{ date2 | timestamp_custom('%D-%H:%M', local=True) }#}
{% set difference = date2 - date1 %}
{% set hours = (difference / 3600) | float(0) | round(2) %}
{{ hours }}
Then I made a test automation:
alias: Strompreis billig
description: ""
triggers:
- trigger: time
at: sensor.starte_geschirrspueler
conditions: []
actions:
- action: notify.mobile_app_sm_g960f
metadata: {}
data:
title: Strompreis TEST
message: >-
Starte Geschirrspüler mit Strompreis: {{
states('sensor.starte_geschirrspueler') }}
- device_id: 8e29dee0847528d111a543048a8af282
domain: button
entity_id: 3790da6843737a6b443d515632e46364
type: press
enabled: false
mode: single
Actually I disabled the start of the dishwasher for testing and decides to send a notification to my mobile.
Unfortunately this doesn’t work. I can run the automation manually then the notification reached my phone.
I can’t spot the mistake in my code. Dev-tools made correct output - but always string altough I convert output to timestamp.
Please help.
BR