Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- !!! ----------------------------------------------------------------------------------- !!!
- alias: Batteri - Opdater inverter indstillinger hver kvarter
- triggers:
- - minutes: /15
- trigger: time_pattern
- conditions: []
- actions:
- - variables:
- current_time: "{{ now().hour * 100 + now().minute }}"
- time_windows:
- - zone: 1
- start: >-
- {{ states('number.esphome_web_b2bf74_sun12k_time_point_1_start')|int
- }}
- stop: >-
- {{ states('number.esphome_web_b2bf74_sun12k_time_point_2_start')|int
- }}
- - zone: 2
- start: >-
- {{ states('number.esphome_web_b2bf74_sun12k_time_point_2_start')|int
- }}
- stop: >-
- {{ states('number.esphome_web_b2bf74_sun12k_time_point_3_start')|int
- }}
- - zone: 3
- start: >-
- {{ states('number.esphome_web_b2bf74_sun12k_time_point_3_start')|int
- }}
- stop: >-
- {{ states('number.esphome_web_b2bf74_sun12k_time_point_4_start')|int
- }}
- - zone: 4
- start: >-
- {{ states('number.esphome_web_b2bf74_sun12k_time_point_4_start')|int
- }}
- stop: >-
- {{ states('number.esphome_web_b2bf74_sun12k_time_point_5_start')|int
- }}
- - zone: 5
- start: >-
- {{ states('number.esphome_web_b2bf74_sun12k_time_point_5_start')|int
- }}
- stop: >-
- {{ states('number.esphome_web_b2bf74_sun12k_time_point_6_start')|int
- }}
- - zone: 6
- start: >-
- {{ states('number.esphome_web_b2bf74_sun12k_time_point_6_start')|int
- }}
- stop: >-
- {{ states('number.esphome_web_b2bf74_sun12k_time_point_1_start')|int
- }}
- - variables:
- matched_zone: >
- {% set ct = current_time | int %} {% set matched = namespace(value=None)
- %} {% for z in time_windows %}
- {% set start = z.start | int %}
- {% set stop = z.stop | int %}
- {% if matched.value is none %}
- {% if start < stop and ct >= start and ct < stop %}
- {% set matched.value = z.zone %}
- {% elif start > stop and (ct >= start or ct < stop) %}
- {% set matched.value = z.zone %}
- {% endif %}
- {% endif %}
- {% endfor %} {{ matched.value }}
- - choose:
- - conditions:
- - condition: template
- value_template: "{{ matched_zone is not none }}"
- sequence:
- - variables:
- control_mode: >-
- {{ states('input_select.zone_' ~ matched_zone ~ '_controlmode')
- }}
- max_power: >-
- {{ states('input_number.zone_' ~ matched_zone ~ '_maxsellpower')
- }}
- - data:
- name: "[Automation] Zone update"
- message: >-
- Zone {{ matched_zone }} valgt: Mode = {{ control_mode }}, Power
- = {{ max_power }} W
- action: logbook.log
- - target:
- entity_id: select.esphome_web_b2bf74_sun12k_limit_control_mode
- data:
- option: "{{ control_mode }}"
- action: select.select_option
- - target:
- entity_id: number.esphome_web_b2bf74_sun12k_max_solar_sell_power
- data:
- value: "{{ max_power }}"
- action: number.set_value
- mode: single
- !!! ----------------------------------------------------------------------------------- !!!
- alias: Batteri - Opladning fra nettet lav SoC og el er billigt
- triggers:
- - minutes: /5
- trigger: time_pattern
- conditions: []
- actions:
- - variables:
- battery_soc: "{{ states('sensor.seplos_battery_1_battery') | float(0) }}"
- today_remaining: "{{ states('sensor.energy_production_today_remaining') | float(0) }}"
- current_price: "{{ states('sensor.nord_pool_dk1_current_price') | float(0) }}"
- - choose:
- - conditions:
- - condition: numeric_state
- entity_id: sensor.nord_pool_dk1_current_price
- below: 0.01
- - condition: template
- value_template: |
- {{
- (battery_soc / 100 * 32) + today_remaining < 32*0.8
- }}
- sequence:
- - data:
- title: Grid Charge Aktiveret
- message: >
- Grid charging slået TIL (pris: {{ current_price }} kr/kWh, SoC ~
- {{ battery_soc }}%)
- action: notify.persistent_notification
- - data:
- name: Batteri Automation
- message: >
- Grid charging slået TIL (pris: {{ current_price }} kr/kWh, SoC ~
- {{ battery_soc }}%)
- entity_id: automation.batteri_opladning_fra_nettet_lav_soc_og_el_er_billigt
- action: logbook.log
- - condition: template
- value_template: >-
- {{
- is_state('switch.esphome_web_b2bf74_sun12k_time_point_1_charge_enable',
- 'off') }}
- - target:
- entity_id: switch.esphome_web_b2bf74_sun12k_time_point_1_charge_enable
- action: switch.turn_on
- data: {}
- - data:
- entity_id: number.esphome_web_b2bf74_sun12k_time_point_1_capacity
- value: 80
- action: number.set_value
- - condition: template
- value_template: >-
- {{
- is_state('switch.esphome_web_b2bf74_sun12k_time_point_2_charge_enable',
- 'off') }}
- - target:
- entity_id: switch.esphome_web_b2bf74_sun12k_time_point_2_charge_enable
- action: switch.turn_on
- data: {}
- - data:
- entity_id: number.esphome_web_b2bf74_sun12k_time_point_2_capacity
- value: 80
- action: number.set_value
- - condition: template
- value_template: >-
- {{
- is_state('switch.esphome_web_b2bf74_sun12k_time_point_3_charge_enable',
- 'off') }}
- - target:
- entity_id: switch.esphome_web_b2bf74_sun12k_time_point_3_charge_enable
- action: switch.turn_on
- data: {}
- - data:
- entity_id: number.esphome_web_b2bf74_sun12k_time_point_3_capacity
- value: 80
- action: number.set_value
- - condition: template
- value_template: >-
- {{
- is_state('switch.esphome_web_b2bf74_sun12k_time_point_4_charge_enable',
- 'off') }}
- - target:
- entity_id: switch.esphome_web_b2bf74_sun12k_time_point_4_charge_enable
- action: switch.turn_on
- data: {}
- - data:
- entity_id: number.esphome_web_b2bf74_sun12k_time_point_4_capacity
- value: 80
- action: number.set_value
- - condition: template
- value_template: >-
- {{
- is_state('switch.esphome_web_b2bf74_sun12k_time_point_5_charge_enable',
- 'off') }}
- - target:
- entity_id: switch.esphome_web_b2bf74_sun12k_time_point_5_charge_enable
- action: switch.turn_on
- data: {}
- - data:
- entity_id: number.esphome_web_b2bf74_sun12k_time_point_5_capacity
- value: 80
- action: number.set_value
- - condition: template
- value_template: >-
- {{
- is_state('switch.esphome_web_b2bf74_sun12k_time_point_6_charge_enable',
- 'off') }}
- - target:
- entity_id: switch.esphome_web_b2bf74_sun12k_time_point_6_charge_enable
- action: switch.turn_on
- data: {}
- - data:
- entity_id: number.esphome_web_b2bf74_sun12k_time_point_6_capacity
- value: 80
- action: number.set_value
- default:
- - data:
- name: Batteri Automation
- message: >
- Grid charging slået FRA (pris: {{ current_price }} kr/kWh, SoC ~ {{
- battery_soc }}%)
- entity_id: automation.batteri_opladning_fra_nettet_lav_soc_og_el_er_billigt
- action: logbook.log
- - condition: template
- value_template: >-
- {{
- is_state('switch.esphome_web_b2bf74_sun12k_time_point_1_charge_enable',
- 'on') }}
- - target:
- entity_id: switch.esphome_web_b2bf74_sun12k_time_point_1_charge_enable
- action: switch.turn_off
- data: {}
- - data:
- entity_id: number.esphome_web_b2bf74_sun12k_time_point_1_capacity
- value: "{{ states('input_number.deye_default_kapacitet_zone_1') | float }}"
- action: number.set_value
- - condition: template
- value_template: >-
- {{
- is_state('switch.esphome_web_b2bf74_sun12k_time_point_2_charge_enable',
- 'on') }}
- - target:
- entity_id: switch.esphome_web_b2bf74_sun12k_time_point_2_charge_enable
- action: switch.turn_off
- data: {}
- - data:
- entity_id: number.esphome_web_b2bf74_sun12k_time_point_2_capacity
- value: "{{ states('input_number.deye_default_kapacitet_zone_2') | float }}"
- action: number.set_value
- - condition: template
- value_template: >-
- {{
- is_state('switch.esphome_web_b2bf74_sun12k_time_point_3_charge_enable',
- 'on') }}
- - target:
- entity_id: switch.esphome_web_b2bf74_sun12k_time_point_3_charge_enable
- action: switch.turn_off
- data: {}
- - data:
- entity_id: number.esphome_web_b2bf74_sun12k_time_point_3_capacity
- value: "{{ states('input_number.deye_default_kapacitet_zone_3') | float }}"
- action: number.set_value
- - condition: template
- value_template: >-
- {{
- is_state('switch.esphome_web_b2bf74_sun12k_time_point_4_charge_enable',
- 'on') }}
- - target:
- entity_id: switch.esphome_web_b2bf74_sun12k_time_point_4_charge_enable
- action: switch.turn_off
- data: {}
- - data:
- entity_id: number.esphome_web_b2bf74_sun12k_time_point_4_capacity
- value: "{{ states('input_number.deye_default_kapacitet_zone_4') | float }}"
- action: number.set_value
- - condition: template
- value_template: >-
- {{
- is_state('switch.esphome_web_b2bf74_sun12k_time_point_5_charge_enable',
- 'on') }}
- - target:
- entity_id: switch.esphome_web_b2bf74_sun12k_time_point_5_charge_enable
- action: switch.turn_off
- data: {}
- - data:
- entity_id: number.esphome_web_b2bf74_sun12k_time_point_5_capacity
- value: "{{ states('input_number.deye_default_kapacitet_zone_5') | float }}"
- action: number.set_value
- - condition: template
- value_template: >-
- {{
- is_state('switch.esphome_web_b2bf74_sun12k_time_point_6_charge_enable',
- 'on') }}
- - target:
- entity_id: switch.esphome_web_b2bf74_sun12k_time_point_6_charge_enable
- action: switch.turn_off
- data: {}
- - data:
- entity_id: number.esphome_web_b2bf74_sun12k_time_point_6_capacity
- value: "{{ states('input_number.deye_default_kapacitet_zone_6') | float }}"
- action: number.set_value
- mode: single
- !!! ----------------------------------------------------------------------------------- !!!
- alias: Batteri - Sæt opladning til enten 80% eller 100%
- description: >-
- Formålet er at ikke oplade batteriet til mere end 80% hvis det ikke er
- nødvendigt, men alligevel oplade til 100% hver 7 dag for balancering
- triggers:
- - minutes: /5
- trigger: time_pattern
- conditions: []
- actions:
- - variables:
- battery_level: "{{ states('sensor.seplos_battery_1_battery') | int }}"
- current_charge: >-
- {{
- states('number.esphome_web_b2bf74_sun12k_maximum_battery_charge_current')
- | int }}
- last_full_charge_days: >-
- {{ (now() - states('sensor.battery_last_100') | as_datetime).days if
- states('sensor.battery_last_100') != 'unknown' else 999 }}
- price: "{{ states('sensor.nord_pool_dk1_current_price') | float }}"
- forecast_kwh: "{{ states('sensor.energy_production_tomorrow') | float }}"
- desired_charge: >-
- {% set current =
- states('number.esphome_web_b2bf74_sun12k_maximum_battery_charge_current')
- | int %} {% set charge = current %} {% if battery_level > 80 %}
- {% set charge = 5 %}
- {% endif %} {% if last_full_charge_days > 7 %}
- {% set charge = 240 %}
- {% endif %} {% if price < 0 %}
- {% set charge = 240 %}
- {% endif %} {% if forecast_kwh < 10 %}
- {% set charge = 240 %}
- {% endif %} {% if battery_level < 75 %}
- {% set charge = 240 %}
- {% endif %} {{ charge }}
- - condition: template
- value_template: "{{ desired_charge != current_charge }}"
- - target:
- entity_id: number.esphome_web_b2bf74_sun12k_maximum_battery_charge_current
- data:
- value: "{{ desired_charge }}"
- action: number.set_value
- - data:
- name: Batteri Automatisering
- message: >-
- Opladningsstrøm ændret fra {{ current_charge }}A til {{ desired_charge
- }}A. (Batteri: {{ battery_level }}%, Pris: {{ price }} kr, Prognose: {{
- forecast_kwh }} kWh, Sidst 100%: {{ last_full_charge_days }} dage siden)
- entity_id: number.esphome_web_b2bf74_sun12k_maximum_battery_charge_current
- action: logbook.log
- mode: single
- !!! -configuration.yaml ------------------------------------------------------------------ !!!
- input_number:
- zone_1_maxsellpower:
- name: Zone 1 Max Sell Power
- min: 0
- max: 12000
- step: 100
- unit_of_measurement: W
- zone_2_maxsellpower:
- name: Zone 2 Max Sell Power
- min: 0
- max: 12000
- step: 100
- unit_of_measurement: W
- zone_3_maxsellpower:
- name: Zone 3 Max Sell Power
- min: 0
- max: 12000
- step: 100
- unit_of_measurement: W
- zone_4_maxsellpower:
- name: Zone 4 Max Sell Power
- min: 0
- max: 12000
- step: 100
- unit_of_measurement: W
- zone_5_maxsellpower:
- name: Zone 5 Max Sell Power
- min: 0
- max: 12000
- step: 100
- unit_of_measurement: W
- zone_6_maxsellpower:
- name: Zone 6 Max Sell Power
- min: 0
- max: 12000
- step: 100
- unit_of_measurement: W
- deye_default_kapacitet_zone_1:
- name: Deye Default Kapacitet Zone 1
- min: 15
- max: 100
- step: 5
- unit_of_measurement: "%"
- deye_default_kapacitet_zone_2:
- name: Deye Default Kapacitet Zone 2
- min: 15
- max: 100
- step: 5
- unit_of_measurement: "%"
- deye_default_kapacitet_zone_3:
- name: Deye Default Kapacitet Zone 3
- min: 15
- max: 100
- step: 5
- unit_of_measurement: "%"
- deye_default_kapacitet_zone_4:
- name: Deye Default Kapacitet Zone 4
- min: 15
- max: 100
- step: 5
- unit_of_measurement: "%"
- deye_default_kapacitet_zone_5:
- name: Deye Default Kapacitet Zone 5
- min: 15
- max: 100
- step: 5
- unit_of_measurement: "%"
- deye_default_kapacitet_zone_6:
- name: Deye Default Kapacitet Zone 6
- min: 15
- max: 100
- step: 5
- unit_of_measurement: "%"
- template:
- - sensor:
- - name: "battery_last_100"
- unique_id: battery_last_100
- device_class: timestamp
- state: >
- {% set battery = states('sensor.seplos_battery_1_battery') | int(0) %}
- {% set last_known = states('sensor.battery_last_100') %}
- {% if battery == 100 %}
- {{ now().isoformat() }}
- {% elif last_known not in ['unknown', 'unavailable', None] %}
- {{ last_known }}
- {% else %}
- none # returnér intet, men overskriv ikke med "unknown"
- {% endif %}
- !!! - Dashboard -------------------------------------------------------------------- !!!
- title: Deye Inverter Dashboard
- views:
- - type: sections
- max_columns: 4
- title: Settings
- path: settings
- sections:
- - type: grid
- cards:
- - type: custom:layout-card
- layout_type: grid
- layout:
- grid-template-columns: auto auto auto auto auto auto auto auto
- cards:
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_1_start
- name: Start 1
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_2_start
- name: Stop 1
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_1_power
- name: Power 1
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_1_capacity
- name: Kapacitet 1
- - type: entity
- entity: switch.esphome_web_b2bf74_sun12k_time_point_1_charge_enable
- name: Charge
- - type: entity
- entity: input_select.zone_1_controlmode
- name: Zone 1 Mode
- - type: entity
- entity: input_number.deye_default_kapacitet_zone_1
- name: Zone 1 Default
- - type: entity
- entity: input_number.zone_1_maxsellpower
- name: Zone 1 Max Power
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_2_start
- name: Start 2
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_3_start
- name: Stop 2
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_2_power
- name: Power 2
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_2_capacity
- name: Kapacitet 2
- - type: entity
- entity: switch.esphome_web_b2bf74_sun12k_time_point_2_charge_enable
- name: Charge
- - type: entity
- entity: input_select.zone_2_controlmode
- name: Zone 2 Mode
- - type: entity
- entity: input_number.deye_default_kapacitet_zone_2
- name: Zone 2 Default
- - type: entity
- entity: input_number.zone_2_maxsellpower
- name: Zone 2 Max Power
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_3_start
- name: Start 3
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_4_start
- name: Stop 3
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_3_power
- name: Power 3
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_3_capacity
- name: Kapacitet 3
- - type: entity
- entity: switch.esphome_web_b2bf74_sun12k_time_point_3_charge_enable
- name: Charge
- - type: entity
- entity: input_select.zone_3_controlmode
- name: Zone 3 Mode
- - type: entity
- entity: input_number.deye_default_kapacitet_zone_3
- name: Zone 3 Default
- - type: entity
- entity: input_number.zone_3_maxsellpower
- name: Zone 3 Max Power
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_4_start
- name: Start 4
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_5_start
- name: Stop 4
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_4_power
- name: Power 4
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_4_capacity
- name: Kapacitet 4
- - type: entity
- entity: switch.esphome_web_b2bf74_sun12k_time_point_4_charge_enable
- name: Charge
- - type: entity
- entity: input_select.zone_4_controlmode
- name: Zone 4 Mode
- - type: entity
- entity: input_number.deye_default_kapacitet_zone_4
- name: Zone 4 Default
- - type: entity
- entity: input_number.zone_4_maxsellpower
- name: Zone 4 Max Power
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_5_start
- name: Start 5
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_6_start
- name: Stop 5
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_5_power
- name: Power 5
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_5_capacity
- name: Kapacitet 5
- - type: entity
- entity: switch.esphome_web_b2bf74_sun12k_time_point_5_charge_enable
- name: Charge
- - type: entity
- entity: input_select.zone_5_controlmode
- name: Zone 5 Mode
- - type: entity
- entity: input_number.deye_default_kapacitet_zone_5
- name: Zone 5 Default
- - type: entity
- entity: input_number.zone_5_maxsellpower
- name: Zone 5 Max Power
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_6_start
- name: Start 6
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_1_start
- name: Stop 6
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_6_power
- name: Power 6
- - type: entity
- entity: number.esphome_web_b2bf74_sun12k_time_point_6_capacity
- name: Kapacitet 6
- - type: entity
- entity: switch.esphome_web_b2bf74_sun12k_time_point_6_charge_enable
- name: Charge
- - type: entity
- entity: input_select.zone_6_controlmode
- name: Zone 6 Mode
- - type: entity
- entity: input_number.deye_default_kapacitet_zone_6
- name: Zone 6 Default
- - type: entity
- entity: input_number.zone_6_maxsellpower
- name: Zone 6 Max Power
- - type: grid
- cards: []
- - type: grid
- cards: []
- - type: grid
- cards: []
- - type: grid
- cards:
- - type: entities
- title: Systemindstillinger
- entities:
- - entity: select.esphome_web_b2bf74_sun12k_limit_control_mode
- - entity: switch.esphome_web_b2bf74_sun12k_grid_charge
- - entity: >-
- number.esphome_web_b2bf74_sun12k_maximum_battery_grid_charge_current
- - entity: number.esphome_web_b2bf74_sun12k_max_solar_sell_power
- cards: []
- cards: []
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement