Bump brother library to version 0.1.15 (#39226)
parent
067efc7805
commit
2568932c1c
homeassistant/components/brother
tests/components/brother
|
@ -1,5 +1,5 @@
|
|||
"""Constants for Brother integration."""
|
||||
from homeassistant.const import TIME_DAYS, UNIT_PERCENTAGE
|
||||
from homeassistant.const import UNIT_PERCENTAGE
|
||||
|
||||
ATTR_BELT_UNIT_REMAINING_LIFE = "belt_unit_remaining_life"
|
||||
ATTR_BLACK_DRUM_COUNTER = "black_drum_counter"
|
||||
|
@ -162,9 +162,5 @@ SENSOR_TYPES = {
|
|||
ATTR_LABEL: ATTR_YELLOW_INK_REMAINING.replace("_", " ").title(),
|
||||
ATTR_UNIT: UNIT_PERCENTAGE,
|
||||
},
|
||||
ATTR_UPTIME: {
|
||||
ATTR_ICON: "mdi:timer-outline",
|
||||
ATTR_LABEL: ATTR_UPTIME.title(),
|
||||
ATTR_UNIT: TIME_DAYS,
|
||||
},
|
||||
ATTR_UPTIME: {ATTR_ICON: None, ATTR_LABEL: ATTR_UPTIME.title(), ATTR_UNIT: None},
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"name": "Brother Printer",
|
||||
"documentation": "https://www.home-assistant.io/integrations/brother",
|
||||
"codeowners": ["@bieniu"],
|
||||
"requirements": ["brother==0.1.14"],
|
||||
"requirements": ["brother==0.1.15"],
|
||||
"zeroconf": ["_printer._tcp.local."],
|
||||
"config_flow": true,
|
||||
"quality_scale": "platinum"
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
"""Support for the Brother service."""
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
from homeassistant.const import DEVICE_CLASS_TIMESTAMP
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
from .const import (
|
||||
ATTR_BLACK_DRUM_COUNTER,
|
||||
|
@ -20,6 +23,7 @@ from .const import (
|
|||
ATTR_MAGENTA_DRUM_REMAINING_PAGES,
|
||||
ATTR_MANUFACTURER,
|
||||
ATTR_UNIT,
|
||||
ATTR_UPTIME,
|
||||
ATTR_YELLOW_DRUM_COUNTER,
|
||||
ATTR_YELLOW_DRUM_REMAINING_LIFE,
|
||||
ATTR_YELLOW_DRUM_REMAINING_PAGES,
|
||||
|
@ -76,8 +80,18 @@ class BrotherPrinterSensor(Entity):
|
|||
@property
|
||||
def state(self):
|
||||
"""Return the state."""
|
||||
if self.kind == ATTR_UPTIME:
|
||||
uptime = utcnow() - timedelta(seconds=self.coordinator.data.get(self.kind))
|
||||
return uptime.replace(microsecond=0).isoformat()
|
||||
return self.coordinator.data.get(self.kind)
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
"""Return the class of this sensor."""
|
||||
if self.kind == ATTR_UPTIME:
|
||||
return DEVICE_CLASS_TIMESTAMP
|
||||
return None
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
|
|
|
@ -384,7 +384,7 @@ bravia-tv==1.0.6
|
|||
broadlink==0.14.1
|
||||
|
||||
# homeassistant.components.brother
|
||||
brother==0.1.14
|
||||
brother==0.1.15
|
||||
|
||||
# homeassistant.components.brottsplatskartan
|
||||
brottsplatskartan==0.0.1
|
||||
|
|
|
@ -205,7 +205,7 @@ bravia-tv==1.0.6
|
|||
broadlink==0.14.1
|
||||
|
||||
# homeassistant.components.brother
|
||||
brother==0.1.14
|
||||
brother==0.1.15
|
||||
|
||||
# homeassistant.components.bsblan
|
||||
bsblan==0.3.7
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
"""Test sensor of Brother integration."""
|
||||
from datetime import timedelta
|
||||
from datetime import datetime, timedelta
|
||||
import json
|
||||
|
||||
from homeassistant.components.brother.const import UNIT_PAGES
|
||||
from homeassistant.const import (
|
||||
ATTR_DEVICE_CLASS,
|
||||
ATTR_ENTITY_ID,
|
||||
ATTR_ICON,
|
||||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
DEVICE_CLASS_TIMESTAMP,
|
||||
STATE_UNAVAILABLE,
|
||||
TIME_DAYS,
|
||||
UNIT_PERCENTAGE,
|
||||
)
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util.dt import utcnow
|
||||
from homeassistant.util.dt import UTC, utcnow
|
||||
|
||||
from tests.async_mock import patch
|
||||
from tests.common import async_fire_time_changed, load_fixture
|
||||
|
@ -24,7 +25,12 @@ ATTR_COUNTER = "counter"
|
|||
|
||||
async def test_sensors(hass):
|
||||
"""Test states of the sensors."""
|
||||
await init_integration(hass)
|
||||
test_time = datetime(2019, 11, 11, 9, 10, 32, tzinfo=UTC)
|
||||
with patch(
|
||||
"homeassistant.components.brother.sensor.utcnow", return_value=test_time
|
||||
):
|
||||
await init_integration(hass)
|
||||
|
||||
registry = await hass.helpers.entity_registry.async_get_registry()
|
||||
|
||||
state = hass.states.get("sensor.hl_l2340dw_status")
|
||||
|
@ -208,9 +214,10 @@ async def test_sensors(hass):
|
|||
|
||||
state = hass.states.get("sensor.hl_l2340dw_uptime")
|
||||
assert state
|
||||
assert state.attributes.get(ATTR_ICON) == "mdi:timer-outline"
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == TIME_DAYS
|
||||
assert state.state == "48"
|
||||
assert state.attributes.get(ATTR_ICON) is None
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == DEVICE_CLASS_TIMESTAMP
|
||||
assert state.state == "2019-09-24T12:14:56+00:00"
|
||||
|
||||
entry = registry.async_get("sensor.hl_l2340dw_uptime")
|
||||
assert entry
|
||||
|
|
Loading…
Reference in New Issue