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

Add duration device class for total print time and longest print sensors #344

Closed

Conversation

saintonotole
Copy link

This patch adds a device class to the Longest Print and Totals Print Time history sensors, similar to the rest of the existing time-related sensors.
The current implementation casts these sensors to plain text values, which makes it very difficult to try to build any automations on top of these values.
For example, I want to make a reminder every X hours of printing to do maintenance on the printer (lubricate the guides, check belt tension, check for debris in the extruder, and so on).
This could also be useful for people with print farms to more easily keep track of printer wear and tear and to more evenly distribute print jobs.

@marcolivierarsenault
Copy link
Owner

@saintonotole this is a great patch, can you adjust tests for it

@saintonotole
Copy link
Author

@marcolivierarsenault I've adjusted the tests to match the expected data

value_fn=lambda sensor: convert_time(
sensor.coordinator.data["history"]["job_totals"]["longest_print"]
),
value_fn=lambda sensor: sensor.coordinator.data["history"]["job_totals"][

Choose a reason for hiding this comment

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

For the failing test you probably need to round the value

@marcolivierarsenault
Copy link
Owner

inactive, re-open if needed

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