slipx06 / sunsynk-power-flow-card

⚡A customizable Home Assistant card to emulate the Sunsynk System flow that's displayed on the Inverter screen.
MIT License
161 stars 48 forks source link

Refine custom entity validations and improve unit conversions #324

Closed Pho3niX90 closed 3 months ago

Pho3niX90 commented 3 months ago

This commit refines the validation of custom entity's state - ensuring it is not null, empty, undefined, or 'unknown'. It also revamps unit conversion functions for better accuracy and precision, specifically the conversion to power and optimizing conversions for kilowatt units in InverterModel.Solis. These changes enhance the representational accuracy and clarity of data.

fixes: #322

Pho3niX90 commented 3 months ago

@slipx06 the isNaN wasn't properly doing what is was intended. the || was defaulting to the right true whenever the left was falsey, so it would always return true in most cases, it was changed only to nullish ?? so that it only defaults to the right hand side IF the value is null.

Just not sure how this would affect the rest of the sensors, if you can test please.

slipx06 commented 3 months ago

Ok I see the issue there, thanks

slipx06 commented 3 months ago

If you could please test the last commit

Pho3niX90 commented 3 months ago

If you could please test the last commit

Working perfectly from what I can tell, will be 100% sure tomorrow when the sun comes up.

Pho3niX90 commented 3 months ago

okay this change didn't fix it, will investigate what the diff between yours and mine are now.

Pho3niX90 commented 3 months ago

@slipx06 okay this pr works (including your recent commits), master doesn't as well as latest release doesn't.

slipx06 commented 3 months ago

Great will merge

Pho3niX90 commented 3 months ago

@slipx06 one thing I have noticed now is that I have some weird unit conversions. Are you seeing the same?

slipx06 commented 3 months ago

@Pho3niX90 Have not noticed. The only change was kw ->w and mw ->kw if values are <1. What are you seeing?

Pho3niX90 commented 3 months ago

@Pho3niX90 Have not noticed. The only change was kw ->w and mw ->kw if values are <1. What are you seeing?

It seems it might have just been my local dev branch that was incorrectly locally merged with the changes. Resetting it to head fixed the issue.