1 """Support for D-Link Power Plug Switches."""
3 from __future__
import annotations
5 from datetime
import timedelta
13 from .
import DLinkConfigEntry
14 from .const
import ATTR_TOTAL_CONSUMPTION
15 from .entity
import DLinkEntity
26 entry: DLinkConfigEntry,
27 async_add_entities: AddEntitiesCallback,
29 """Set up the D-Link Power Plug switch."""
34 """Representation of a D-Link Smart Plug switch."""
40 """Return the state attributes of the device."""
42 temperature = self.
hasshass.config.units.temperature(
43 int(self.
datadata.temperature), UnitOfTemperature.CELSIUS
49 total_consumption =
float(self.
datadata.total_consumption)
51 total_consumption =
None
54 ATTR_TOTAL_CONSUMPTION: total_consumption,
55 ATTR_TEMPERATURE: temperature,
60 """Return true if switch is on."""
61 return self.
datadata.state ==
"ON"
64 """Turn the switch on."""
65 self.
datadata.smartplug.state =
"ON"
68 """Turn the switch off."""
69 self.
datadata.smartplug.state =
"OFF"
72 """Get the latest data from the smart plug and updates the states."""
77 """Return True if entity is available."""
78 return self.
datadata.available
None turn_off(self, **Any kwargs)
None turn_on(self, **Any kwargs)
dict[str, Any] extra_state_attributes(self)
None async_setup_entry(HomeAssistant hass, DLinkConfigEntry entry, AddEntitiesCallback async_add_entities)