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>
pull/128654/head
Michael 2024-10-12 20:22:03 +02:00 committed by Franck Nijhof
parent 18d65d513e
commit ba4d081021
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
6 changed files with 8 additions and 6 deletions

View File

@ -8,6 +8,6 @@
"iot_class": "local_polling",
"loggers": ["deepmerge", "pyipp"],
"quality_scale": "platinum",
"requirements": ["pyipp==0.16.0"],
"requirements": ["pyipp==0.17.0"],
"zeroconf": ["_ipps._tcp.local.", "_ipp._tcp.local."]
}

View File

@ -4,7 +4,7 @@ from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass
from datetime import datetime, timedelta
from datetime import datetime
from typing import Any
from pyipp import Marker, Printer
@ -19,7 +19,6 @@ from homeassistant.const import ATTR_LOCATION, PERCENTAGE, EntityCategory
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType
from homeassistant.util.dt import utcnow
from . import IPPConfigEntry
from .const import (
@ -80,7 +79,7 @@ PRINTER_SENSORS: tuple[IPPSensorEntityDescription, ...] = (
device_class=SensorDeviceClass.TIMESTAMP,
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
value_fn=lambda printer: (utcnow() - timedelta(seconds=printer.info.uptime)),
value_fn=lambda printer: printer.booted_at,
),
)

View File

@ -1960,7 +1960,7 @@ pyintesishome==1.8.0
pyipma==3.0.7
# homeassistant.components.ipp
pyipp==0.16.0
pyipp==0.17.0
# homeassistant.components.iqvia
pyiqvia==2022.04.0

View File

@ -1574,7 +1574,7 @@ pyinsteon==1.6.3
pyipma==3.0.7
# homeassistant.components.ipp
pyipp==0.16.0
pyipp==0.17.0
# homeassistant.components.iqvia
pyiqvia==2022.04.0

View File

@ -2,6 +2,7 @@
# name: test_diagnostics
dict({
'data': dict({
'booted_at': '2019-11-11T09:10:02+00:00',
'info': dict({
'command_set': 'ESCPL2,BDC,D4,D4PX,ESCPR7,END4,GENEP,URF',
'location': None,

View File

@ -1,5 +1,6 @@
"""Tests for the diagnostics data provided by the Internet Printing Protocol (IPP) integration."""
import pytest
from syrupy import SnapshotAssertion
from homeassistant.core import HomeAssistant
@ -9,6 +10,7 @@ from tests.components.diagnostics import get_diagnostics_for_config_entry
from tests.typing import ClientSessionGenerator
@pytest.mark.freeze_time("2019-11-11 09:10:32+00:00")
async def test_diagnostics(
hass: HomeAssistant,
hass_client: ClientSessionGenerator,