cmroche / OctoPrint-HomeAssistant

Home Assistant plugin for OctoPrint, enabling MQTT discovery of you device and sensors
110 stars 18 forks source link

Removing state_class from non-numeric sensors #112

Closed thejeffreystone closed 1 year ago

thejeffreystone commented 1 year ago

Setting state_class and or unit_of_measurement on non-numeric sensors causes an error in Home Assistant.

Removed to keep the homeassistant log from filling up with errors that look like:

ValueError: Sensor sensor.octoprint_approximate_completion_time has device class 'None', state class 'measurement' unit 'None' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'Jul 31, 19:53:59' (<class 'str'>)

ValueError: Sensor sensor.octoprint_print_time_left has device class 'None', state class 'measurement' unit 'None' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: '0:09:01' (<class 'str'>)

ValueError: Sensor sensor.octoprint_print_time has device class 'None', state class 'measurement' unit 'None' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: '9:10:59' (<class 'str'>)

mreditor97 commented 1 year ago

This has been patched in #108

Just waiting for it to be merged into the next update.

cmroche commented 1 year ago

Thanks for the contribution @thejeffreystone , as mentioned this appears to be already solved now and will be release soon. Please reopen the MR with additional changes, and rebased on latest master if there is anything else you would like me to consider.

Cheers.