Skip to content
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

Added value_factor support, to scale value shown in state label #362

Merged
merged 1 commit into from
May 28, 2020

Conversation

dzikimarian
Copy link
Contributor

Hey,
My router reports everything in bytes, which is not very handy for daily use, therefore I added ability to scale value to other unit. If you like it, fell free to merge it.

obraz
Default settings

obraz

Value factor applied

value_factor: -9
decimals: 2
unit: GB

@kalkih kalkih added the feature request New feature or request label May 28, 2020
@kalkih kalkih merged commit befa3c2 into kalkih:dev May 28, 2020
@kalkih
Copy link
Owner

kalkih commented May 28, 2020

Thanks, great addition!

@clavdal
Copy link

clavdal commented Nov 4, 2022

Hi. Great feature. In my case, I need to convert windspeed from KM/H to M/S - so have to multiply it by 0,277778 - This feature doesn't support that if I understand it correctly - Is any other way to make such a modification

@ildar170975
Copy link
Collaborator

Is any other way to make such a modification

template sensor

@dzikimarian
Copy link
Contributor Author

Well, there's a way :-) Since value_factor effectively raises 10 to the power of its value, then it's matter of question: "to which power I need raise 10 in order to get 0.27778“.

This can be done by calculating log10(0.27778), and the answer is -0,556302153 - set value_factor to it and it should be fine (I calculated value over morning coffee, so please double check it's valid :-))

@clavdal
Copy link

clavdal commented Nov 5, 2022

Thanks - Both solutions seem to work - I will save the Template sensor for the next challenge.

@ildar170975
Copy link
Collaborator

ildar170975 commented Nov 5, 2022

In some cases converting units is not a task for a card.
If some integration provides a value with inappropriate unit - shall we convert it in the card?
For instance, Xiaomi Miio gives a total duration of cleaning for robot vacuums in seconds - which is inconvenient.
Surely a user have to create a template sensor to convert this value to "hours" (or whatever) - and then this converted value may be displayed both in Entities card & any graph card (w/o a need to convert).
Alternatively, if some value is displayed with an original unit in many cards and you want to change a unit for just ONE card - then yes, you are interested to convert it in the card.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants