### Example: Custom Sensor with Simple Division Source: https://kellerza.github.io/sunsynk/reference/mysensors Demonstrates creating a custom sensor class that divides the values of two registers. This requires defining a new class inheriting from `Sensor`. ```python from dataclasses import dataclass, field from sunsynk import Sensor, SensorDefinitions, WATT from sunsynk.helpers import unpack_value @dataclass(slots=True, eq=False) class MyCustomSensor(Sensor): """Custom sensor, using multiple registers.""" def reg_to_value(self, regs: RegType) -> ValType: """Calculate the value.""" val1 = unpack_value((regs[0],), signed=True) val2 = unpack_value((regs[1],), signed=True) return val1 / val2 SENSORS = SensorDefinition() # Use the class above with register 10 and 20 SENSORS += MyCustomSensor((10, 20), "Mysensor1", WATT) ``` -------------------------------- ### Define Custom Sensors in Python Source: https://kellerza.github.io/sunsynk/reference/mysensors Create custom sensors by defining them in `mysensors.py`. This example shows how to add basic, math, and read/write sensors. ```python from sunsynk import AMPS, CELSIUS, KWH, VOLT, WATT, Sensor, SensorDefinitions from sunsynk.rwsensors import NumberRWSensor, SelectRWSensor, TimeRWSensor from sunsynk.sensors import MathSensor, TempSensor # Initialize the sensor definitions SENSORS = SensorDefinitions() # Add your custom sensors SENSORS += ( # Basic sensor example Sensor(178, "My Custom Power Sensor", WATT, -1), # Math sensor example (combining multiple registers) MathSensor((175, 172), "Custom Combined Power", WATT, factors=(1, 1)), # Read/Write sensor example NumberRWSensor(130, "Custom Control Setting", "%", min=0, max=100), ) ``` -------------------------------- ### Docker Compose Configuration for Sunsynk Multi Source: https://kellerza.github.io/sunsynk/guide/standalone-deployment Example docker-compose.yml to run Sunsynk Multi service. Configure MQTT, driver, sensors, and inverter details via environment variables. ```yaml services: sunsynk-multi-amd64: restart: unless-stopped profiles: ['sunsynk-amd64'] image: ghcr.io/kellerza/hass-addon-sunsynk-multi:stable environment: MQTT_HOST: mqtt MQTT_PORT: 1883 MQTT_USERNAME: ${MQTT_USER} MQTT_PASSWORD: ${MQTT_PASSWORD} S6_KEEP_ENV: 1 DRIVER: "pymodbus" SENSOR_DEFINITIONS: "single-phase" SENSORS: '["energy_management", "power_flow_card", "pv2_power"]' SENSORS_FIRST_INVERTER: '["settings"]' MANUFACTURER: "Sunsynk" READ_ALLOW_GAP: 2 READ_SENSORS_BATCH_SIZE: 20 NUMBER_ENTITY_MODE: "auto" INVERTERS: '[{"SERIAL_NR":"1234567890","HA_PREFIX":"SUN-10k-dsaxz","MODBUS_ID":1,"DONGLE_SERIAL_NUMBER":"1234567890","PORT":"tcp://192.168.1.123:8899"}]' SCHEDULES: '[{"key":"w","read_every":5,"report_every":60,"change_by":80,"change_percent":0,"change_any":0}]' ``` -------------------------------- ### Configuring mbusd for Addon Connections Source: https://kellerza.github.io/sunsynk/guide/fault-finding If multiple addons require serial port access, connect all addons to mbusd. This example shows connecting to mbusd using a TCP address. ```text tcp://192.168.1.x:503 ``` -------------------------------- ### Example: Override Battery Sensor Schedule Source: https://kellerza.github.io/sunsynk/reference/schedules An example of how to override the schedule for a specific sensor, such as the battery sensor ('%'). This configuration changes the read time and enables immediate reporting on any change. ```yaml - KEY: "%" READ_EVERY: 30 REPORT_EVERY: 300 CHANGE_ANY: true ``` -------------------------------- ### Add Custom Selling Load Sensor Source: https://kellerza.github.io/sunsynk/reference/mysensors An example of adding a custom selling load sensor that subtracts the inverter output power. ```python MathSensor((175, 172), "Selling Load Power direct", WATT, factors=(1, 1)), ``` -------------------------------- ### Install Sunsynk Power Flow Card via HACS Source: https://kellerza.github.io/sunsynk/examples/lovelace Add the custom Lovelace repository to HACS for installation. Alternatively, use the provided button if available. ```yaml SENSORS: - power_flow_card ``` -------------------------------- ### Sunsynk Multi options.yaml Configuration Source: https://kellerza.github.io/sunsynk/guide/standalone-deployment Configure the Sunsynk Multi add-on by creating an options.yaml file. Adjust the INVERTERS section to match your specific inverter setup. The PORT setting points to the mbusd service within the Docker Compose stack. ```yaml --- DRIVER: "pymodbus" INVERTERS: - SERIAL_NR: "007" HA_PREFIX: SS MODBUS_ID: 1 DONGLE_SERIAL_NUMBER: "0" PORT: tcp://mbusd:502 SENSOR_DEFINITIONS: single-phase SENSORS: - energy_management - power_flow_card - pv2_power SENSORS_FIRST_INVERTER: - settings MANUFACTURER: Sunsynk READ_ALLOW_GAP: 2 READ_SENSORS_BATCH_SIZE: 20 SCHEDULES: - KEY: W READ_EVERY: 5 REPORT_EVERY: 60 CHANGE_ANY: false CHANGE_BY: 80 CHANGE_PERCENT: 0 NUMBER_ENTITY_MODE: "auto" MQTT_HOST: core-mosquitto MQTT_PORT: 1883 MQTT_USERNAME: hass MQTT_PASSWORD: "" # DEBUG: 0 # DEBUG_DEVICE: "/dev/ttyAMA0" ``` -------------------------------- ### Custom MQTT Configuration Source: https://kellerza.github.io/sunsynk/reference/multi-options Set `MQTT_CUSTOM: true` to force the add-on to use the provided MQTT configuration instead of supervisor settings. This is useful for custom MQTT broker setups. ```yaml MQTT_CUSTOM: true # Force the add-on to use this MQTT configuration MQTT_HOST: core-mosquitto MQTT_PORT: 1883 MQTT_USERNAME: hass MQTT_PASSWORD: my-secure-password ``` -------------------------------- ### Connecting to mbusd for Serial Port Access Source: https://kellerza.github.io/sunsynk/guide/fault-finding When multiple addons need to access the serial port, connect them to mbusd instead of directly to the port. This example shows connecting the addon to mbusd via TCP. ```text tcp://:502 ``` -------------------------------- ### Configure Modbus TCP Gateway Port Source: https://kellerza.github.io/sunsynk/reference/multi-options Use this configuration when connecting to a Modbus TCP gateway. Ensure the IP address and port are correct for your network setup. ```yaml INVERTERS: - PORT: tcp://homeassistant.local:502 ``` -------------------------------- ### Lovelace System Settings Card Configuration Source: https://kellerza.github.io/sunsynk/examples/lovelace-settings This Lovelace YAML configures a vertical stack of horizontal stacks to display and edit system settings. It utilizes Mushroom entity cards and gauge cards for various parameters like program time, charge, capacity, and load limit. Ensure you have the Mushroom cards installed via HACS. ```yaml type: vertical-stack cards: - type: horizontal-stack cards: - type: custom:mushroom-entity-card entity: select.ss_prog1_time fill_container: true secondary_info: none primary_info: state icon: mdi:numeric-1 - type: vertical-stack cards: - type: custom:mushroom-entity-card entity: select.ss_prog1_charge name: ' ' fill_container: false icon_type: none - type: custom:mushroom-entity-card entity: number.ss_prog1_power name: ' ' icon_type: none - type: gauge entity: number.ss_prog1_capacity name: ' ' needle: false - type: horizontal-stack cards: - type: custom:mushroom-entity-card entity: select.ss_prog2_time fill_container: true secondary_info: none primary_info: state icon: mdi:numeric-2 - type: vertical-stack cards: - type: custom:mushroom-entity-card entity: select.ss_prog2_charge name: ' ' fill_container: false icon_type: none - type: custom:mushroom-entity-card entity: number.ss_prog2_power name: ' ' icon_type: none - type: gauge entity: number.ss_prog2_capacity needle: false name: ' ' - type: horizontal-stack cards: - type: custom:mushroom-entity-card entity: select.ss_prog3_time fill_container: true secondary_info: none primary_info: state icon: mdi:numeric-3 - type: vertical-stack cards: - type: custom:mushroom-entity-card entity: select.ss_prog3_charge name: ' ' fill_container: false icon_type: none - type: custom:mushroom-entity-card entity: number.ss_prog3_power name: ' ' icon_type: none - type: gauge entity: number.ss_prog3_capacity needle: false name: ' ' - type: horizontal-stack cards: - type: custom:mushroom-entity-card entity: select.ss_prog4_time fill_container: true secondary_info: none primary_info: state icon: mdi:numeric-4 - type: vertical-stack cards: - type: custom:mushroom-entity-card entity: select.ss_prog4_charge name: ' ' fill_container: false icon_type: none - type: custom:mushroom-entity-card entity: number.ss_prog4_power name: ' ' icon_type: none - type: gauge entity: number.ss_prog4_capacity needle: false name: ' ' - type: horizontal-stack cards: - type: custom:mushroom-entity-card entity: select.ss_prog5_time fill_container: true secondary_info: none primary_info: state icon: mdi:numeric-5 - type: vertical-stack cards: - type: custom:mushroom-entity-card entity: select.ss_prog5_charge name: ' ' fill_container: false icon_type: none - type: custom:mushroom-entity-card entity: number.ss_prog5_power name: ' ' icon_type: none - type: gauge entity: number.ss_prog5_capacity needle: false name: ' ' - type: horizontal-stack cards: - type: custom:mushroom-entity-card entity: select.ss_prog6_time fill_container: true secondary_info: none primary_info: state icon: mdi:numeric-6 - type: vertical-stack cards: - type: custom:mushroom-entity-card entity: select.ss_prog6_charge name: ' ' fill_container: false icon_type: none - type: custom:mushroom-entity-card entity: number.ss_prog6_power name: ' ' icon_type: none - type: gauge entity: number.ss_prog6_capacity needle: false name: ' ' - type: entity entity: select.ss_load_limit ``` -------------------------------- ### Load Home Assistant Packages Source: https://kellerza.github.io/sunsynk/examples/overview This configuration snippet loads packages from the `/config/packages/` directory. Ensure you have a packages folder set up as per Home Assistant documentation. ```yaml homeassistant: packages: !include_dir_named packages ``` -------------------------------- ### Build and Run Sunsynk Multi with Docker Compose Source: https://kellerza.github.io/sunsynk/guide/standalone-deployment Build the Sunsynk Multi Docker image using a specified base image and then run it as a detached service. View the container logs to monitor its operation. ```bash BUILD_FROM= docker compose build sunsynk-multi ``` ```bash docker compose up -d sunsynk-multi ``` ```bash docker compose logs -f sunsynk-multi ``` -------------------------------- ### Build and Run Mbusd with Docker Compose Source: https://kellerza.github.io/sunsynk/guide/standalone-deployment Build the mbusd Docker image and run it. Ensure the 'volumes' section in 'docker-compose.yaml' correctly maps your host's RS485 port. ```bash BUILD_FROM= docker compose build mbusd ``` ```bash docker compose up mbusd ``` ```bash docker compose logs -f mbusd ``` -------------------------------- ### Configure System Operating Mode Settings Source: https://kellerza.github.io/sunsynk/reference/definitions Use the 'settings' group under `SENSORS_FIRST_INVERTER` to configure system operating modes. These settings are also visible in Lovelace. ```yaml SENSORS_FIRST_INVERTER: - settings ``` -------------------------------- ### Include All Sensors Source: https://kellerza.github.io/sunsynk/reference/definitions Use the 'all' group to include all available sensors. This is primarily for testing and not recommended for production due to potential performance issues and excessive data logging. ```yaml SENSORS: - all ``` -------------------------------- ### Docker Compose Configuration for Sunsynk Multi (Basic) Source: https://kellerza.github.io/sunsynk/guide/standalone-deployment A basic Docker Compose service definition for Sunsynk Multi using a pre-built image. It ensures the container restarts automatically unless stopped and mounts the options.yaml file. ```yaml services: sunsynk-multi: restart: unless-stopped image: ghcr.io/kellerza/hass-addon-sunsynk-multi:stable volumes: - ${PWD}/options.yaml:/data/options.yaml ``` -------------------------------- ### Add Custom Sensors Source: https://kellerza.github.io/sunsynk/reference/definitions Add custom sensors to your configuration under the `SENSORS` or `SENSORS_FIRST_INVERTER` keys. The logs will display sensor names in a lowercase, no-space format. ```yaml SENSORS: - battery_soc - Battery SOC ``` -------------------------------- ### Docker Compose Configuration for Sunsynk Multi (with Environment Variables) Source: https://kellerza.github.io/sunsynk/guide/standalone-deployment Docker Compose configuration for Sunsynk Multi that uses environment variables for MQTT settings. The S6_KEEP_ENV: 1 setting ensures environment variables are preserved. ```yaml services: sunsynk-multi: restart: unless-stopped image: ghcr.io/kellerza/hass-addon-sunsynk-multi:stable volumes: - ${PWD}/options.yaml:/data/options.yaml environment: MQTT_HOST: mqtt MQTT_PORT: 1883 MQTT_USERNAME: ${MQTT_USER} MQTT_PASSWORD: ${MQTT_PASSWORD} S6_KEEP_ENV: 1 ``` -------------------------------- ### Run Sunsynk Multi with Docker CLI Source: https://kellerza.github.io/sunsynk/guide/standalone-deployment Command to run the Sunsynk Multi container using the Docker CLI. It sets the container to restart automatically, mounts the options.yaml file, and names the container 'sunsynk-multi'. ```bash docker run -d --name sunsynk-multi \ --restart unless-stopped \ -v ${PWD}/options.yaml:/data/options.yaml \ ghcr.io/kellerza/hass-addon-sunsynk-multi:stable ``` -------------------------------- ### Detect Load Shedding using Grid Frequency Source: https://kellerza.github.io/sunsynk/examples/a-mode Creates a binary sensor to detect load shedding based on grid frequency dropping below 40Hz. It also configures alerts for power failures and their duration, with customizable repeat intervals and notifiers. ```yaml template: binary_sensor: - name: Load shedding state: "{{ states('sensor.ss_grid_frequency') | default (50) | int(0) < 40 }}" alert: load_shed: name: "Load shedding" message: "The power is off for - {{ relative_time(states.binary_sensor.load_shedding.last_changed) }}" done_message: "The power is back on" entity_id: binary_sensor.load_shedding repeat: - 2 - 30 - 60 - 120 can_acknowledge: true # Optional, default is true skip_first: true # Optional, false is the default notifiers: - mobile_app_johann_iphone ``` -------------------------------- ### Add Custom Sensors to Home Assistant Configuration Source: https://kellerza.github.io/sunsynk/reference/mysensors Configure Home Assistant to use your custom sensors. You can add them individually or use the `mysensors` group to include all custom sensors. ```yaml SENSORS: - my_custom_sensor_1 - my_custom_sensor_2 ``` ```yaml SENSORS: - mysensors ``` -------------------------------- ### Set Load Limit to Essentials Source: https://kellerza.github.io/sunsynk/examples/a-mode Use this automation to set the inverter's load limit to 'Essentials' mode at 18:30 daily. This ensures only essential loads are powered during the evening. ```yaml alias: SS Load Limit Essentials trigger: - platform: time at: "18:30:00" condition: [] action: - service: select.select_option data: option: Essentials target: entity_id: select.ss_load_limit mode: single ``` -------------------------------- ### Include Core Energy Sensors Source: https://kellerza.github.io/sunsynk/guide/energy-management These sensors are required for full Home Assistant Energy feature functionality, tracking grid and battery interactions, and PV generation. ```yaml SENSORS: - total_grid_import - total_grid_export - total_pv_energy - total_battery_charge - total_battery_discharge ``` -------------------------------- ### Add Individual Device Energy Sensors Source: https://kellerza.github.io/sunsynk/guide/energy-management Optionally include these sensors to track energy consumption and generation at the device level for more granular insights. ```yaml SENSORS: - total_load_energy - total_active_energy ``` -------------------------------- ### Configure Empty Serial Port for First Inverter Source: https://kellerza.github.io/sunsynk/reference/multi-options For the first inverter in the list, an empty string can be used for the port. The system will then use the serial port specified under DEBUG_DEVICE. ```yaml INVERTERS: - PORT: "" ``` -------------------------------- ### Recommended Solarman Schedule Overrides Source: https://kellerza.github.io/sunsynk/reference/schedules Recommended schedule overrides for the Solarman driver to prevent overwhelming the dongle. These settings adjust read and report frequencies for specific sensor types. ```yaml SCHEDULES: - KEY: W READ_EVERY: 15 REPORT_EVERY: 60 CHANGE_BY: 80 - KEY: RW READ_EVERY: 15 REPORT_EVERY: 60 CHANGE_ANY: true - KEY: any_unit READ_EVERY: 30 REPORT_EVERY: 60 CHANGE_BY: 80 ``` -------------------------------- ### Display Deye/Sunsynk Sensor Values in Home Assistant Source: https://kellerza.github.io/sunsynk/examples/templates Use these templates in Home Assistant's Developer Tools to view real-time sensor data from your Deye/Sunsynk inverter. Ensure the sensor entities are correctly configured. ```yaml Essentials: {{ states("sensor.ss_essential_power") }} W Non-Essentials: {{ states("sensor.ss_non_essential_power") }} W Grid CT: {{ states("sensor.ss_grid_ct_power") }} W Battery: {{ states("sensor.ss_battery_power") }} W {{ states("sensor.ss_battery_voltage") }} V {{ states("sensor.ss_battery_current") }} Amps {{ states("sensor.ss_battery_temperature") }} °C Grid Power: {{ states("sensor.ss_grid_power") }} W {{ states("sensor.ss_grid_frequency") }} Hz {{ states("sensor.ss_grid_voltage") }} V {{ states("sensor.ss_grid_current") }} Amp CT {{ states("sensor.ss_grid_ct_power") }} W Inverter {{ states("sensor.ss_inverter_power") }} W {{ states("sensor.ss_inverter_frequency") }} Hz Load {{ states("sensor.ss_essential_power") }} W {{ states("sensor.ss_grid_frequency") }} Hz {{ states("sensor.ss_grid_voltage") }} V {{ states("sensor.ss_grid_current") }} Amp PV1 {{ states("sensor.ss_pv1_power") }} W {{ states("sensor.ss_pv1_voltage") }} V {{ states("sensor.ss_pv1_current") }} A ``` -------------------------------- ### Sensors Included in 'settings' Group Source: https://kellerza.github.io/sunsynk/reference/definitions This list details the sensors available within the 'settings' group for system operating mode configuration. ```yaml SENSORS: - export_limit_power # 3PH, 3PH-hv - grid_charge_enabled - load_limit - prog1_capacity - prog1_charge - prog1_power - prog1_time - prog2_capacity - prog2_charge - prog2_power - prog2_time - prog3_capacity - prog3_charge - prog3_power - prog3_time - prog4_capacity - prog4_charge - prog4_power - prog4_time - prog5_capacity - prog5_charge - prog5_power - prog5_time - prog6_capacity - prog6_charge - prog6_power - prog6_time - solar_export - use_timer ``` -------------------------------- ### Custom Sensors Configuration Source: https://kellerza.github.io/sunsynk/reference/definitions Configuration for adding custom sensors using the 'mysensors' group. Refer to Custom Sensors documentation for more details. ```yaml SENSORS: - mysensors ``` -------------------------------- ### Implement System Time Sensor Source: https://kellerza.github.io/sunsynk/reference/mysensors Defines a custom sensor for reading and writing system time. It includes methods for converting between display values and register values. Note that write functionality is partially implemented. ```python from dataclasses import dataclass, field import re from sunsynk import RegType, ValType, SensorDefinitions from sunsynk.rwsensors import RWSensor, ResolveType SENSORS = SensorDefinitions() @dataclass(slots=True, eq=False) class SystemTimeRWSensor(RWSensor): """Read & write time sensor.""" def value_to_reg(self, value: ValType, resolve: ResolveType) -> RegType: """Get the reg value from a display value.""" redt = re.compile(r"(2\d{3})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})") match = redt.fullmatch(value) if not match: raise ValueError("Invalid datetime {value}") y, m, d = int(match.group(1)) - 2000, int(match.group(2)), int(match.group(3)) h, mn, s = int(match.group(4)), int(match.group(5)), int(match.group(6)) regs = ( (y << 8) + m, (d << 8) + h, (mn << 8) + s, ) raise ValueError(f"{y}-{m:02}-{d:02} {h}:{mn:02}:{s:02} ==> {regs}") return regs def reg_to_value(self, regs: RegType) -> ValType: """Decode the register.""" y = ((regs[0] & 0xFF00) >> 8) + 2000 m = regs[0] & 0xFF d = (regs[1] & 0xFF00) >> 8 h = regs[1] & 0xFF mn = (regs[2] & 0xFF00) >> 8 s = regs[2] & 0xFF return f"{y}-{m:02}-{d:02} {h}:{mn:02}:{s:02}" SENSORS += SystemTimeRWSensor((22, 23, 24), "Date", unit="") ``` -------------------------------- ### Enable Energy Management Sensor Source: https://kellerza.github.io/sunsynk/guide/energy-management Include this sensor to enable the basic Energy Management feature in Home Assistant. ```yaml SENSORS: - energy_management ``` -------------------------------- ### List of Energy Management Sensors Source: https://kellerza.github.io/sunsynk/reference/definitions These are the specific sensors included when the 'energy_management' group is selected. ```yaml SENSORS: - total_battery_charge - total_battery_discharge - total_grid_export - total_grid_import - total_pv_energy ``` -------------------------------- ### Lovelace Power Distribution Card YAML Configuration Source: https://kellerza.github.io/sunsynk/examples/lovelace Complete Lovelace YAML configuration for the Power Distribution Card. This includes defining entities for solar, home, battery, pool, and grid, along with their display properties and actions. ```yaml type: custom:power-distribution-card title: '' entities: - decimals: '' display_abs: true name: solar unit_of_display: W icon: mdi:solar-power producer: true entity: sensor.ss_pv1_power threshold: '' preset: solar icon_color: equal: '' smaller: '' - decimals: '' display_abs: true name: home unit_of_display: W consumer: true icon: mdi:home-assistant invert_value: true entity: sensor.ss_essential_power color_threshold: '0' threshold: '' preset: home icon_color: bigger: '' equal: '' smaller: '' arrow_color: bigger: '' equal: '' smaller: '' - decimals: '' display_abs: true name: battery unit_of_display: W consumer: true icon: mdi:battery-outline producer: true entity: sensor.ss_battery_power threshold: '' preset: battery icon_color: bigger: '' equal: '' smaller: '' secondary_info_attribute: '' battery_percentage_entity: sensor.ss_battery_soc - decimals: '' display_abs: true name: pool unit_of_display: W invert_value: true consumer: true icon: mdi:pool entity: sensor.ss_non_essential_power color_threshold: '0' preset: pool threshold: '' icon_color: bigger: '' equal: '' smaller: '' arrow_color: bigger: '' equal: '' smaller: '' - decimals: '' display_abs: true name: grid unit_of_display: W icon: mdi:transmission-tower entity: sensor.ss_grid_ct_power preset: grid threshold: '' icon_color: equal: '' smaller: '' double_tap_action: action: navigate navigation_path: /lovelace/power tap_action: action: navigate navigation_path: /lovelace/power center: type: bars content: - preset: ratio name: ratio - preset: custom entity: sensor.ss_battery_soc name: SOC animation: slide ``` -------------------------------- ### Default Sensor Schedules Source: https://kellerza.github.io/sunsynk/reference/schedules The default behavior for reading and reporting sensors based on their key or unit. This table outlines the default read and report intervals in seconds, and conditions for immediate reporting. ```text +-----------+-----+------+--------+-----------+----------+------------+ | Key | src | Read | Report | Change by | Change % | Change any | +-----------+-----+------+--------+-----------+----------+------------+ | date_time | | 60 | 60 | | | True | | rw | | 5 | 300 | | | True | | w | | 5 | 60 | 80 | | | | kwh | | 300 | 300 | | | | | any_unit | | 15 | 300 | | | True | | no_unit | | 15 | 300 | | | True | +-----------+-----+------+--------+-----------+----------+------------+ ``` -------------------------------- ### Loadshedding Jinja Template Source: https://kellerza.github.io/sunsynk/guide/esp This Jinja macro formats loadshedding information for display. It calculates remaining time until the next event and displays alerts based on the severity and proximity of loadshedding. ```jinja {% macro loadshed_md(espnext) %} {%- set active = (as_timestamp(states(espnext))<=as_timestamp(now())) | bool %} {%- set stage = state_attr(espnext, "note") %} {%- set t0 = state_attr(espnext, "start") | as_timestamp | int %} {%- set t1 = state_attr(espnext, "end") | as_timestamp | int %} {%- set t0_min = (t0|int - as_timestamp(now()))|int // 60 %} {%- set t1_min = (t1|int - as_timestamp(now()))|int // 60 %} {%- if stage %} {%- if not bool(active) %} {%- set mins = t0_min % 60 %} {%- set hrs = t0_min // 60 %} {%- set alert = "Load Shedding starts in {h}:{m:02d} ({next})".format(m=mins, h=hrs, next=t0 | timestamp_custom("%H:%M", True)) %} {%- if hrs>12 %} {{ alert }} {%- elif hrs > 1 %} {{ alert }} {%- else %} {{ alert }} {%- endif %} {%- else %} {%- set mins = t1_min % 60 %} {%- set hrs = t1_min // 60 %} {%- set alert = "Load Shedding ends in {h}:{m:02d} ({next})".format(m=mins, h=hrs, next=t1 | timestamp_custom("%H:%M", True)) %} {{ alert }} {%- endif %} {%- else %} {%- set mins = t0_min % 60 %} {%- set hrs = t0_min // 60 % 24 %} {%- set days = t0_min // 1440 %} {%- if (t0 == 0 or t1 == 0) %} {%- set alert = "No Load Shedding" %} {%- else %} {%- set alert = "Stage {stage} starts in {d}d {h:02d}:{m:02d} ({next})".format(stage=stage, d=days, m=mins, h=hrs, next=as_timestamp(start_time) | timestamp_custom("%H:%M", True)) %} {%- endif %} {{ alert }} {%- endif %} {% endmacro %} ``` -------------------------------- ### Sensors Included in 'advanced' Group Source: https://kellerza.github.io/sunsynk/reference/definitions This list details the sensors available within the 'advanced' group, providing in-depth system parameters. ```yaml SENSORS: - battery_capacity_current # 3PH, 3PH-hv - battery_charge_efficiency # 3PH, 3PH-hv - battery_low_capacity - battery_max_charge_current - battery_max_discharge_current - battery_resistance # 3PH, 3PH-hv - battery_restart_capacity - battery_shutdown_capacity - battery_type # 3PH, 3PH-hv - battery_wake_up # 3PH, 3PH-hv - configured_grid_frequency # 3PH, 3PH-hv - configured_grid_phases # 3PH, 3PH-hv - date_time - grid_charge_battery_current - grid_charge_start_battery_soc # 3PH, 3PH-hv - grid_charge_start_battery_voltage # 3PH, 3PH-hv - grid_standard # 3PH, 3PH-hv - track_grid_phase # 3PH, 3PH-hv - ups_delay_time # 3PH, 3PH-hv ``` -------------------------------- ### Select Sensor Definitions Source: https://kellerza.github.io/sunsynk/reference/definitions Choose the appropriate set of sensor definitions based on your inverter type (single-phase, three-phase low voltage, or three-phase high voltage). ```yaml SENSOR_DEFINITIONS: single-phase / three-phase [low voltage] / three-phase-hv [high voltage] ``` -------------------------------- ### Configure Solarman Driver Port Source: https://kellerza.github.io/sunsynk/reference/multi-options Configure the Solarman driver with the dongle's IP address and the standard port 8899. It is recommended to set a static IP for the dongle on your router. ```yaml DRIVER: solarman INVERTER: - PORT: tcp://192.168.1.182:8899 ``` -------------------------------- ### Sunsynk Power Flow Card Configuration Source: https://kellerza.github.io/sunsynk/examples/lovelace A detailed Lovelace YAML configuration for the Sunsynk Power Flow card. Customize various aspects of the card's appearance and data display, including inverter, battery, solar, load, and grid parameters. ```yaml type: custom:sunsynk-power-flow-card cardstyle: compact large_font: true show_solar: true inverter: modern: true autarky: power battery: energy: 10640 shutdown_soc: 15 show_daily: true animation_speed: 6 max_power: 4100 show_absolute: true show_remaining_energy: true animate: true solar: show_daily: true mppts: 2 animation_speed: 9 max_power: 5500 display_mode: 2 pv1_max_power: 2250 pv2_max_power: 2250 efficiency: 3 load: show_daily: true show_aux: false load1_name: Geyser load1_icon: boiler animation_speed: 8 max_power: 8000 dynamic_colour: true dynamic_icon: true path_threshold: 90 grid: show_daily_buy: true no_grid_colour: - 125 - 125 - 125 show_nonessential: false animation_speed: 8 max_power: 8000 grid_off_colour: - 220 - 4 - 4 grid_name: " " entities: use_timer_248: switch.ss_use_timer priority_load_243: switch.ss_priority_load inverter_voltage_154: sensor.ss_inverter_voltage load_frequency_192: sensor.ss_load_frequency inverter_current_164: sensor.ss_inverter_current inverter_power_175: sensor.ss_inverter_power grid_connected_status_194: binary_sensor.ss_grid_connected inverter_status_59: sensor.ss_overall_state day_battery_charge_70: sensor.ss_day_battery_charge day_battery_discharge_71: sensor.ss_day_battery_discharge battery_voltage_183: sensor.ss_battery_voltage battery_soc_184: sensor.ss_battery_soc battery_power_190: sensor.ss_battery_power battery_current_191: sensor.ss_battery_current grid_power_169: sensor.ss_grid_power day_grid_import_76: sensor.ss_day_grid_import grid_ct_power_172: sensor.ss_grid_power day_load_energy_84: sensor.ss_day_load_energy essential_power: sensor.ss_essential_1_power nonessential_power: none aux_power_166: none day_pv_energy_108: sensor.ss_day_pv_energy pv1_power_186: sensor.ss_pv1_power pv2_power_187: sensor.ss_pv2_power pv1_voltage_109: sensor.ss_pv1_voltage pv1_current_110: sensor.ss_pv1_current pv2_voltage_111: sensor.ss_pv2_voltage pv2_current_112: sensor.ss_pv2_current prog1_time: select.ss_prog1_time prog1_capacity: number.ss_prog1_capacity prog1_charge: select.ss_prog1_charge prog2_time: select.ss_prog2_time prog2_capacity: number.ss_prog2_capacity prog2_charge: select.ss_prog2_charge prog3_time: select.ss_prog3_time prog3_capacity: number.ss_prog3_capacity prog3_charge: select.ss_prog3_charge prog4_time: select.ss_prog4_time prog4_capacity: number.ss_prog4_capacity prog4_charge: select.ss_prog4_charge prog5_time: select.ss_prog5_time prog5_capacity: number.ss_prog5_capacity prog5_charge: select.ss_prog5_charge prog6_time: select.ss_prog6_time prog6_capacity: number.ss_prog6_capacity prog6_charge: select.ss_prog6_charge radiator_temp_91: sensor.ss_radiator_temperature dc_transformer_temp_90: sensor.ss_dc_transformer_temperature total_pv_generation: sensor.ss_total_pv_energy remaining_solar: sensor.energy_production_today_remaining dynamic_line_width: true min_line_width: 2 ``` -------------------------------- ### Set Load Limit to Zero Export Source: https://kellerza.github.io/sunsynk/examples/a-mode This automation sets the inverter's load limit to 'Zero Export' at 07:00 daily. This mode allows feeding power to non-essential loads and the grid, with CT control to limit grid feedback. ```yaml alias: SS Load Limit Zero Export trigger: - platform: time at: "07:00:00" condition: [] action: - service: select.select_option data: option: Zero Export target: entity_id: select.ss_load_limit mode: single ``` -------------------------------- ### Automate Battery Charging Source: https://kellerza.github.io/sunsynk/examples/a-mode This automation charges the battery if the next day's solar production is low and electricity prices are below a threshold, specifically in March and September. It triggers at 23:55:00. ```yaml alias: Cargar bateria noche description: "" trigger: - platform: time at: "23:55:00" condition: - condition: template value_template: "{{ now().month in [3, 9] }} " alias: "Marzo y Septiembre " - condition: numeric_state entity_id: sensor.energy_production_tomorrow below: 15 - condition: numeric_state entity_id: sensor.esios_pvpc attribute: price_next_day_00h below: 0.05 action: - device_id: 1d0794ae215d5051bf06926b63209edf domain: select entity_id: select.prog1_mode type: select_option option: Charge mode: single ``` -------------------------------- ### Include Generator Control Sensors Source: https://kellerza.github.io/sunsynk/reference/definitions Use the 'generator' group to enable sensors for controlling and monitoring generator operations. ```yaml SENSORS: - generator ``` -------------------------------- ### List of Power Flow Card Sensors Source: https://kellerza.github.io/sunsynk/reference/definitions This list details all sensors that are part of the 'power_flow_card' group. ```yaml SENSORS: - aux_power # 1PH, 1PH-16kw - battery_1_soc # 3PH-hv - battery_1_voltage # 3PH-hv - battery_current # 1PH, 1PH-16kw, 3PH - battery_power # 1PH, 1PH-16kw, 3PH - battery_soc # 1PH, 1PH-16kw, 3PH - battery_voltage # 1PH, 1PH-16kw, 3PH - day_battery_charge - day_battery_discharge - day_grid_export - day_grid_import - day_load_energy - day_pv_energy - essential_power # 1PH, 1PH-16kw - grid_connected - grid_ct_power - grid_current - grid_frequency - grid_l1_power # 3PH, 3PH-hv - grid_l2_power - grid_l3_power # 3PH, 3PH-hv - grid_power - grid_voltage # 1PH, 1PH-16kw - inverter_current # 1PH, 1PH-16kw - inverter_power - inverter_voltage # 1PH, 1PH-16kw - load_frequency - load_l1_power - load_l1_voltage # 3PH, 3PH-hv - load_l2_power - load_l2_voltage # 3PH, 3PH-hv - load_l3_power # 3PH, 3PH-hv - load_l3_voltage # 3PH, 3PH-hv - load_power - non_essential_power # 1PH, 1PH-16kw - overall_state - priority_load - pv1_current - pv1_power - pv1_voltage - pv2_current - pv2_power - pv2_voltage - pv3_current - pv3_power - pv3_voltage - pv4_current # 3PH, 3PH-hv - pv4_power # 3PH, 3PH-hv - pv4_voltage # 3PH, 3PH-hv - pv_power # 3PH, 3PH-hv - use_timer ``` -------------------------------- ### Lovelace Panel for Inverter Control Source: https://kellerza.github.io/sunsynk/examples/lovelace-settings This Lovelace YAML configuration defines a panel to control the Turbo Energy inverter system's work mode and schedule settings. It uses 'entities' cards to display and edit various parameters for up to six different time-based schedules. ```yaml - theme: Backend-selected title: Bateria path: bateria icon: mdi:battery badges: [] cards: - type: entities entities: - entity: select.prog1_time name: Hora - entity: number.prog1_power name: Potencia maxima - entity: select.prog1_mode name: Modo - entity: number.prog1_capacity name: Minimo Bateria title: Horario 1 - type: entities entities: - entity: select.prog2_time name: Hora - entity: number.prog2_power name: Potencia maxima - entity: select.prog2_mode name: Modo - entity: number.prog2_capacity name: Minimo Bateria title: Horario 2 - type: entities entities: - entity: select.prog3_time name: Hora - entity: number.prog3_power name: Potencia maxima - entity: select.prog3_mode name: Modo - entity: number.prog3_capacity name: Minimo Bateria title: Horario 3 - type: entities entities: - entity: select.prog4_time name: Hora - entity: number.prog4_power name: Potencia maxima - entity: select.prog4_mode name: Modo - entity: number.prog4_capacity name: Minimo Bateria title: Horario 4 - type: entities entities: - entity: select.prog5_time name: Hora - entity: number.prog5_power name: Potencia maxima - entity: select.prog5_mode name: Modo - entity: number.prog5_capacity name: Minimo Bateria title: Horario 5 - type: entities entities: - entity: select.prog6_time name: Hora - entity: number.prog6_power name: Potencia maxima - entity: select.prog6_mode name: Modo - entity: number.prog6_capacity name: Minimo Bateria title: Horario 6 ``` -------------------------------- ### Configure Umodbus Serial Port Source: https://kellerza.github.io/sunsynk/reference/multi-options This configuration is for the umodbus driver using a serial connection. It requires a 'serial://' prefix and the correct device path. ```yaml DRIVER: umodbus INVERTERS: - PORT: serial:///dev/ttyUSB0 ``` -------------------------------- ### Lovelace Markdown Card for Loadshedding Source: https://kellerza.github.io/sunsynk/guide/esp This YAML configuration adds a Lovelace markdown card to your frontend. It uses the previously defined Jinja macro to display the loadshedding status. ```yaml - type: markdown content: '{% from "loadshed.jinja" import loadshed_md %} {{ loadshed_md("sensor.eskom_vp_next") }}' ``` -------------------------------- ### Required Sensors for Power Distribution Card Source: https://kellerza.github.io/sunsynk/examples/lovelace List the essential sensors that need to be configured for the Power Distribution Card to function correctly. These sensors provide the data for power generation, consumption, and battery status. ```yaml SENSORS: - pv1_power - essential_power - battery_power - battery_soc - non_essential_power - grid_ct_power ``` -------------------------------- ### System Diagnostics Sensors Source: https://kellerza.github.io/sunsynk/reference/definitions List of sensors for system diagnostics and monitoring. These sensors provide insights into the operational status of the system. ```yaml SENSORS: - diagnostics ``` ```yaml SENSORS: - battery_bms_alarm_flag # - battery_bms_fault_flag # - battery_bms_soh # - battery_current # 1PH, 1PH-16kw, 3PH - battery_power # 1PH, 1PH-16kw, 3PH - battery_soc # 1PH, 1PH-16kw, 3PH - battery_temperature # 1PH, 1PH-16kw, 3PH - battery_voltage # 1PH, 1PH-16kw, 3PH - dc_transformer_temperature - fan_warning # 3PH-hv - fault - grid_l1_voltage # 3PH, 3PH-hv - grid_l2_voltage # 3PH, 3PH-hv - grid_l3_voltage # 3PH, 3PH-hv - grid_phase_warning # 3PH-hv - grid_relay_status # 3PH, 3PH-hv - grid_voltage # 1PH, 1PH-16kw - inverter_l1_power # 3PH, 3PH-hv - inverter_l2_power # 3PH, 3PH-hv - inverter_l3_power # 3PH, 3PH-hv - inverter_relay_status # - lithium_battery_loss_warning # 3PH-hv - parallel_communication_quality_warning # 3PH-hv - radiator_temperature ```