Skip to content
Closed
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
2 changes: 1 addition & 1 deletion homeassistant/components/fritzbox/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class FritzSensorEntityDescription(
device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT,
suitable=lambda device: device.has_powermeter, # type: ignore[no-any-return]
native_value=lambda device: device.power / device.voltage / 1000
native_value=lambda device: round(device.power / device.voltage / 1000, 4)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this is a "virtual" entity, as it is not a native value provided by the device or service (but calculated in HA). That is not allowed. This sensor should be removed.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be very helpful to see current in ampere out of the box from this device to improve user experience, because most other devices provide the same.
I don't see any convenient way to calculate current in HA. Is there an easy way by GUI to create a current entity by doing calculation including rounding? A rule would run into errors, if the device is renamed.
So why not provide calculated current out of the box?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this discussion should be continued in #78324 (comment)

if device.power and getattr(device, "voltage", None)
else 0.0,
),
Expand Down
2 changes: 1 addition & 1 deletion tests/components/fritzbox/test_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async def test_setup(hass: HomeAssistant, fritz: Mock):
],
[
f"{SENSOR_DOMAIN}.{CONF_FAKE_NAME}_electric_current",
"0.0246869565217391",
"0.0247",
f"{CONF_FAKE_NAME} Electric Current",
ELECTRIC_CURRENT_AMPERE,
SensorStateClass.MEASUREMENT,
Expand Down