Skip to content

Commit

Permalink
Merge pull request #44 from DanteWinters/develop
Browse files Browse the repository at this point in the history
Feature update
  • Loading branch information
DanteWinters authored Oct 21, 2023
2 parents 4635f50 + c1749b6 commit dce2075
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vscode/
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,22 @@ The four entity images on the card can be clicked to display the history of the
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
The status bar for the parallel inverters works as follows:
- The status that is shown is for the first inverter. The next feature update update will hopefully have it covered.
- If both inverters have normal status, it will display a normal status.
- If only one inverter has an non-normal status, the inverter alias will be displayed along with the non-normal status.
- If all the inverters have the same error (i.e. 'no-grid'), it will display this error on the parallel page.
- If there are multiple different error, the status will display as 'multiple errors' and you will need to go to the specific inverter to see the error.
# Card not loading issue
With this card, there has been multiple isntances of the card not loading. From my exoeience, the best way to fix this is to clear the cache and it should load. I can give instructions for both Android mobile devices and the browser.
With this card, there has been multiple instances of the card not loading. From my experience, the best way to fix this is to clear the cache and it should load. I can give instructions for both Android mobile devices and the browser.
### Android
1. Find *Home Assistant* in the list of apps in settings.
2. This step may differ depending on the Android device. Find anything that indicates data used or storage.
3. When there, find the option to clear all the data (cache and storage). Clearning this will log you out of the app and you'll need to log in again.
3. When there, find the option to clear all the data (cache and storage). Clearing this will log you out of the app and you'll need to log in again.
4. Card should then show up. If it doesn't, please log a bug.
### Web browser
Expand Down
2 changes: 1 addition & 1 deletion config-entity-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,5 +284,5 @@ export function getStatusMessage(status_code, show_no_grid_as_warning) {
break;
}

return `Status: ${message} ${indicator}`;
return `${message} ${indicator}`;
}
68 changes: 58 additions & 10 deletions lux-power-distribution-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,14 @@ class LuxPowerDistributionCard extends HTMLElement {
}
if (index == config.inverter_count) {
for (let i = 0; i < config.inverter_count; i++) {
hass.callService("luxpower", "luxpower_refresh_registers", { dongle: config.lux_dongle.values[i] });
hass.callService("luxpower", "luxpower_refresh_registers", {
dongle: config.lux_dongle.values[i],
});
}
} else {
hass.callService("luxpower", "luxpower_refresh_registers", { dongle: config.lux_dongle.values[index] });
hass.callService("luxpower", "luxpower_refresh_registers", {
dongle: config.lux_dongle.values[index],
});
}
});
}
Expand All @@ -149,10 +153,14 @@ class LuxPowerDistributionCard extends HTMLElement {
}
if (index == config.inverter_count) {
for (let i = 0; i < config.inverter_count; i++) {
hass.callService("luxpower", "luxpower_refresh_registers", { dongle: config.lux_dongle.values[i] });
hass.callService("luxpower", "luxpower_refresh_registers", {
dongle: config.lux_dongle.values[i],
});
}
} else {
hass.callService("luxpower", "luxpower_refresh_registers", { dongle: config.lux_dongle.values[index] });
hass.callService("luxpower", "luxpower_refresh_registers", {
dongle: config.lux_dongle.values[index],
});
}
});
}
Expand Down Expand Up @@ -209,16 +217,56 @@ class LuxPowerDistributionCard extends HTMLElement {
}

updateStatus(index) {
let msg = "";
if (index == -1) {
index = 0;
}
const status_element = this.card.querySelector("#status-cell");
if (status_element) {
let msg = cef.getStatusMessage(
let statuses = [];
let normal_cnt = 0;
let error_cnt = 0;
for (let i = 0; i < this.config.inverter_count; i++) {
let msg_i = cef.getStatusMessage(
parseInt(cef.getEntitiesState(this.config, this._hass, "status_codes", i)),
this.config.status_codes.no_grid_is_warning
);
statuses.push(msg_i);
if (msg_i == `Normal 🟢`) {
normal_cnt++;
} else {
error_cnt++;
}
}
if (error_cnt == 0) {
// no errors
msg = `Status: ${statuses[0]}`;
} else if (error_cnt == 1) {
// single error
let filtered = statuses.filter(function (stat) {
return stat !== "Normal 🟢";
});
let fault_index = statuses.indexOf(filtered[0]);
msg = `${this.config.inverter_alias.values[fault_index]}: ${statuses[fault_index]}`;
} else {
// Multiple or multiple of same
let filtered = statuses.filter(function (stat) {
return stat !== "Normal 🟢";
});
let filtered_again = filtered.filter(function (stat) {
return stat !== filtered[0];
});
if (filtered_again.length == 0) {
msg = `Status: ${statuses[0]}`;
} else {
msg = `Multiple errors 🔴`;
}
}
} else {
msg = cef.getStatusMessage(
parseInt(cef.getEntitiesState(this.config, this._hass, "status_codes", index)),
this.config.status_codes.no_grid_is_warning
);

msg = `Status: ${msg}`;
}
const status_element = this.card.querySelector("#status-cell");
if (status_element) {
status_element.innerHTML = msg;
}
}
Expand Down

0 comments on commit dce2075

Please sign in to comment.