-
-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow customisation of location-card badges. #890
Allow customisation of location-card badges. #890
Conversation
0f96cf1
to
4ebc895
Compare
Just wanted to say I really like this idea. Having all "open" Rollershutters shown makes no sense for me either, but for other types of Blinds I like it, so being able to configure it would indeed be nice. |
Thanks @crnjan and sorry for the delay. Part of the reason I sat on this PR is that while we're at it, it could be good to go all the way and add some parameters to also specify not only the "reduce" part but also the "map" part: arrays of equipment classes to consider, with or without subclasses, possibly other criteria too. I'd be tempted to approve this PR as-is, as it looks good, to be honest, that being said, if we have to change the API afterwards again it's probably best to figure out what we aim to do before introducing new options. |
Thx for the feedback, totally agree - but unfortunately don't get much (spare) time last days, will try to figure something up ASAP. |
Signed-off-by: Boris Krivonog <boris.krivonog@inova.si>
Signed-off-by: Boris Krivonog <boris.krivonog@inova.si>
Signed-off-by: Boris Krivonog <boris.krivonog@inova.si>
ad913a4
to
97a20ef
Compare
Job #23: Bundle Size — 10.88MB (~+0.01%).Changed metrics (2/8)
|
@@ -73,14 +73,14 @@ export default { | |||
} | |||
}, | |||
map () { | |||
return this.query.map((item) => this.store[item.name].state).filter((state) => Number.isFinite(Number.parseFloat(state.split(' ')[0]))) | |||
return this.query.map((item) => this.store[item.name].state).filter((state) => Number.isFinite(Number.parseFloat(state))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why these .split(' ')|0]
were removed? They seemed to be useful when you had math operations to perform on quantity types (represented as strings with the unit in the API, you can't perform e.g. averages with them).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If parseFloat encounters a character other than a plus sign (+), minus sign (- U+002D HYPHEN-MINUS), numeral (0–9), decimal point (.), or exponent (e or E), it returns the value up to that character, ignoring the invalid character and characters following it.
So IMHO it's not needed ... from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat
The following examples all return 3.14:
parseFloat(3.14);
parseFloat('3.14');
parseFloat(' 3.14 ');
parseFloat('314e-2');
parseFloat('0.0314E+2');
parseFloat('3.14some non-digit characters');
so parseFloat('3.14 C');
should work ...
Sorry for delayed responses, I hope I'll find some spare time over the weekend to make some progress, if not before ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry Boris for the long delay. I think your changes are valuable and if we're ever to change the API, as long as we agree on them for the long-term and revisit them, eventually, they're okay to include for now.
@crnjan Nice work. May I ask you to add this to the documentation. That would be really much appreciated. Thanks in advance. |
Was using OH 3 before #771 was merged - at that time blinds badges were displayed on location card(s) when rollershutters were closed (in my case position > 0) - and after fix was merged, really still cannot get used seeing badge when blinds are open (up) :)
So instead of arguing what is better, let's make it configurable so each can decide what suits best.
For example - Living Room, 3 blinds, 2 closed - default configuration:
If we want to see blind's badge when
position > 0
we can writeresult
We can override icon too
Badges can be overridden per card (as above example) or for all cards
If both are specified, per-card definition takes precedence.
All badges can be overridden, i.e. both lights&blinds
result
I look forward to any feedback or comments.
Signed-off-by: Boris Krivonog boris.krivonog@inova.si