Skip to content

Commit

Permalink
feat: adds off_colour: and remaining_energy_to_shutdown: closes #577
Browse files Browse the repository at this point in the history
 closes #554
  • Loading branch information
slipx06 committed Dec 18, 2024
1 parent ddb7fdb commit a230418
Show file tree
Hide file tree
Showing 23 changed files with 163 additions and 48 deletions.
9 changes: 6 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ The `invert_power` attribute can be used to reverse direction if needed by your
| show_absolute: | Optional | `false` | set to `true` to display power and current as absolute values.
| auto_scale: | Optional | `true` | If set to `true` the card will use the entities `unit_of_measurement` attribute to perform the correct scaling (i,e, power values greater than 999W will be displayed as kW e.g. 1.23kW) and display the correct unit. The number of decimal places can be changed using the `decimal_places` card attribute apart from the daily energy values which are set using the `decimal_places_energy` attribute. |
| hide_soc: | Optional | `false` | If set to `true` the current program capacity (soc), or for Goodwe inverters the shutdown soc and offgrid shutdown soc that is shown to the left of the current battery one SOC will be hidden. |
| show_remaining_energy: | Optional | `true` | Set to `true` to display the remaining battery one energy in kWh based on the current SOC. Only visable on the `lite` and `full` cards. |
| show_remaining_energy: | Optional | `true` | Set to `true` to display the remaining battery one energy in kWh based on the current SOC. |
| remaining_energy_to_shutdown: | Optional | `false` | If set to `true` the displayed remaining battery energy will be the available energy to the shutdown SOC and not to 0%. |
| navigate: | Optional | | Sets the navigation path when clicking on the battery one image. Can be used to link to other dashboards and views e.g. `/lovelace/1`.
| invert_flow: | Optional | `false` | Inverts the animated flow. Expects a positive number for battery charging and a negative number for battery discharging

Expand All @@ -96,7 +97,8 @@ The `invert_power` attribute can be used to reverse direction if needed by your
| show_absolute: | Optional | `false` | set to `true` to display power and current as absolute values.
| auto_scale: | Optional | `true` | If set to `true` the card will use the entities `unit_of_measurement` attribute to perform the correct scaling (i,e, power values greater than 999W will be displayed as kW e.g. 1.23kW) and display the correct unit. The number of decimal places can be changed using the `decimal_places` card attribute apart from the daily energy values which are set using the `decimal_places_energy` attribute. |
| hide_soc: | Optional | `false` | If set to `true` the current program capacity (soc), or for Goodwe inverters the shutdown soc and offgrid shutdown soc that is shown to the left of the current battery SOC will be hidden. |
| show_remaining_energy: | Optional | `true` | Set to `true` to display the remaining battery two energy in kWh based on the current SOC. Only visable on the `lite` and `full` cards. |
| show_remaining_energy: | Optional | `true` | Set to `true` to display the remaining battery two energy in kWh based on the current SOC. |
| remaining_energy_to_shutdown: | Optional | `false` | If set to `true` the displayed remaining battery energy will be the available energy to the shutdown SOC and not to 0%. |
| navigate: | Optional | | Sets the navigation path when clicking on the battery two image. Can be used to link to other dashboards and views e.g. `/lovelace/1`.
| invert_flow: | Optional | `false` | Inverts the animated flow. Expects a positive number for battery two charging and a negative number for battery two discharging

Expand Down Expand Up @@ -131,7 +133,8 @@ These attributes are only needed if `show_solar` is set to `true`.

| Attribute | Requirement | Default | Description |
|--------------------|-------------|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| colour: | Optional | `'#5fb6ad'` | Setss the colour of all the load card objects. Hex codes (`'#66ff00'` etc) or names (`red`, `green`, `blue` etc). |
| colour: | Optional | `'#5fb6ad'` | Sets the colour of all the load card objects. Hex codes (`'#66ff00'` etc) or names (`red`, `green`, `blue` etc). |
| off_colour: | Optional | `grey` | Sets the off colour for the additional essential loads. Set this to `transparent` to hide the load when power is below the `off_threshold` |
| dynamic_colour: | Optional | `true` | The essential icon colour will change based on the % contribution of the power source (battery, grid, solar) supplying the load. Set to `false` to disable. |
| dynamic_icon: | Optional | `true` | The essential icon will change when there is 100% contribution from a single power source (battery, grid, solar). Set to `false` to disable. |
| invert_load: | Optional | `false` | Set to `true` if your sensor provides a negative number when the load is drawing power. |
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": "6.1.7",
"version": "6.2.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
30 changes: 19 additions & 11 deletions src/cards/compact-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,10 @@ export const compactCard = (config: sunsynkPowerFlowCardConfig, inverterImg: str
class="${!config.entities?.battery_status && !data.compactMode ? 'st3' : 'st3 left-align'}"
display="${!config.battery.show_remaining_energy || (data.compactMode && data.batteryCount === 2) ? 'none' : ''}"
fill="${data.batteryColour}">
${Utils.toNum((data.batteryEnergy * (data.stateBatterySoc.toNum(2) / 100) / 1000), 2)}
${UnitOfEnergy.KILO_WATT_HOUR}
${!config.battery.remaining_energy_to_shutdown
? `${Utils.toNum((data.batteryEnergy * (data.stateBatterySoc.toNum() / 100) / 1000), 2)} ${UnitOfEnergy.KILO_WATT_HOUR}`
: `${Utils.toNum((data.batteryEnergy * ((data.stateBatterySoc?.toNum() - data.batteryOneShutdown) / 100) / 1000), 2)} ${UnitOfEnergy.KILO_WATT_HOUR}`
}
</text>
<text x="169" y="${!config.battery.show_remaining_energy ? '320' : '311'}" class="st3 left-align"
display="${data.compactMode ? 'none' : ''}"
Expand Down Expand Up @@ -610,8 +612,10 @@ export const compactCard = (config: sunsynkPowerFlowCardConfig, inverterImg: str
class="st3 left-align"
display="${!config.battery.show_remaining_energy ? 'none' : ''}"
fill="${data.batteryColour}">
${Utils.toNum((data.batteryEnergy * (data.stateBatterySoc.toNum(2) / 100) / 1000), 2)}
${UnitOfEnergy.KILO_WATT_HOUR}
${!config.battery.remaining_energy_to_shutdown
? `${Utils.toNum((data.batteryEnergy * (data.stateBatterySoc.toNum() / 100) / 1000), 2)} ${UnitOfEnergy.KILO_WATT_HOUR}`
: `${Utils.toNum((data.batteryEnergy * ((data.stateBatterySoc?.toNum() - data.batteryOneShutdown) / 100) / 1000), 2)} ${UnitOfEnergy.KILO_WATT_HOUR}`
}
</text>
</svg>
<svg id="two_batteries_data_compact_bat2"
Expand Down Expand Up @@ -655,8 +659,10 @@ export const compactCard = (config: sunsynkPowerFlowCardConfig, inverterImg: str
class="st3 left-align"
display="${!config.battery2.show_remaining_energy ? 'none' : ''}"
fill="${data.battery2Colour}">
${Utils.toNum((data.battery2Energy * (data.stateBattery2Soc.toNum(2) / 100) / 1000), 2)}
${UnitOfEnergy.KILO_WATT_HOUR}
${!config.battery2.remaining_energy_to_shutdown
? `${Utils.toNum((data.battery2Energy * (data.stateBattery2Soc.toNum() / 100) / 1000), 2)} ${UnitOfEnergy.KILO_WATT_HOUR}`
: `${Utils.toNum((data.battery2Energy * ((data.stateBattery2Soc?.toNum() - data.batteryTwoShutdown) / 100) / 1000), 2)} ${UnitOfEnergy.KILO_WATT_HOUR}`
}
</text>
</svg>
<svg id="battery2_data_lite"
Expand Down Expand Up @@ -705,8 +711,10 @@ export const compactCard = (config: sunsynkPowerFlowCardConfig, inverterImg: str
class="${!config.entities?.battery2_status ? 'st3' : 'st3 left-align'}"
display="${!config.show_battery || !config.battery2.show_remaining_energy ? 'none' : ''}"
fill="${data.battery2Colour}">
${Utils.toNum((data.battery2Energy * (data.stateBattery2Soc.toNum(2) / 100) / 1000), 2)}
${UnitOfEnergy.KILO_WATT_HOUR}
${!config.battery2.remaining_energy_to_shutdown
? `${Utils.toNum((data.battery2Energy * (data.stateBattery2Soc.toNum() / 100) / 1000), 2)} ${UnitOfEnergy.KILO_WATT_HOUR}`
: `${Utils.toNum((data.battery2Energy * ((data.stateBattery2Soc?.toNum() - data.batteryTwoShutdown) / 100) / 1000), 2)} ${UnitOfEnergy.KILO_WATT_HOUR}`
}
</text>
<text x="169" y="${!config.battery2.show_remaining_energy ? '320' : '311'}" class="st3 left-align"
display="${!config.show_battery ? 'none' : ''}"
Expand Down Expand Up @@ -1973,15 +1981,15 @@ export const compactCard = (config: sunsynkPowerFlowCardConfig, inverterImg: str
</circle>
</svg>
<path id="es-load1" d="M 441 180 L 441 147" class="${data.additionalLoad === 1 ? '' : 'st12'}"
fill="none" stroke="${data.loadColour}" stroke-width="1" stroke-miterlimit="10"
fill="none" stroke="${data.load1Colour}" stroke-width="1" stroke-miterlimit="10"
pointer-events="stroke"/>
<path id="es-load1" d="M 441 180 L 441 147"
class="${[2, 3, 4, 5, 6].includes(data.additionalLoad) ? '' : 'st12'}" fill="none"
stroke="${data.loadColour}" stroke-width="1" stroke-miterlimit="10"
stroke="${data.load1Colour}" stroke-width="1" stroke-miterlimit="10"
pointer-events="stroke"/>
<path id="es-load2" d="M 441 290 L 441 257"
class="${[2, 3, 4, 5, 6].includes(data.additionalLoad) ? '' : 'st12'}" fill="none"
stroke="${data.loadColour}" stroke-width="1" stroke-miterlimit="10"
stroke="${data.load2Colour}" stroke-width="1" stroke-miterlimit="10"
pointer-events="stroke"/>
${config.load?.navigate
? svg`
Expand Down
20 changes: 12 additions & 8 deletions src/cards/full-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,10 @@ export const fullCard = (config: sunsynkPowerFlowCardConfig, inverterImg: string
<text x="101" y="378" class="st3"
display="${!config.battery.show_remaining_energy ? 'none' : ''}"
fill="${data.batteryColour}">
${Utils.toNum((data.batteryEnergy * (data.stateBatterySoc?.toNum() / 100) / 1000), 2)}
${UnitOfEnergy.KILO_WATT_HOUR}
${!config.battery.remaining_energy_to_shutdown
? `${Utils.toNum((data.batteryEnergy * (data.stateBatterySoc.toNum() / 100) / 1000), 2)} ${UnitOfEnergy.KILO_WATT_HOUR}`
: `${Utils.toNum((data.batteryEnergy * ((data.stateBatterySoc?.toNum() - data.batteryOneShutdown) / 100) / 1000), 2)} ${UnitOfEnergy.KILO_WATT_HOUR}`
}
</text>
</svg>
<svg id="battery2_icon"
Expand Down Expand Up @@ -768,8 +770,10 @@ export const fullCard = (config: sunsynkPowerFlowCardConfig, inverterImg: string
<text x="101" y="378" class="st3"
display="${!config.battery2.show_remaining_energy ? 'none' : ''}"
fill="${data.battery2Colour}">
${Utils.toNum((data.battery2Energy * (data.stateBattery2Soc?.toNum() / 100) / 1000), 2)}
${UnitOfEnergy.KILO_WATT_HOUR}
${!config.battery2.remaining_energy_to_shutdown
? `${Utils.toNum((data.battery2Energy * (data.stateBattery2Soc.toNum() / 100) / 1000), 2)} ${UnitOfEnergy.KILO_WATT_HOUR}`
: `${Utils.toNum((data.battery2Energy * ((data.stateBattery2Soc?.toNum() - data.batteryTwoShutdown) / 100) / 1000), 2)} ${UnitOfEnergy.KILO_WATT_HOUR}`
}
</text>
</svg>
<svg id="battery1_remaining"
Expand Down Expand Up @@ -1952,17 +1956,17 @@ export const fullCard = (config: sunsynkPowerFlowCardConfig, inverterImg: string
</text>
<path id="es-load1" d="M 409 143 L 409 135" display="${data.showAux ? '' : 'none'}"
class="${[1, 2].includes(data.additionalLoad) ? '' : 'st12'}" fill="none"
stroke="${data.loadColour}" stroke-width="1" stroke-miterlimit="10"
stroke="${data.load1Colour}" stroke-width="1" stroke-miterlimit="10"
pointer-events="stroke"/>
<path id="es-load1" d="M 412 143 L 412 135" display="${!data.showAux ? '' : 'none'}"
class="${[4, 5, 6].includes(data.additionalLoad) ? '' : 'st12'}" fill="none"
stroke="${data.loadColour}" stroke-width="1" stroke-miterlimit="10"
stroke="${data.load2Colour}" stroke-width="1" stroke-miterlimit="10"
pointer-events="stroke"/>
<path id="es-load1" d="M 412 80 L 412 60" display="${!data.showAux ? '' : 'none'}"
class="${data.additionalLoad === 1 ? '' : 'st12'}" fill="none" stroke="${data.loadColour}"
class="${data.additionalLoad === 1 ? '' : 'st12'}" fill="none" stroke="${data.load1Colour}"
stroke-width="1" stroke-miterlimit="10" pointer-events="stroke"/>
<path id="es-load2" d="M 412 80 L 412 53" display="${!data.showAux ? '' : 'none'}"
class="${[2, 4, 5, 6].includes(data.additionalLoad) ? '' : 'st12'}" fill="none" stroke="${data.loadColour}"
class="${[2, 4, 5, 6].includes(data.additionalLoad) ? '' : 'st12'}" fill="none" stroke="${data.load1Colour}"
stroke-width="1" stroke-miterlimit="10" pointer-events="stroke"/>
<svg id="load-flow">
<circle id="es-dot" cx="0" cy="0"
Expand Down
3 changes: 3 additions & 0 deletions src/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default {
colour: 'pink',
show_daily: false,
show_remaining_energy: true,
remaining_energy_to_shutdown: false,
animation_speed: 6,
max_power: 4500,
show_absolute: false,
Expand All @@ -53,6 +54,7 @@ export default {
hide_soc: false,
colour: 'pink',
show_remaining_energy: true,
remaining_energy_to_shutdown: false,
show_absolute: false,
auto_scale: true,
dynamic_colour: true,
Expand Down Expand Up @@ -82,6 +84,7 @@ export default {
},
load: {
colour: '#5fb6ad',
off_colour: 'grey',
dynamic_colour: true,
dynamic_icon: true,
aux_dynamic_colour: true,
Expand Down
4 changes: 4 additions & 0 deletions src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ export class SunSynkCardEditor extends LitElement implements LovelaceCardEditor
{name: 'animate', selector: {boolean: {}}},
{name: 'hide_soc', selector: {boolean: {}}},
{name: 'show_remaining_energy', selector: {boolean: {}}},
{name: 'remaining_energy_to_shutdown', selector: {boolean: {}}},
{name: 'navigate', selector: {text: {}}},
{name: 'invert_flow', selector: {boolean: {}}},
],
Expand Down Expand Up @@ -263,7 +264,9 @@ export class SunSynkCardEditor extends LitElement implements LovelaceCardEditor
{name: 'animate', selector: {boolean: {}}},
{name: 'hide_soc', selector: {boolean: {}}},
{name: 'show_remaining_energy', selector: {boolean: {}}},
{name: 'remaining_energy_to_shutdown', selector: {boolean: {}}},
{name: 'navigate', selector: {text: {}}},
{name: 'invert_flow', selector: {boolean: {}}},
],
},
{
Expand Down Expand Up @@ -297,6 +300,7 @@ export class SunSynkCardEditor extends LitElement implements LovelaceCardEditor
{name: 'show_daily', selector: {boolean: {}}},
{name: 'auto_scale', selector: {boolean: {}}},
{name: 'colour', selector: {color_rgb: {}}},
{name: 'off_colour', selector: {color_rgb: {}}},
{name: 'dynamic_colour', selector: {boolean: {}}},
{name: 'dynamic_icon', selector: {boolean: {}}},
{name: 'invert_load', selector: {boolean: {}}},
Expand Down
Loading

0 comments on commit a230418

Please sign in to comment.