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
5 changes: 0 additions & 5 deletions homeassistant/components/smartthings/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ def get_capabilities(capabilities: Sequence[str]) -> Sequence[str] | None:
Capability.air_conditioner_mode,
Capability.demand_response_load_control,
Capability.air_conditioner_fan_mode,
Capability.power_consumption_report,
Capability.relative_humidity_measurement,
Capability.switch,
Capability.temperature_measurement,
Expand Down Expand Up @@ -422,10 +421,6 @@ def extra_state_attributes(self):
"drlc_status_level",
"drlc_status_start",
"drlc_status_override",
"power_consumption_start",
"power_consumption_power",
"power_consumption_energy",
"power_consumption_end",
]
state_attributes = {}
for attribute in attributes:
Expand Down
24 changes: 20 additions & 4 deletions homeassistant/components/smartthings/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ async def async_setup_entry(
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Add binary sensors for a config entry."""
"""Add sensors for a config entry."""
broker = hass.data[DOMAIN][DATA_BROKERS][config_entry.entry_id]
entities: list[SensorEntity] = []
for device in broker.devices.values():
Expand Down Expand Up @@ -641,7 +641,7 @@ def __init__(

@property
def name(self) -> str:
"""Return the name of the binary sensor."""
"""Return the name of the sensor."""
return f"{self._device.label} {self._name}"

@property
Expand Down Expand Up @@ -681,7 +681,7 @@ def __init__(self, device, index):

@property
def name(self) -> str:
"""Return the name of the binary sensor."""
"""Return the name of the sensor."""
return f"{self._device.label} {THREE_AXIS_NAMES[self._index]}"

@property
Expand Down Expand Up @@ -716,7 +716,7 @@ def __init__(

@property
def name(self) -> str:
"""Return the name of the binary sensor."""
"""Return the name of the sensor."""
return f"{self._device.label} {self.report_name}"

@property
Expand Down Expand Up @@ -747,3 +747,19 @@ def native_unit_of_measurement(self):
if self.report_name == "power":
return POWER_WATT
return ENERGY_KILO_WATT_HOUR

@property
def extra_state_attributes(self):
"""Return specific state attributes."""
if self.report_name == "power":
attributes = [
"power_consumption_start",
"power_consumption_end",
]
state_attributes = {}
for attribute in attributes:
value = getattr(self._device.status, attribute)
if value is not None:
state_attributes[attribute] = value
return state_attributes
return None
11 changes: 0 additions & 11 deletions tests/components/smartthings/test_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ def air_conditioner_fixture(device_factory):
Capability.air_conditioner_mode,
Capability.demand_response_load_control,
Capability.air_conditioner_fan_mode,
Capability.power_consumption_report,
Capability.switch,
Capability.temperature_measurement,
Capability.thermostat_cooling_setpoint,
Expand Down Expand Up @@ -177,12 +176,6 @@ def air_conditioner_fixture(device_factory):
"high",
"turbo",
],
Attribute.power_consumption: {
"start": "2019-02-24T21:03:04Z",
"power": 0,
"energy": 500,
"end": "2019-02-26T02:05:55Z",
},
Attribute.switch: "on",
Attribute.cooling_setpoint: 23,
},
Expand Down Expand Up @@ -320,10 +313,6 @@ async def test_air_conditioner_entity_state(hass, air_conditioner):
assert state.attributes["drlc_status_level"] == -1
assert state.attributes["drlc_status_start"] == "1970-01-01T00:00:00Z"
assert state.attributes["drlc_status_override"] is False
assert state.attributes["power_consumption_start"] == "2019-02-24T21:03:04Z"
assert state.attributes["power_consumption_power"] == 0
assert state.attributes["power_consumption_energy"] == 500
assert state.attributes["power_consumption_end"] == "2019-02-26T02:05:55Z"


async def test_set_fan_mode(hass, thermostat, air_conditioner):
Expand Down
2 changes: 2 additions & 0 deletions tests/components/smartthings/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ async def test_power_consumption_sensor(hass, device_factory):
state = hass.states.get("sensor.refrigerator_power")
assert state
assert state.state == "109"
assert state.attributes["power_consumption_start"] == "2021-07-30T16:45:25Z"
assert state.attributes["power_consumption_end"] == "2021-07-30T16:58:33Z"
entry = entity_registry.async_get("sensor.refrigerator_power")
assert entry
assert entry.unique_id == f"{device.device_id}.power_meter"
Expand Down