diff --git a/dist/sunsynk-power-flow-card.js b/dist/sunsynk-power-flow-card.js index 78534562..c5dbbe14 100644 --- a/dist/sunsynk-power-flow-card.js +++ b/dist/sunsynk-power-flow-card.js @@ -224,8 +224,20 @@ class SunsynkPowerFlowCard extends LitElement { } let duration = ""; + let formattedResultTime = ""; if (battery_power > 0 && config.battery.energy !== "hidden") { let totalSeconds = ((((parseInt(stateObj12.state) - config.battery.shutdown_soc) / 100) * (config.battery.energy || 15960) ) / (battery_power || 1)) * 60 * 60; + + const currentTime = new Date(); // Create a new Date object representing the current time + const durationMilliseconds = totalSeconds * 1000; // Convert the duration to milliseconds + const resultTime = new Date(currentTime.getTime() + durationMilliseconds); // Add the duration in milliseconds + const resultHours = resultTime.getHours(); // Get the hours component of the resulting time + const resultMinutes = resultTime.getMinutes(); // Get the minutes component of the resulting time + const formattedMinutes = resultMinutes.toString().padStart(2, "0"); + const formattedHours = resultHours.toString().padStart(2, "0"); + formattedResultTime = `${formattedHours}:${formattedMinutes}`; + + const days = Math.floor(totalSeconds / (60 * 60 * 24)); const hours = Math.floor((totalSeconds % (60 * 60 * 24)) / (60 * 60)); const minutes = Math.floor((totalSeconds % (60 * 60)) / 60); @@ -240,6 +252,16 @@ class SunsynkPowerFlowCard extends LitElement { else if (battery_power < 0 && config.battery.energy !== "hidden") { let remainingEnergy = (config.battery.energy - (config.battery.energy * (parseInt(stateObj12.state)/100) || 1)); let totalSeconds = ((remainingEnergy / battery_power || 1) * 60 * 60 *-1); + + const currentTime = new Date(); // Create a new Date object representing the current time + const durationMilliseconds = totalSeconds * 1000; // Convert the duration to milliseconds + const resultTime = new Date(currentTime.getTime() + durationMilliseconds); // Add the duration in milliseconds + const resultHours = resultTime.getHours(); // Get the hours component of the resulting time + const resultMinutes = resultTime.getMinutes(); // Get the minutes component of the resulting time + const formattedMinutes = resultMinutes.toString().padStart(2, "0"); + const formattedHours = resultHours.toString().padStart(2, "0"); + formattedResultTime = `${formattedHours}:${formattedMinutes}`; + const days = Math.floor(totalSeconds / (60 * 60 * 24)); const hours = Math.floor((totalSeconds % (60 * 60 * 24)) / (60 * 60)); const minutes = Math.floor((totalSeconds % (60 * 60)) / 60); @@ -263,6 +285,12 @@ class SunsynkPowerFlowCard extends LitElement { float = "False"; } +// let rateofcharge = ""; +// rateofcharge = (parseInt(stateObj35.state) / 312 * 100).toFixed(0); +// if (rateofcharge < 0 ){ +// rateofcharge = ((parseInt(stateObj35.state) / 312 * 100).toFixed(0) * -1); +// } + let inverterStateColour = ""; let inverterStateMsg = ""; if (stateObj21.state === '0' || stateObj21.state === 'standby') { @@ -399,10 +427,10 @@ class SunsynkPowerFlowCard extends LitElement { - + ${duration} - BATTERY RUNTIME - TO FULL CHARGE + RUNTIME TO ${formattedResultTime} + TO FULL CHARGE @${formattedResultTime} BATTERY FLOATING ${totalsolar ? totalsolar : '0'} W PV1 @@ -677,8 +705,8 @@ class SunsynkPowerFlowCard extends LitElement { ${duration} - BATTERY RUNTIME - TO FULL CHARGE + RUNTIME TO ${formattedResultTime} + TO FULL CHARGE @${formattedResultTime} BATTERY FLOATING DAILY CHARGE DAILY DISCHARGE