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

Precise Print Progress Percentage #109

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mreditor97
Copy link
Contributor

In this patch, I have added in a more precise display of the print progress percentage that is displayed within Home Assistant. The suggested_display_precision is set to 2 to allow for two decimal places on the percentage which is probably the sweet spot for accuracy.

Enjoy! :)

@mreditor97 mreditor97 marked this pull request as ready for review July 11, 2023 12:33
@cmroche cmroche self-requested a review August 6, 2023 19:58
@cmroche
Copy link
Owner

cmroche commented Aug 6, 2023

@mreditor97

I'm seeing this error when testing:

Traceback (most recent call last):
  File "/workspaces/core/homeassistant/components/sensor/__init__.py", line 593, in state
    numerical_value = float(value)  # type:ignore[arg-type]
                      ^^^^^^^^^^^^
ValueError: could not convert string to float: 'None'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/workspaces/core/homeassistant/components/mqtt/models.py", line 270, in process_write_state_requests
    entity.async_write_ha_state()
  File "/workspaces/core/homeassistant/helpers/entity.py", line 746, in async_write_ha_state
    self._async_write_ha_state()
  File "/workspaces/core/homeassistant/helpers/entity.py", line 808, in _async_write_ha_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/core/homeassistant/helpers/entity.py", line 752, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/workspaces/core/homeassistant/components/sensor/__init__.py", line 595, in state
    raise ValueError(
ValueError: Sensor sensor.octoprint_approximate_total_print_time has device class 'duration', state class 'None' unit 's' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'None' (<class 'str'>)

Copy link
Owner

@cmroche cmroche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments, errors in HA log.

@mreditor97
Copy link
Contributor Author

mreditor97 commented Aug 6, 2023

@cmroche I am thinking that is due to the broken patch from 3.6.5. I'll rebase it when I get chance then it should sort this problem...as that error was fixed in the #108 pull

@mreditor97
Copy link
Contributor Author

@cmroche I have rebased with the new master branch, so you shouldn't have any errors now. It should just display a slightly more precise print progress percentage.

@mreditor97 mreditor97 requested a review from cmroche November 15, 2023 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants