Skip to content

Commit

Permalink
feat: Shutdown SOC closes #85, CZ lang closes #84
Browse files Browse the repository at this point in the history
  • Loading branch information
slipx06 committed Oct 7, 2023
1 parent 4bdb510 commit 343f423
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 8 deletions.
6 changes: 3 additions & 3 deletions dist/sunsynk-power-flow-card.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ To display battery power and current as absolute values set `show_absolute: true
| Attribute | Requirement |Default | Description |
| --- | --- | --- |--- |
|energy: | **Required** | `0` | Total battery energy in Wh (e.g. 3 x 5.32kWh = 15960). If set to `0` the remaining battery runtime will be hidden|
|shutdown_soc: | **Required** | `20` |The battery shutdown percentage used to calculate remaining runtime |
|shutdown_soc: | **Required** | `20` |The battery shutdown percentage used to calculate remaining runtime. Numeric value or sensor i.e. `sensor.sunsynk_battery_capacity_shutdown` |
|invert_power:| Optional | `false`|Set to `true` if your sensor provides a positive number for battery charge and negative number for battery discharge|
|colour:| Optional| `pink`| Changes the colour of all the battery card objects. Hex codes (`'#66ff00'` etc) or names (`red`, `green`, `blue` etc) |
|show_daily: | Optional| `false` | Toggles the daily total |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sunsynk-power-flow-card",
"version": "2.8.0",
"version": "2.9.0",
"description": "A customizable Home Assistant card to emulate the Sunsynk System flow that's displayed on the Inverter screen.",
"main": "sunsynk-power-flow-card.js",
"scripts": {
Expand Down
11 changes: 8 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,11 @@ export class SunsynkPowerFlowCard extends LitElement {
charge: this.hass.states[config.entities.prog6_charge] || { state: '' }
};

const shutdownsoc = this.hass.states[config.battery.shutdown_soc] || { state: '' };
let shutdown = isNaN(parseInt(shutdownsoc.state)) ? config.battery.shutdown_soc : parseInt(shutdownsoc.state);
let inverter_prog: inverterProg = {
capacity: config.battery.shutdown_soc,
// capacity: config.battery.shutdown_soc,
capacity: shutdown,
entityID: ''
};
if (!config.entities.use_timer_248 || config.entities.use_timer_248 === false || stateObj26.state === 'off') {
Expand Down Expand Up @@ -318,7 +321,8 @@ export class SunsynkPowerFlowCard extends LitElement {
let battery_capacity: number = 0;
if (config.show_battery !== false && battery_power > 0) {
if (stateObj20.state === "off" || inverter_prog.show === false || parseInt(stateObj12.state) <= inverter_prog.capacity) {
battery_capacity = config.battery.shutdown_soc;
// battery_capacity = config.battery.shutdown_soc;
battery_capacity = shutdown;
} else {
battery_capacity = inverter_prog.capacity;
}
Expand All @@ -337,7 +341,8 @@ export class SunsynkPowerFlowCard extends LitElement {

if (config.show_battery !== false || config.battery.energy !== 0) {
if (battery_power === 0) {
totalSeconds = (((parseInt(stateObj12.state) - config.battery.shutdown_soc) / 100) * config.battery.energy) / 1 * 60 * 60;
// totalSeconds = (((parseInt(stateObj12.state) - config.battery.shutdown_soc) / 100) * config.battery.energy) / 1 * 60 * 60;
totalSeconds = (((parseInt(stateObj12.state) - shutdown) / 100) * config.battery.energy) / 1 * 60 * 60;
} else if (battery_power > 0) {
totalSeconds = (((parseInt(stateObj12.state) - battery_capacity) / 100) * config.battery.energy) / battery_power * 60 * 60;
} else if (battery_power < 0) {
Expand Down
53 changes: 53 additions & 0 deletions src/localize/languages/cz.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"common": {
"description": "A Home Assistant card to emulate the Sunsynk power flow that's shown on the Inverter screen",
"version": "Verze",
"runtime_to": "ČAS VYBITÍ DO",
"battery_floating": "BATERIE JE NABITÁ",
"charge": "NABÍT",
"to": "DO",
"daily_load": "DNES SPOTŘEBA",
"daily_aux": "DENNÍ VSTUP",
"daily_grid_buy": "DNES NÁKUP",
"daily_grid_sell": "DNES PRODEJ",
"daily_solar": "DNES VÝROBA",
"daily_solar_left": "DNES VÝROBA / CELKEM VÝROBA",
"daily_charge": "DNES NABÍJENÍ",
"daily_discharge": "DNES VYBÍJENÍ",
"ratio": "Poměr",
"timer_off": "Časovač off",
"timer_on": "Časovač on",
"priority_batt": "Nabít Baterii z ds",
"priority_load": "Prioritní Spotřeba",
"nonessential_name": "Nedostupné",
"aux_name": "Pomocné",
"load1_name": "",
"load2_name": "",
"pv1_name": "PV1",
"pv2_name": "PV2",
"pv3_name": "PV3",
"pv4_name": "PV4",
"essential": "Nezbytný"
},
"errors": {
"battery": {
"bat": "Nejsou definovány žádné atributy baterie",
"energy": "Uveďte prosím atribut energie baterie a hodnotu ve Wh, např. 5,32 Energie baterie: 5320",
"shutdown_soc": "Uveďte atribut battery shut down_soc a hodnotu, např. shutdown_soc: 20 shutdown_soc: 20",
"full_capacity": "Plná kapacita musí být mezi 80 a 100",
"empty_capacity": "Prázdná kapacita musí být <= 30",
"show_daily": "Please include the day_battery_charge_70 and day_battery_discharge_71 attributes and entity IDs"
},
"solar": {
"sol": "Nejsou definovány žádné sluneční atributy",
"mppts": "Uveďte prosím atribut a hodnotu solar mppts; 1,2,3 nebo 4 např. mppts: 2",
"show_daily": "Uveďte prosím atribut day_pv_energy_108 a ID entity"
},
"grid": {
"show_daily": "Uveďte prosím atributy day_grid_import_76 a day_grid_export_77 a ID entit"
},
"essential_power": "Atribut essential_power je nastaven na hodnotu none. Uveďte prosím atribut inverter_power_175 a ID entity, aby karta mohla vypočítat tuto hodnotu.",
"nonessential_power": "Atribut neesenciální_výkon je nastaven na hodnotu none. Uveďte prosím atribut grid_power_169 a ID entity, aby karta mohla vypočítat tuto hodnotu.",
"missing_entity": "Uveďte prosím atribut a ID entity"
}
}
2 changes: 2 additions & 0 deletions src/localize/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as et from './languages/et.json';
import * as fr from './languages/fr.json';
import * as nl from './languages/nl.json';
import * as ru from './languages/ru.json';
import * as cz from './languages/cz.json';

const languages: any = {
da: da,
Expand All @@ -16,6 +17,7 @@ const languages: any = {
fr: fr,
nl: nl,
ru: ru,
cz: cz,
};

export function localize(string: string, search = '', replace = '') {
Expand Down

0 comments on commit 343f423

Please sign in to comment.