mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use percentage constant as unit in LaMetric brightness (#80162)
This commit is contained in:
parent
e9e3fb1cc8
commit
b28ad1282a
@ -9,6 +9,7 @@ from demetriek import Device, LaMetricDevice
|
||||
|
||||
from homeassistant.components.number import NumberEntity, NumberEntityDescription
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import PERCENTAGE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
@ -43,7 +44,7 @@ NUMBERS = [
|
||||
native_step=1,
|
||||
native_min_value=0,
|
||||
native_max_value=100,
|
||||
native_unit_of_measurement="%",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
value_fn=lambda device: device.display.brightness,
|
||||
set_value_fn=lambda device, bri: device.display(brightness=int(bri)),
|
||||
),
|
||||
|
@ -19,6 +19,7 @@ from homeassistant.const import (
|
||||
ATTR_FRIENDLY_NAME,
|
||||
ATTR_ICON,
|
||||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
PERCENTAGE,
|
||||
STATE_UNAVAILABLE,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -46,7 +47,7 @@ async def test_brightness(
|
||||
assert state.attributes.get(ATTR_MAX) == 100
|
||||
assert state.attributes.get(ATTR_MIN) == 0
|
||||
assert state.attributes.get(ATTR_STEP) == 1
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "%"
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
||||
assert state.state == "100"
|
||||
|
||||
entry = entity_registry.async_get(state.entity_id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user