Bump `brother` library to version 4.0.0 (#111157)
* Bump library * Update code to the new library version * Improve diagnostics * Fix tests --------- Co-authored-by: Maciej Bieniek <478555+bieniu@users.noreply.github.com>pull/111034/head
parent
3be83bf2f5
commit
bccd9bd21f
|
@ -22,6 +22,8 @@ async def async_get_config_entry_diagnostics(
|
|||
diagnostics_data = {
|
||||
"info": dict(config_entry.data),
|
||||
"data": asdict(coordinator.data),
|
||||
"model": coordinator.brother.model,
|
||||
"firmware": coordinator.brother.firmware,
|
||||
}
|
||||
|
||||
return diagnostics_data
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
"iot_class": "local_polling",
|
||||
"loggers": ["brother", "pyasn1", "pysmi", "pysnmp"],
|
||||
"quality_scale": "platinum",
|
||||
"requirements": ["brother==3.0.0"],
|
||||
"requirements": ["brother==4.0.0"],
|
||||
"zeroconf": [
|
||||
{
|
||||
"type": "_printer._tcp.local.",
|
||||
|
|
|
@ -16,10 +16,10 @@ from homeassistant.components.sensor import (
|
|||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST, PERCENTAGE, EntityCategory
|
||||
from homeassistant.const import PERCENTAGE, EntityCategory
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import StateType
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
@ -332,11 +332,11 @@ async def async_setup_entry(
|
|||
# Due to the change of the attribute name of one sensor, it is necessary to migrate
|
||||
# the unique_id to the new one.
|
||||
entity_registry = er.async_get(hass)
|
||||
old_unique_id = f"{coordinator.data.serial.lower()}_b/w_counter"
|
||||
old_unique_id = f"{coordinator.brother.serial.lower()}_b/w_counter"
|
||||
if entity_id := entity_registry.async_get_entity_id(
|
||||
PLATFORM, DOMAIN, old_unique_id
|
||||
):
|
||||
new_unique_id = f"{coordinator.data.serial.lower()}_bw_counter"
|
||||
new_unique_id = f"{coordinator.brother.serial.lower()}_bw_counter"
|
||||
_LOGGER.debug(
|
||||
"Migrating entity %s from old unique ID '%s' to new unique ID '%s'",
|
||||
entity_id,
|
||||
|
@ -347,19 +347,9 @@ async def async_setup_entry(
|
|||
|
||||
sensors = []
|
||||
|
||||
device_info = DeviceInfo(
|
||||
configuration_url=f"http://{entry.data[CONF_HOST]}/",
|
||||
identifiers={(DOMAIN, coordinator.data.serial)},
|
||||
serial_number=coordinator.data.serial,
|
||||
manufacturer="Brother",
|
||||
model=coordinator.data.model,
|
||||
name=coordinator.data.model,
|
||||
sw_version=coordinator.data.firmware,
|
||||
)
|
||||
|
||||
for description in SENSOR_TYPES:
|
||||
if description.value(coordinator.data) is not None:
|
||||
sensors.append(BrotherPrinterSensor(coordinator, description, device_info))
|
||||
sensors.append(BrotherPrinterSensor(coordinator, description))
|
||||
async_add_entities(sensors, False)
|
||||
|
||||
|
||||
|
@ -375,13 +365,21 @@ class BrotherPrinterSensor(
|
|||
self,
|
||||
coordinator: BrotherDataUpdateCoordinator,
|
||||
description: BrotherSensorEntityDescription,
|
||||
device_info: DeviceInfo,
|
||||
) -> None:
|
||||
"""Initialize."""
|
||||
super().__init__(coordinator)
|
||||
self._attr_device_info = device_info
|
||||
self._attr_device_info = DeviceInfo(
|
||||
configuration_url=f"http://{coordinator.brother.host}/",
|
||||
identifiers={(DOMAIN, coordinator.brother.serial)},
|
||||
connections={(CONNECTION_NETWORK_MAC, coordinator.brother.mac)},
|
||||
serial_number=coordinator.brother.serial,
|
||||
manufacturer="Brother",
|
||||
model=coordinator.brother.model,
|
||||
name=coordinator.brother.model,
|
||||
sw_version=coordinator.brother.firmware,
|
||||
)
|
||||
self._attr_native_value = description.value(coordinator.data)
|
||||
self._attr_unique_id = f"{coordinator.data.serial.lower()}_{description.key}"
|
||||
self._attr_unique_id = f"{coordinator.brother.serial.lower()}_{description.key}"
|
||||
self.entity_description = description
|
||||
|
||||
@callback
|
||||
|
|
|
@ -606,7 +606,7 @@ bring-api==0.4.1
|
|||
broadlink==0.18.3
|
||||
|
||||
# homeassistant.components.brother
|
||||
brother==3.0.0
|
||||
brother==4.0.0
|
||||
|
||||
# homeassistant.components.brottsplatskartan
|
||||
brottsplatskartan==1.0.5
|
||||
|
|
|
@ -514,7 +514,7 @@ bring-api==0.4.1
|
|||
broadlink==0.18.3
|
||||
|
||||
# homeassistant.components.brother
|
||||
brother==3.0.0
|
||||
brother==4.0.0
|
||||
|
||||
# homeassistant.components.brottsplatskartan
|
||||
brottsplatskartan==1.0.5
|
||||
|
|
|
@ -72,5 +72,6 @@
|
|||
],
|
||||
"1.3.6.1.4.1.2435.2.3.9.4.2.1.5.5.1.0": "0123456789",
|
||||
"1.3.6.1.4.1.2435.2.3.9.4.2.1.5.4.5.2.0": "WAITING ",
|
||||
"1.3.6.1.2.1.43.7.1.1.4.1.1": "2004"
|
||||
"1.3.6.1.2.1.43.7.1.1.4.1.1": "2004",
|
||||
"1.3.6.1.2.1.2.2.1.6.1": "aa:bb:cc:dd:ee:ff"
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
'drum_remaining_pages': 11014,
|
||||
'drum_status': 1,
|
||||
'duplex_unit_pages_counter': 538,
|
||||
'firmware': '1.17',
|
||||
'fuser_remaining_life': 97,
|
||||
'fuser_unit_remaining_pages': None,
|
||||
'image_counter': None,
|
||||
|
@ -47,13 +46,11 @@
|
|||
'magenta_toner': 10,
|
||||
'magenta_toner_remaining': 8,
|
||||
'magenta_toner_status': 2,
|
||||
'model': 'HL-L2340DW',
|
||||
'page_counter': 986,
|
||||
'pf_kit_1_remaining_life': 98,
|
||||
'pf_kit_1_remaining_pages': 48741,
|
||||
'pf_kit_mp_remaining_life': None,
|
||||
'pf_kit_mp_remaining_pages': None,
|
||||
'serial': '0123456789',
|
||||
'status': 'waiting',
|
||||
'uptime': '2019-09-24T12:14:56+00:00',
|
||||
'yellow_counter': None,
|
||||
|
@ -67,9 +64,11 @@
|
|||
'yellow_toner_remaining': 2,
|
||||
'yellow_toner_status': 2,
|
||||
}),
|
||||
'firmware': '1.17',
|
||||
'info': dict({
|
||||
'host': 'localhost',
|
||||
'type': 'laser',
|
||||
}),
|
||||
'model': 'HL-L2340DW',
|
||||
})
|
||||
# ---
|
||||
|
|
Loading…
Reference in New Issue