Fix potential div zero error in init#95
Conversation
Wraps math function inside ternary operator to provide for a "default" value when actual values are not available.
krbaker
left a comment
There was a problem hiding this comment.
This shouldn't assume values if there are none, I think this should be a missing data point and I think None will plumb through here?
|
Updated with feedback. Also, let me know if you have a preference for full fat if/else instead of ternaries as the primary maintainer. I have a tendency toward one-liners when making quick hacks, but for they can sometimes be not so great for code readability. |
Just making sure this is tested and does what I'd expect (I'm not 100% sure, but believe this should result in unknown data for a sample with 0 inverters) I'm perfectly happy with the ternaries, they are small enough they stay perfectly readable (IMO) |
krbaker
left a comment
There was a problem hiding this comment.
so long as this does what I think go for it.
|
I'm testing just by editing the filed directly on my install through the VSCode add-on. I have confirmed your surmise that the value being None make the resulting entitites In |

Wraps math function inside ternary operator to provide for a "default" value when actual values are not available.
I suspect this happens when the virtual meter device is created during local night, when the inverters are in an error state, and associated entites are unavailable.