GithubHelp home page GithubHelp logo

Comments (37)

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024 1

Hmm... I downloaded Opera and it was fine. I'll take a look at the refresh behaviour tomorrow morning. Odd.

from bom-weather-card.

bieniu avatar bieniu commented on May 23, 2024 1

I think now we have the expected result. Each number is displayed in the same way as on the HA core cards. Great work 👍

from bom-weather-card.

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024

I don't believe I am controlling that in the card anywhere. What does HA show in dev-tools as the state? Is that formatted correctly? The card should have the same format as the state does.

from bom-weather-card.

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024

I was thinking about this last night. Its probably html formatting like described here
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString
I'm going to see if I can do this.

from bom-weather-card.

bieniu avatar bieniu commented on May 23, 2024

Entity states use . as a decimal separator. Changing to , is a matter of formatting. Maybe you could add this as an option?

from bom-weather-card.

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024

As per above I'll see if I can utilise the tolocalesrting in js to do this. I think I can read the locale from HA. I will need you to test this for your system when I get it in there. I may just do the visibility first so you can confirm I'm on the right track. It will be next week as I am going away for a few days.....

from bom-weather-card.

bieniu avatar bieniu commented on May 23, 2024

Thanks for your effort. You can count on me for testing. Unfortunately, I can't help with js because I don't know it.

from bom-weather-card.

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024

I can't help with js because I don't know it.

me either lol!! But stay tuned..

from bom-weather-card.

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024

Can you try pulling the js file from master (in HACS set to master) and test if the visibility shows the correct number format - that is the only one I have tried so far.
Please let me know if this works for you

from bom-weather-card.

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024

I'm 100% sure it works if I edit in the locale to the js however not sure if it will pick it up from the browser or if I have to create a variable to parse it to the js. I hopefully won't have to do that!

from bom-weather-card.

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024

Docs in www seem to say we should be golden..
If this parameter is not provided, the toLocaleString() method will use the host environment's current locale.

It will revert back when it auto refreshes in around 30-60 seconds but I can totally fix that. I just don't want to screw around with more code till I know it will work. Then I will fix every other place it might occur as well....

from bom-weather-card.

bieniu avatar bieniu commented on May 23, 2024

It works for visibility but not for humidity. Both values in states use . as decimal separator

image

image
image

from bom-weather-card.

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024

Yeah like I said I was only trying to prove I worked it out and only did it for visibility! (After 30-60 seconds it will revert too) Now I know I worked it out I will roll it out for humidity etc as well. Stay tuned..

from bom-weather-card.

bieniu avatar bieniu commented on May 23, 2024

OK, so we have proof that your method works 👍

from bom-weather-card.

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024

ok I did visibility, humidity, pressure, temperature (in case you display decimals)
Please confirm it's working for you. The 30 second refresh is also resolved now (I hope) too...
Let me know and I'll draft a new release.....

from bom-weather-card.

bieniu avatar bieniu commented on May 23, 2024

Everything seems to be working well 👍

image

Thanks for your great work.

from bom-weather-card.

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024

Excellent. My pressure has a comma in it now... I wonder why yours doesn't?

from bom-weather-card.

bieniu avatar bieniu commented on May 23, 2024

Because the state has no decimal numbers

image

from bom-weather-card.

bieniu avatar bieniu commented on May 23, 2024

No, the reason has to be different, I used an entity with decimal numbers and the card shows a rounded value

image

image

from bom-weather-card.

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024

Interesting. My attributes are same as yours and mine is rounded to zero decimals as well but I get a comma as the thousands separator. Has to be something locale related.. I don't see why else it would do it. Is it convention there to only show a thousands sep if there is more than one digit before? (So >9999)? I dunno....

from bom-weather-card.

bieniu avatar bieniu commented on May 23, 2024

I added show_decimals: true to the card configuration and pressure still hasn't decimals numbers 😊

image

from bom-weather-card.

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024

Ok I wonder if it's a cache issue... In chrome can you open dev-tools (F12) and right click refresh and select Empty Cache and Hard Reload? Although I get the humidity changed ..... grasping straws..

from bom-weather-card.

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024

Also.... thanks for proving I made it work for Temperature as well..

from bom-weather-card.

bieniu avatar bieniu commented on May 23, 2024

I always reload the page without the cache when changing the card via SHIFT+F5 (Opera), via CTRL+R from dev tools effect is the same.

from bom-weather-card.

bieniu avatar bieniu commented on May 23, 2024

Precip intensity still uses . as decimal separator.
entity_pop_intensity: sensor.dom_precipitation

image

image

from bom-weather-card.

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024

ok I fixed intensity. Published 0.85a as a pre release. Please test and let me know.

from bom-weather-card.

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024

also can you give me your language/locality code so I can see if I can see whats up with the pressure. (mine is en-AU so it's language-region). With chrome the only way to do a full clear cache and hard reload is using the method I describe - there is no keyboard shortcut. Also maybe can you try chrome or another browser if you have it? I'm just perplexed!

from bom-weather-card.

bieniu avatar bieniu commented on May 23, 2024

also can you give me your language/locality code

pl-PL

With chrome the only way to do a full clear cache and hard reload is using the method I describe

I'm using Opera 72 on Windows/Debian/Android. I also tested on Edge.

With 0.85a pop intensity uses , as decimal separator but only for 30-40 seconds and than . comes back. The same behavior regardless of the browser used.

from bom-weather-card.

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024

Can you try 0.85b to fix refresh and let me know please?

from bom-weather-card.

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024

And I didn't update to 0.85b in the console so it will still say a instead of b. Grrrrrr

from bom-weather-card.

bieniu avatar bieniu commented on May 23, 2024

Refresh is fixed, I have , all the time.

from bom-weather-card.

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024

Well that's good! I'm going to check if I missed anything else tomorrow and I'll make a new release. Will also hard-code for your locale and see what I sss in my browser as I don't understand why that is not giving the expected result.

from bom-weather-card.

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024

Except for pressure I assume....

Also so you know this has nothing to do with the HA PR you referenced.. this is purely js using the configured locale on your computer..

from bom-weather-card.

bieniu avatar bieniu commented on May 23, 2024

It seems that the thousands separator is not used for pl-PL

image

image

And here we have value rounding https://github.com/DavidFW1960/bom-weather-card/blob/master/bom-weather-card.js#L441

IMO, everything is fine now, at least for pl-PL.

from bom-weather-card.

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024

I'm going to hard code pl-PL today and see what it does here...

from bom-weather-card.

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024

You can keep your weather too BTW lol

from bom-weather-card.

DavidFW1960 avatar DavidFW1960 commented on May 23, 2024

Can confirm the pl-PL doesn't show the thousands separator as you said so I agree all is well with this now. I don't think I missed anything else and I just bumped to version 0.85c and released.
Thanks for the suggestion and assistance in debugging.

from bom-weather-card.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.