Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions homeassistant/components/fritzbox/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,6 @@ def suitable_temperature(device: FritzhomeDevice) -> bool:
return device.has_temperature_sensor and not device.has_thermostat


def value_electric_current(device: FritzhomeDevice) -> float:
"""Return native value for electric current sensor."""
if (
isinstance(device.power, int)
and isinstance(device.voltage, int)
and device.voltage > 0
):
return round(device.power / device.voltage, 3)
return 0.0


def value_nextchange_preset(device: FritzhomeDevice) -> str:
"""Return native value for next scheduled preset sensor."""
if device.nextchange_temperature == device.eco_temperature:
Expand Down Expand Up @@ -153,7 +142,7 @@ def value_scheduled_preset(device: FritzhomeDevice) -> str:
device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT,
suitable=lambda device: device.has_powermeter, # type: ignore[no-any-return]
native_value=value_electric_current,
native_value=lambda device: round((device.current or 0.0) / 1000, 3),
Comment thread
frenck marked this conversation as resolved.
),
FritzSensorEntityDescription(
key="total_energy",
Expand Down
1 change: 1 addition & 0 deletions tests/components/fritzbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class FritzDeviceSwitchMock(FritzEntityBaseMock):
device_lock = "fake_locked_device"
energy = 1234
voltage = 230000
current = 25
fw_version = "1.2.3"
has_alarm = False
has_powermeter = True
Expand Down
18 changes: 0 additions & 18 deletions tests/components/fritzbox/test_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,3 @@ async def test_assume_device_unavailable(hass: HomeAssistant, fritz: Mock) -> No
state = hass.states.get(ENTITY_ID)
assert state
assert state.state == STATE_UNAVAILABLE


async def test_device_current_unavailable(hass: HomeAssistant, fritz: Mock) -> None:
"""Test current in case voltage and power are not available."""
device = FritzDeviceSwitchMock()
device.voltage = None
device.power = None
assert await setup_config_entry(
hass, MOCK_CONFIG[FB_DOMAIN][CONF_DEVICES][0], ENTITY_ID, device, fritz
)

state = hass.states.get(ENTITY_ID)
assert state
assert state.state == STATE_ON

state = hass.states.get(f"{SENSOR_DOMAIN}.{CONF_FAKE_NAME}_electric_current")
assert state
assert state.state == "0.0"