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
12 changes: 2 additions & 10 deletions homeassistant/components/fritzbox/sensor.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
"""Support for AVM FRITZ!SmartHome temperature sensor only devices."""
from __future__ import annotations

from datetime import datetime

from pyfritzhome import FritzhomeDevice

from homeassistant.components.sensor import (
ATTR_STATE_CLASS,
STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL_INCREASING,
SensorEntity,
)
from homeassistant.config_entries import ConfigEntry
Expand All @@ -28,7 +27,6 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from homeassistant.util.dt import utc_from_timestamp

from . import FritzBoxEntity
from .const import (
Expand Down Expand Up @@ -99,7 +97,7 @@ async def async_setup_entry(
ATTR_ENTITY_ID: f"{device.ain}_total_energy",
ATTR_UNIT_OF_MEASUREMENT: ENERGY_KILO_WATT_HOUR,
ATTR_DEVICE_CLASS: DEVICE_CLASS_ENERGY,
ATTR_STATE_CLASS: STATE_CLASS_MEASUREMENT,
ATTR_STATE_CLASS: STATE_CLASS_TOTAL_INCREASING,
},
coordinator,
ain,
Expand Down Expand Up @@ -153,12 +151,6 @@ def native_value(self) -> float | None:
return energy / 1000 # type: ignore [no-any-return]
return 0.0

@property
def last_reset(self) -> datetime:
"""Return the time when the sensor was last reset, if any."""
# device does not provide timestamp of initialization
return utc_from_timestamp(0)


class FritzBoxTempSensor(FritzBoxSensor):
"""The entity class for FRITZ!SmartHome temperature sensors."""
Expand Down
5 changes: 2 additions & 3 deletions tests/components/fritzbox/test_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
DOMAIN as FB_DOMAIN,
)
from homeassistant.components.sensor import (
ATTR_LAST_RESET,
ATTR_STATE_CLASS,
DOMAIN as SENSOR_DOMAIN,
STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL_INCREASING,
)
from homeassistant.components.switch import DOMAIN
from homeassistant.const import (
Expand Down Expand Up @@ -73,10 +73,9 @@ async def test_setup(hass: HomeAssistant, fritz: Mock):
state = hass.states.get(f"{SENSOR_DOMAIN}.{CONF_FAKE_NAME}_total_energy")
assert state
assert state.state == "1.234"
assert state.attributes[ATTR_LAST_RESET] == "1970-01-01T00:00:00+00:00"
assert state.attributes[ATTR_FRIENDLY_NAME] == f"{CONF_FAKE_NAME} Total Energy"
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == ENERGY_KILO_WATT_HOUR
assert state.attributes[ATTR_STATE_CLASS] == STATE_CLASS_MEASUREMENT
assert state.attributes[ATTR_STATE_CLASS] == STATE_CLASS_TOTAL_INCREASING


async def test_turn_on(hass: HomeAssistant, fritz: Mock):
Expand Down