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

[BUG] Custom "Command" type doesn't allow negative values #87

Closed
puterboy opened this issue Dec 21, 2022 · 4 comments
Closed

[BUG] Custom "Command" type doesn't allow negative values #87

puterboy opened this issue Dec 21, 2022 · 4 comments
Labels
fixed next Hopefully fixed in next

Comments

@puterboy
Copy link

I am using TopTemp to display the outside temperature which in the Northeast U.S. is now negative in Celsius.
This causes an error since it seems that command is expected to be a positive number.
There are other sensors which could presumably give a negative number too.

@LazeMSS
Copy link
Owner

LazeMSS commented Dec 21, 2022

Strange - hmmm will need to test

LazeMSS added a commit that referenced this issue Dec 21, 2022
Fixed problem with color picker #75
Allow negative input numbers #87
Set timeout handling on custom commands #88
@LazeMSS LazeMSS added the fixed next Hopefully fixed in next label Dec 22, 2022
LazeMSS added a commit that referenced this issue Dec 22, 2022
- Fixes for spelling: #86
- Fixed problem with color picker #75
- Allow negative input numbers #87
- Set timeout handling on custom commands #88
- Improved hide when printer is not connected #80
@LazeMSS LazeMSS mentioned this issue Dec 22, 2022
@LazeMSS
Copy link
Owner

LazeMSS commented Dec 22, 2022

@LazeMSS LazeMSS closed this as completed Dec 22, 2022
@puterboy
Copy link
Author

I think there is still a bug here. The 'test' now works (per your code fix) but it still won't display a negative number -- it just gives a spinning wheel...

@puterboy
Copy link
Author

OK - I found the problem.
Try this fix:

+++ __init__.py 2022-12-23 13:42:35.678604481 -0500
@@ -729,7 +729,7 @@
     def handleCustomData(self,indx,out,time):
         self.debugOut("Got custom data: " + str(out))
         # Check
-        if isinstance(out,(float, int)) or str(out).replace('.','',1).isdigit():
+        if isinstance(out,(float, int)) or str(out).lstrip('-').replace('.','',1).isdigit():
             resultData = [time,float(out)]
             if indx not in self.customHistory:
                 self.customHistory[indx] = []

Only limitation here is that '--2.3' (or any number of initial dashes) would be recognized as a number.
If you want to eliminate that case you would need to either add more logic or use 're' for regex test.

@LazeMSS LazeMSS reopened this Dec 25, 2022
@LazeMSS LazeMSS closed this as completed Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed next Hopefully fixed in next
Projects
None yet
Development

No branches or pull requests

2 participants