Add battery sensor to fritzbox smart home devices (#49374)
This commit is contained in:
parent
6e911ba19f
commit
a050c8827b
3 changed files with 64 additions and 1 deletions
|
@ -64,6 +64,7 @@ class FritzDeviceSensorMock(Mock):
|
|||
"""Mock of a AVM Fritz!Box sensor device."""
|
||||
|
||||
ain = "fake_ain"
|
||||
battery_level = 23
|
||||
device_lock = "fake_locked_device"
|
||||
fw_version = "1.2.3"
|
||||
has_alarm = False
|
||||
|
|
|
@ -13,6 +13,7 @@ from homeassistant.components.sensor import DOMAIN
|
|||
from homeassistant.const import (
|
||||
ATTR_FRIENDLY_NAME,
|
||||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
)
|
||||
from homeassistant.helpers.typing import HomeAssistantType
|
||||
|
@ -47,6 +48,13 @@ async def test_setup(hass: HomeAssistantType, fritz: Mock):
|
|||
assert state.attributes[ATTR_STATE_LOCKED] == "fake_locked"
|
||||
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == TEMP_CELSIUS
|
||||
|
||||
state = hass.states.get(f"{ENTITY_ID}_battery")
|
||||
|
||||
assert state
|
||||
assert state.state == "23"
|
||||
assert state.attributes[ATTR_FRIENDLY_NAME] == "fake_name Battery"
|
||||
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == PERCENTAGE
|
||||
|
||||
|
||||
async def test_update(hass: HomeAssistantType, fritz: Mock):
|
||||
"""Test update with error."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue