mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 16:27:08 +00:00
Fix printer uptime fluctuations in IPP (#127725)
* decrease uptime accuracy from seconds to minutes * adjust tests * calc uptime timestamp in coordinator * bump pyipp to 0.17.0 * revert changes, just use the new printer.booted_at property --------- Co-authored-by: Chris Talkington <chris@talkingtontech.com>
This commit is contained in:
parent
3112682923
commit
caf85fe61d
@ -8,6 +8,6 @@
|
|||||||
"iot_class": "local_polling",
|
"iot_class": "local_polling",
|
||||||
"loggers": ["deepmerge", "pyipp"],
|
"loggers": ["deepmerge", "pyipp"],
|
||||||
"quality_scale": "platinum",
|
"quality_scale": "platinum",
|
||||||
"requirements": ["pyipp==0.16.0"],
|
"requirements": ["pyipp==0.17.0"],
|
||||||
"zeroconf": ["_ipps._tcp.local.", "_ipp._tcp.local."]
|
"zeroconf": ["_ipps._tcp.local.", "_ipp._tcp.local."]
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from pyipp import Marker, Printer
|
from pyipp import Marker, Printer
|
||||||
@ -19,7 +19,6 @@ from homeassistant.const import ATTR_LOCATION, PERCENTAGE, EntityCategory
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
from homeassistant.util.dt import utcnow
|
|
||||||
|
|
||||||
from . import IPPConfigEntry
|
from . import IPPConfigEntry
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -80,7 +79,7 @@ PRINTER_SENSORS: tuple[IPPSensorEntityDescription, ...] = (
|
|||||||
device_class=SensorDeviceClass.TIMESTAMP,
|
device_class=SensorDeviceClass.TIMESTAMP,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
value_fn=lambda printer: (utcnow() - timedelta(seconds=printer.info.uptime)),
|
value_fn=lambda printer: printer.booted_at,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1966,7 +1966,7 @@ pyintesishome==1.8.0
|
|||||||
pyipma==3.0.7
|
pyipma==3.0.7
|
||||||
|
|
||||||
# homeassistant.components.ipp
|
# homeassistant.components.ipp
|
||||||
pyipp==0.16.0
|
pyipp==0.17.0
|
||||||
|
|
||||||
# homeassistant.components.iqvia
|
# homeassistant.components.iqvia
|
||||||
pyiqvia==2022.04.0
|
pyiqvia==2022.04.0
|
||||||
|
@ -1580,7 +1580,7 @@ pyinsteon==1.6.3
|
|||||||
pyipma==3.0.7
|
pyipma==3.0.7
|
||||||
|
|
||||||
# homeassistant.components.ipp
|
# homeassistant.components.ipp
|
||||||
pyipp==0.16.0
|
pyipp==0.17.0
|
||||||
|
|
||||||
# homeassistant.components.iqvia
|
# homeassistant.components.iqvia
|
||||||
pyiqvia==2022.04.0
|
pyiqvia==2022.04.0
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# name: test_diagnostics
|
# name: test_diagnostics
|
||||||
dict({
|
dict({
|
||||||
'data': dict({
|
'data': dict({
|
||||||
|
'booted_at': '2019-11-11T09:10:02+00:00',
|
||||||
'info': dict({
|
'info': dict({
|
||||||
'command_set': 'ESCPL2,BDC,D4,D4PX,ESCPR7,END4,GENEP,URF',
|
'command_set': 'ESCPL2,BDC,D4,D4PX,ESCPR7,END4,GENEP,URF',
|
||||||
'location': None,
|
'location': None,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
"""Tests for the diagnostics data provided by the Internet Printing Protocol (IPP) integration."""
|
"""Tests for the diagnostics data provided by the Internet Printing Protocol (IPP) integration."""
|
||||||
|
|
||||||
|
import pytest
|
||||||
from syrupy import SnapshotAssertion
|
from syrupy import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -9,6 +10,7 @@ from tests.components.diagnostics import get_diagnostics_for_config_entry
|
|||||||
from tests.typing import ClientSessionGenerator
|
from tests.typing import ClientSessionGenerator
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.freeze_time("2019-11-11 09:10:32+00:00")
|
||||||
async def test_diagnostics(
|
async def test_diagnostics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client: ClientSessionGenerator,
|
hass_client: ClientSessionGenerator,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user