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

Temperature displays as -0 instead of 0 when rounding is enabled #74

Closed
cloneofghosts opened this issue Jan 6, 2023 · 14 comments
Closed

Comments

@cloneofghosts
Copy link
Collaborator

I've noticed that when you have rounding selected and when the temperature is below freezing and close enough to zero to get rounded up to zero it displays as -0 instead of 0 as seen in the screenshot below.

image

@alexander0042
Copy link
Collaborator

That's pretty weird- it's just a "round(x)" statement in the code, so no idea why it would add in a negative sign. My best guess it's something intrinsic to Python, since other people seem to have encountered it before: https://stackoverflow.com/questions/11010683/how-to-have-negative-zero-always-formatted-as-positive-zero-in-a-python-string.

I'll throw a "+0" in there following the suggestion in that post in the next update, and hopefully that clears this up!

@cloneofghosts
Copy link
Collaborator Author

I've rain into this issue before when creating my own custom display for OpenWeatherMap for a website a while back. I ended up checking if the temperature is between -0.5 and 0 in which case I set the temperature to zero.

I found the code from the repo we were working in and this is how I solved the issue in JSP

<c:when test="${weather.weatherTemp gt -0.5 and weather.weatherTemp lt 0 }">
	<!-- To prevent -0 from showing as the current tempreature -->
	0&deg;C
</c:when>

@cloneofghosts
Copy link
Collaborator Author

It also seems that if the high temp is 0 it doesn't display it on the weather card. Not sure if that's a HA thing or if it's an issue with the integration.

image
image

@alexander0042
Copy link
Collaborator

I think it must be HA thing, since the values are calculated the same way on the integration end of things.

I've corrected this issue in the next integration release, so I'll leave this issue open until that goes out for reference.

@cloneofghosts
Copy link
Collaborator Author

The high temp missing must be an issue with the built in card. I've installed a custom one and it displays 0 as the high temp on the card itself.

@cloneofghosts
Copy link
Collaborator Author

I'm trying to setup Precipitation Probability in the weather card and I get this error and they all show as ---%

'entity_pop_1 attribute forecast[1].precipitation_probability not found

I'm guessing the integration does not have this setup as I had to add a sensor to show the probability for the current day forecast. Also if the next day is not forecasting any precipitation accumulation then I get a similar error and it shows ---mm.

Can you add in the precipitation probability and if there's no accumulation forecasted then set it to 0 to fix these issues?

@cloneofghosts
Copy link
Collaborator Author

@alexander0042 Any updates here? I haven't seen an update for the integration released and am wondering when that is supposed to release.

Also if the issue I mentioned in my last comment could get looked at and fixed that would be awesome. 🙂

@alexander0042
Copy link
Collaborator

Hi,

Thanks for tagging me with the reminder here! Since I've been working on the API side of things, this was moved to the back burner for a couple weeks, but haven't forgotten about it.

This is a larger question than I realized- I'm guessing you're using a manual weather card, and want precipitation probability as the "Secondary Info Attribute", using the card described here: https://www.home-assistant.io/dashboards/weather-forecast/? Are you defining it via yaml, or the UI somehow?

@cloneofghosts
Copy link
Collaborator Author

At first I was using the built in Weather Card but I have since switched to using the Platinum Weather Card.

So do I need to define that info attribute on somewhere on the built-in weather card for it to work or do I need to do something else? I'm pretty new to the HA stuff so if you could point me in the correct direction that would be great.

Any chance of looking at the precipitation accumulation issue as well? Just defaulting it to 0 would solve the issue that comes up from time to time.

@alexander0042
Copy link
Collaborator

I'm also far from an expert at HA, so we'll muddle through this together! I think I've worked out what your question is here- it works when I use it as a sensor, but it's not one of the "weather" attributes. I think this should be easy to add, since the data is already there, so testing it now.

@alexander0042
Copy link
Collaborator

Ok, got it in the weather entity, and corrected the lines issue. I'm a little bit worried that this might break a workflow somewhere, since the way Dark Sky was doing it was returning "None". However, I agree that the lines are weird, and I imagine it would be easier for people to program automation with a zero instead of missing, so I'm going to change it and see if anyone notices.

image

image

Let me know if you'd like any other parameters added to the weather entity. It's pretty light at the moment, and I can't think of why adding additional things in would hurt.

@cloneofghosts
Copy link
Collaborator Author

That is correct it wasn't part of the weather entity so it was giving a warning about it not existing but glad to see it was added. As long as the change from None to 0 is added in the changelog then it shouldn't be too much of an issue? Though people tend to not read the changelog so you could still get some issues popping up.

I can't think of anything else to be added to the weather entity since you can always create sensors as needed to fill in any missing gaps that the entity does not provide.

@alexander0042
Copy link
Collaborator

Ok, release (v1.1.0) is live! Thank you again for all your help with this, and we are hopefully good to close!

@cloneofghosts
Copy link
Collaborator Author

This is fixed. Thanks!

@github-actions github-actions bot locked and limited conversation to collaborators Jul 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants