mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Downgrade OctoPrint printer disconnected errors (#63076)
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
cba752c1af
commit
d85d93d1a1
@ -225,7 +225,7 @@ class OctoprintDataUpdateCoordinator(DataUpdateCoordinator):
|
|||||||
printer = await self._octoprint.get_printer_info()
|
printer = await self._octoprint.get_printer_info()
|
||||||
except PrinterOffline:
|
except PrinterOffline:
|
||||||
if not self._printer_offline:
|
if not self._printer_offline:
|
||||||
_LOGGER.error("Unable to retrieve printer information: Printer offline")
|
_LOGGER.debug("Unable to retrieve printer information: Printer offline")
|
||||||
self._printer_offline = True
|
self._printer_offline = True
|
||||||
except ApiError as err:
|
except ApiError as err:
|
||||||
raise UpdateFailed(err) from err
|
raise UpdateFailed(err) from err
|
||||||
|
@ -62,7 +62,7 @@ async def async_setup_entry(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
_LOGGER.error("Printer appears to be offline, skipping temperature sensors")
|
_LOGGER.debug("Printer appears to be offline, skipping temperature sensors")
|
||||||
|
|
||||||
entities.append(OctoPrintStatusSensor(coordinator, device_id))
|
entities.append(OctoPrintStatusSensor(coordinator, device_id))
|
||||||
entities.append(OctoPrintJobPercentageSensor(coordinator, device_id))
|
entities.append(OctoPrintJobPercentageSensor(coordinator, device_id))
|
||||||
|
@ -144,3 +144,46 @@ async def test_sensors_paused(hass):
|
|||||||
assert state.name == "OctoPrint Estimated Finish Time"
|
assert state.name == "OctoPrint Estimated Finish Time"
|
||||||
entry = entity_registry.async_get("sensor.octoprint_estimated_finish_time")
|
entry = entity_registry.async_get("sensor.octoprint_estimated_finish_time")
|
||||||
assert entry.unique_id == "Estimated Finish Time-uuid"
|
assert entry.unique_id == "Estimated Finish Time-uuid"
|
||||||
|
|
||||||
|
|
||||||
|
async def test_sensors_printer_disconnected(hass):
|
||||||
|
"""Test the underlying sensors."""
|
||||||
|
job = {
|
||||||
|
"job": {},
|
||||||
|
"progress": {"completion": 50, "printTime": 600, "printTimeLeft": 6000},
|
||||||
|
"state": "Paused",
|
||||||
|
}
|
||||||
|
with patch(
|
||||||
|
"homeassistant.util.dt.utcnow", return_value=datetime(2020, 2, 20, 9, 10, 0)
|
||||||
|
):
|
||||||
|
await init_integration(hass, "sensor", printer=None, job=job)
|
||||||
|
|
||||||
|
entity_registry = er.async_get(hass)
|
||||||
|
|
||||||
|
state = hass.states.get("sensor.octoprint_job_percentage")
|
||||||
|
assert state is not None
|
||||||
|
assert state.state == "50"
|
||||||
|
assert state.name == "OctoPrint Job Percentage"
|
||||||
|
entry = entity_registry.async_get("sensor.octoprint_job_percentage")
|
||||||
|
assert entry.unique_id == "Job Percentage-uuid"
|
||||||
|
|
||||||
|
state = hass.states.get("sensor.octoprint_current_state")
|
||||||
|
assert state is not None
|
||||||
|
assert state.state == "unavailable"
|
||||||
|
assert state.name == "OctoPrint Current State"
|
||||||
|
entry = entity_registry.async_get("sensor.octoprint_current_state")
|
||||||
|
assert entry.unique_id == "Current State-uuid"
|
||||||
|
|
||||||
|
state = hass.states.get("sensor.octoprint_start_time")
|
||||||
|
assert state is not None
|
||||||
|
assert state.state == "unknown"
|
||||||
|
assert state.name == "OctoPrint Start Time"
|
||||||
|
entry = entity_registry.async_get("sensor.octoprint_start_time")
|
||||||
|
assert entry.unique_id == "Start Time-uuid"
|
||||||
|
|
||||||
|
state = hass.states.get("sensor.octoprint_estimated_finish_time")
|
||||||
|
assert state is not None
|
||||||
|
assert state.state == "unknown"
|
||||||
|
assert state.name == "OctoPrint Estimated Finish Time"
|
||||||
|
entry = entity_registry.async_get("sensor.octoprint_estimated_finish_time")
|
||||||
|
assert entry.unique_id == "Estimated Finish Time-uuid"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user