- alias: Laden - Load balancing description: Deze automatisering controleert of je teveel stroom verbruikt op je meter en schakeltde laadpaal af indien nodig mode: single triggers: - seconds: '30' trigger: time_pattern conditions: - condition: state entity_id: sensor.laadpaal state: Charging Normal actions: - if: - condition: numeric_state entity_id: sensor.max_stroom_op_fase above: 23 then: - target: entity_id: number.laadpaal_max_station_current data: value: '{{ states(''number.laadpaal_max_station_current'') | int - 2 }}' alias: verlaag met 1 ampere action: number.set_value else: - condition: numeric_state entity_id: sensor.max_stroom_op_fase below: 20 - condition: not conditions: - condition: state entity_id: number.laadpaal_max_station_current state: '16' alias: Test charge rate is not already at the 16 amp maximum - target: entity_id: number.laadpaal_max_station_current data: value: '{{ states(''number.laadpaal_max_station_current'') | int + 1 }}' alias: Increase charging rate by 1 amp action: number.set_value - alias: Laden - Periodieke controle description: Deze automatisering start op elke eerste minuut van een nieuw uur en bepaalt of er geladen moet worden of niet triggers: - trigger: time_pattern minutes: '0' conditions: - condition: or conditions: - condition: state entity_id: sensor.laadpaal state: Charging Normal - condition: state entity_id: sensor.laadpaal state: Wait Vehicle Charging - condition: state entity_id: sensor.laadpaal state: Load Balancing Forced Off actions: - choose: - conditions: - condition: template value_template: "{% for item in states('input_text.goedkopelaadtijden') |\ \ from_json %}\n {% if item.hour == now().hour %}\n {{ True }}\n {%\ \ endif %}\n{% endfor %}" sequence: - target: entity_id: number.laadpaal_max_station_current data: value: '16' alias: Activeer laden action: number.set_value - action: notify.mobile_app_iphone metadata: {} data: message: De auto gaat nu laden omdat dit uur goedkoop is. title: Auto laden default: - alias: Laden stoppen target: entity_id: number.laadpaal_max_station_current data: value: '0' action: number.set_value mode: single - alias: Laden - Start bepalen description: Als de laadkabel aangesloten is dan zal met deze automation gevraagd worden hoe je wil laden. Hierna zal het laden wel of niet gestart worden afhankelijk van de goedkope uren triggers: - trigger: state entity_id: - sensor.laadpaal from: Available to: null conditions: [] actions: - alias: Variabelen aanmaken voor de keuzemogelijkheden variables: action_fast: '{{ ''FAST'' }}' action_work: '{{ ''WORK'' }}' action_cheap: '{{ ''CHEAP'' }}' - alias: Vraag hoe de auto geladen moet worden action: notify.mobile_app_iphone data: message: De auto gaat laden. Hoe wil je de auto laden? data: actions: - action: '{{ action_fast }}' title: Zo snel mogelijk - action: '{{ action_work }}' title: Voor 6 uur - action: '{{ action_cheap }}' title: Binnen 24 uur - alias: Wacht op antwoord vanuit de melding hoe de auto geladen moet worden wait_for_trigger: - event_type: mobile_app_notification_action event_data: action: '{{ action_fast }}' trigger: event - event_type: mobile_app_notification_action event_data: action: '{{ action_work }}' trigger: event - event_type: mobile_app_notification_action event_data: action: '{{ action_cheap }}' trigger: event timeout: hours: 0 minutes: 5 seconds: 0 milliseconds: 0 - alias: De helper instellen wanneer het laden klaar moet zijn choose: - conditions: - condition: template value_template: '{{ wait.trigger.event.data.action == action_work }}' sequence: - action: input_number.set_value target: entity_id: input_number.laden_klaar data: value: 6 alias: Deze actie zal worden uitgevoerd als er voor 6 uur gekozen is - conditions: - condition: template value_template: '{{ wait.trigger.event.data.action == action_cheap }}' sequence: - action: input_number.set_value target: entity_id: input_number.laden_klaar data: value: '{{ now().hour }}' alias: Deze actie zal worden uitgevoerd als er binnen 24 uur gekozen is - conditions: - condition: template value_template: '{{ wait.trigger.event.data.action == action_fast }}' sequence: - action: input_number.set_value target: entity_id: input_number.laden_klaar data: value: -1 alias: Deze actie zal worden uitgevoerd als er voor zo snel mogelijk gekozen is - delay: hours: 0 minutes: 0 seconds: 1 milliseconds: 0 - variables: autocapacity: 60 chargercapacity: 11 kwhladen: '{{ autocapacity * (0.01 * states(''sensor.tesla_battery_level'') | int) }}' tijdladen: '{{ ((autocapacity - kwhladen) / chargercapacity) | int }}' tijdladenafgerond: '{{ ((tijdladen + 1) | round(0, ''ceil'', default)) | int }}' alias: Bereken het aantal uur dat er nodig is om te laden - variables: prices_today: '{{ state_attr(''sensor.nordpool_kwh_nl_eur_2_11_031'', ''today'') }}' prices_today_ns: "{% set nstoday = namespace(items=[]) %}\n{% for price in prices_today\ \ %}\n {% set nstoday.items = nstoday.items + [{'hour': loop.index0, 'price':\ \ price}] %}\n{% endfor %}\n{% if states('input_number.laden_klaar') == '-1.0'\ \ %}\n {% set endtime = (now().hour + tijdladenafgerond) | int %}\n {{ nstoday.items\ \ | sort(attribute='price') | selectattr('hour','>=', now().hour) | selectattr('hour',\ \ '<', endtime) | list }}\n{% else %}\n {{ (nstoday.items | sort(attribute='price')\ \ | selectattr('hour', '>=', now().hour) | list)[:tijdladenafgerond] }}\n\ {% endif %}\n" prices_tomorrow: '{{ state_attr(''sensor.nordpool_kwh_nl_eur_2_11_031'', ''tomorrow'') }}' prices_tomorrow_ns: "{% set nstomorrow = namespace(items=[]) %}\n{% for price\ \ in prices_tomorrow %}\n {% set nstomorrow.items = nstomorrow.items + [{'hour':\ \ loop.index0, 'price': price}] %}\n{% endfor %}\n{% if (now().hour + tijdladenafgerond)\ \ > 24 %}\n {% set asap_resthours = 24 - (now().hour + tijdladenafgerond)\ \ %}\n {{ nstomorrow.items | sort(attribute='price') | selectattr('hour',\ \ '<', asap_resthours | int) | list }}\n{% else %}\n {{ (nstomorrow.items\ \ | sort(attribute='price') | selectattr('hour', '<', states('input_number.laden_klaar')\ \ | int) | list)[:tijdladenafgerond] }}\n{% endif %}\n" combined_prices: '{{ (prices_today_ns + prices_tomorrow_ns) | sort(attribute=''price'') }}' alias: Maakt een lijst met de goedkoopste uren om te laden - target: entity_id: input_text.goedkopelaadtijden data: value: '{{ combined_prices[:tijdladenafgerond] | tojson}}' action: input_text.set_value alias: Plaatst de goedkope uren in een helper - delay: hours: 0 minutes: 0 seconds: 2 milliseconds: 0 - choose: - conditions: - condition: template value_template: "{% for item in states('input_text.goedkopelaadtijden') |\ \ from_json %}\n {% if item.hour == now().hour %}\n {{ True }}\n {%\ \ endif %}\n{% endfor %}" sequence: - action: number.set_value metadata: {} data: value: '16' target: entity_id: number.laadpaal_max_station_current - action: notify.mobile_app_iphone metadata: {} data: message: De auto gaat nu laden omdat dit uur goedkoop is. title: Auto laden default: - action: number.set_value metadata: {} data: value: '0' target: entity_id: number.laadpaal_max_station_current - action: notify.mobile_app_iphone metadata: {} data: message: De auto gaat nog niet laden en wacht tot een goedkoop moment. title: Auto laden alias: Activeer het laden als het nu een goedkoop uur is. mode: single