Skip to content

Commit

Permalink
- Reworked codebase to open path for parallel inverters.
Browse files Browse the repository at this point in the history
- Spread code over different files in order to help the development process.
  • Loading branch information
DanteWinters committed Aug 30, 2023
1 parent 288c4ab commit caadee0
Show file tree
Hide file tree
Showing 6 changed files with 997 additions and 715 deletions.
118 changes: 69 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ DanteWinters/lux-power-distribution-card

## Manual install

1. Download `lux-power-distribution-card.js` from the [latest release](https://github.com/DanteWinters/lux-power-distribution-card/releases/latest) and copy it into your `config/www` directory.
1. Download the four JavaScript files (`lux-power-distribution-card.js`, `config-entity-functions.js`, `html-functions.js` and `constants.js`) from the [latest release](https://github.com/DanteWinters/lux-power-distribution-card/releases/latest) and copy it into your `config/www` directory.

2. Add the resource reference:
1. Visit the Resources page in your Home Assistant instance [![Open your Home Assistant instance and show your dashboard resources.](https://my.home-assistant.io/badges/lovelace_resources.svg)](https://my.home-assistant.io/redirect/lovelace_resources/)
Expand All @@ -33,34 +33,41 @@ DanteWinters/lux-power-distribution-card
## Configuration
The following is a list of configs for the card:

**NOTE:** All entities must be added as an entity underneath the config. Refer to the example code below on how this looks.
**NOTE:** Please refer to the example config below for clarification on how the entities should be added.

### Required configurations

| Name | Type | Description |
|---|:---:|---|
| battery_soc | entity | Battery state of charge |
| battery_flow | entity | Power flowing from and to the battery. Negative flow is discharge, and positive flow is charge. |
| home_consumption | entity | Output power of the inverter to your home. |
| grid_flow | entity | Power flowing to and from grid. Negative flow is import from grid, and positive flow is export to grid. |
| inverter_count | number | The number of inverters used in the system. Must be a positive integer that is 1 or higher. |
| battery_soc | entities | Battery state of charge. |
| battery_flow | entities | Power flowing from and to the battery. Negative flow is discharge, and positive flow is charge. |
| home_consumption | entities | Output power of the inverter to your home. |
| grid_flow | entities | Power flowing to and from grid. Negative flow is import from grid, and positive flow is export to grid. |

### Optional configurations

| Name | Type | Description |
|---|:---:|---|
| battery_voltage | entity | Battery's voltage. |
| pv_power | entity | Solar power. |
| backup_power | entity | This is off-grid power. In the case of the LuxpowerTek inverter, this is used when grid is not available. |
| grid_voltage | entity | Grid's voltage. |
| energy_allocations | list of entities | This is not a single entity, but a list of entities. Explanation below. |
| update_time | entity | An entity for the last time the values were updated. |
| update_time_timestamp_attribute | boolean | If the update time entity has atimestamp attribute, it can be used to show how long since the last update. |
| grid_indicator_hue | boolean | If this is set to true and the grid voltage drops to 0, the grid image will become dimmer. (Requires a grid voltage entity.) |
| grid_indicator_dot | boolean | If this is set to true and the grid voltage drops to 0, a red indicator will be added next to the grid voltage text. (Requires a grid voltage entity.)|
| use_lux_status_codes | entity | This is used with the *lux_fail_status_codes* list. If the status code is in the given list, a warning will show on the top right card to indicate something is wrong. |
| lux_fail_status_codes | integer list | List of failure codes that will show a warning at the top right of the card. |
| lux_dongle | string | This is the LuxPower inverter's dongle number. It will later on be used to call the refresh service. (This requires the LuxPowerTek integration that supports this.)
| refresh_button_location | string | the location of the refresh button. see below for more information. **NOTE:** the refresh button will only show if the *lux_dongle* is added. |
|---|---|---|
| battery_voltage | entities | Battery's voltage. |
| pv_power | entities | Solar power. |
| backup_power | entities | This is off-grid power. In the case of the LuxpowerTek inverter, this is used when grid is not available. |
| grid_voltage | entities | Grid's voltage. |
| energy_allocations | entities | This is not a single entity, but a list of entities. Explanation below. |
| update_time | entities | An entity for the last time the values were updated. |
| status_codes | entities | An entity that has the inverter status. This is directly used with the LuxpowerTek integration (See below). |
| lux_dongle | list of strings | This is the LuxPower inverter's dongle number. It will later on be used to call the refresh service. (This requires the LuxPowerTek integration that supports this.) This or the inverter alias list are required if there are more than 1 inverter. |
| inverter_alias | list of strings | This is used when there is more than 1 inverter. This will be the names used in the dropdown list. This or the lux dongle list is required. |
| refresh_button | string | The location of the refresh button. Can be 'left', 'right' or 'both'. See below for more information. **NOTE:** the refresh button will only show if the *lux_dongle* is added. |

### Sub-configs that are not a list of entities or values

| Parent | Name | Type | Description |
|---|---|---|---|
| grid_indicator | hue | bool | If this is set to true and the grid voltage drops to 0, the grid image will become dimmer. (Requires a grid voltage entity.) |
| grid_indicator | dot | bool | If this is set to true and the grid voltage drops to 0, a red indicator will be added next to the grid voltage text. (Requires a grid voltage entity.) |
| update_time | show_last_update | bool | If the update time entity has a timestamp attribute, it can be used to show how long since the last update. |
| status_codes | no_grid_is_warning | bool | Some status codes (64, 136 and 192) are shown when grid is not available. If this value is true, these codes will show up as a warning on the status. If the value is false, these values will show up as normal. |

# LuxpowerTek integration

Expand All @@ -72,34 +79,46 @@ If you have the Luxpower integration, you can use the following code directly (e

```yaml
type: custom:lux-power-distribution-card
inverter_count: 1
battery_soc:
entity: sensor.lux_battery
entities:
- sensor.lux_battery
battery_flow:
entity: sensor.lux_battery_flow_live
entities:
- sensor.lux_battery_flow_live
home_consumption:
entity: sensor.lux_home_consumption_live
entities:
- sensor.lux_home_consumption_live
grid_flow:
entity: sensor.lux_grid_flow_live
entities:
- sensor.lux_grid_flow_live
lux_dongle:
- BAxxxxxxxx
inverter_alias:
- Inverter 1
battery_voltage:
entity: sensor.lux_battery_voltage_live
entities:
- sensor.lux_battery_voltage_live
pv_power:
entity: sensor.lux_solar_output_live
entities:
- sensor.lux_solar_output_live
backup_power:
entity: sensor.lux_power_to_eps_live
entities:
- sensor.lux_power_to_eps_live
grid_voltage:
entity: sensor.lux_grid_voltage_live
entities:
- sensor.lux_grid_voltage_live
update_time:
entity: sensor.lux_data_received_time
update_time_timestamp_attribute: true
grid_indicator_hue: true
use_lux_status_codes: true
lux_status_code:
entity: sensor.lux_status
lux_fail_status_codes:
- 64
- 16
lux_dongle: BA________
refresh_button_location: right
entities:
- sensor.lux_data_received_time
show_last_update: true
grid_indicator:
hue: true
status_codes:
entities:
- sensor.lux_status
no_grid_is_warning: true
refresh_button: right
energy_allocations:
entities:
- sensor.power_plug_1
Expand All @@ -108,16 +127,6 @@ energy_allocations:
- sensor.power_plug_4
```
## Status codes
The status codes are up to the user for what they want to see the warning for.
Currently there are 2 options that will be displayed:
- *Status: Normal 🟢*
- *Status: Warning 🔴*
At some point in time, the warning message may be updated and be based on the status represented by the code.
## Refresh and the Dongle serial number
This refresh only works for the LuxPowerTek integration referenced above. The service name and function call format are hard-coded.
Expand Down Expand Up @@ -156,6 +165,17 @@ The four entity images on the card can be clicked to display the history of the
- Home Image: Home consumption entity's history.
- Grid Image: Grid flow entity's history.
# Parallel inverters
With v1.0.0, support for parallel inverters have arrived! In order to use parallel inverters, simply indicate the number of inverters you are using in the config, and add the additional inverter's entities under their corresponding headers. Take note of the *inverter_alias* and *lux_dongle* config values when using parallel inverters.
### Known issues
- Currently there is no option to mix the values, but that is on the roadmap.
- The refresh button only works on the first dongle value added.
# Developer's note
Although the card is functional and even has a few nice features, the development of it was done with a lot of inexperience. From my side, I do not have JavaScript or HTML experience other than this card. For this reason, there may be many ways I implemented things that aren't optimal or safe. If you are knowledgeable in and willing to look through the code, and advice and help will be much appreciated.
In addition, I currently only have 1 inverter. So the tests for the parallel inverters were done purely in a testing environment and may have some bugs.
Loading

0 comments on commit caadee0

Please sign in to comment.