diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dbe9c82 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vscode/ \ No newline at end of file diff --git a/README.md b/README.md index 924bc6f..92fdcae 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/config-entity-functions.js b/config-entity-functions.js index 1068e88..5b262a7 100755 --- a/config-entity-functions.js +++ b/config-entity-functions.js @@ -284,5 +284,5 @@ export function getStatusMessage(status_code, show_no_grid_as_warning) { break; } - return `Status: ${message} ${indicator}`; + return `${message} ${indicator}`; } diff --git a/lux-power-distribution-card.js b/lux-power-distribution-card.js index 6cf1846..9e05968 100755 --- a/lux-power-distribution-card.js +++ b/lux-power-distribution-card.js @@ -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], + }); } }); } @@ -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], + }); } }); } @@ -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; } }