mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 03:37:07 +00:00
This commit is contained in:
parent
de5bd26050
commit
81ebdadcec
@ -12,10 +12,10 @@ from homeassistant.components.switch import (SwitchDevice, PLATFORM_SCHEMA)
|
|||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_USERNAME)
|
CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_USERNAME)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.const import TEMP_CELSIUS
|
from homeassistant.const import TEMP_CELSIUS, STATE_UNKNOWN
|
||||||
|
|
||||||
REQUIREMENTS = ['https://github.com/LinuxChristian/pyW215/archive/'
|
REQUIREMENTS = ['https://github.com/LinuxChristian/pyW215/archive/'
|
||||||
'v0.3.4.zip#pyW215==0.3.4']
|
'v0.3.5.zip#pyW215==0.3.5']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -72,11 +72,25 @@ class SmartPlugSwitch(SwitchDevice):
|
|||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
"""Return the state attributes of the device."""
|
"""Return the state attributes of the device."""
|
||||||
ui_temp = self.units.temperature(int(self.smartplug.temperature),
|
try:
|
||||||
TEMP_CELSIUS)
|
ui_temp = self.units.temperature(int(self.smartplug.temperature),
|
||||||
temperature = "{} {}".format(ui_temp, self.units.temperature_unit)
|
TEMP_CELSIUS)
|
||||||
current_consumption = "{} W".format(self.smartplug.current_consumption)
|
temperature = "%i %s" % \
|
||||||
total_consumption = "{} W".format(self.smartplug.total_consumption)
|
(ui_temp, self.units.temperature_unit)
|
||||||
|
except ValueError:
|
||||||
|
temperature = STATE_UNKNOWN
|
||||||
|
|
||||||
|
try:
|
||||||
|
current_consumption = "%.2f W" % \
|
||||||
|
float(self.smartplug.current_consumption)
|
||||||
|
except ValueError:
|
||||||
|
current_consumption = STATE_UNKNOWN
|
||||||
|
|
||||||
|
try:
|
||||||
|
total_consumption = "%.1f W" % \
|
||||||
|
float(self.smartplug.total_consumption)
|
||||||
|
except ValueError:
|
||||||
|
total_consumption = STATE_UNKNOWN
|
||||||
|
|
||||||
attrs = {
|
attrs = {
|
||||||
ATTR_CURRENT_CONSUMPTION: current_consumption,
|
ATTR_CURRENT_CONSUMPTION: current_consumption,
|
||||||
|
@ -137,7 +137,7 @@ hikvision==0.4
|
|||||||
https://github.com/Danielhiversen/flux_led/archive/0.6.zip#flux_led==0.6
|
https://github.com/Danielhiversen/flux_led/archive/0.6.zip#flux_led==0.6
|
||||||
|
|
||||||
# homeassistant.components.switch.dlink
|
# homeassistant.components.switch.dlink
|
||||||
https://github.com/LinuxChristian/pyW215/archive/v0.3.4.zip#pyW215==0.3.4
|
https://github.com/LinuxChristian/pyW215/archive/v0.3.5.zip#pyW215==0.3.5
|
||||||
|
|
||||||
# homeassistant.components.media_player.webostv
|
# homeassistant.components.media_player.webostv
|
||||||
# homeassistant.components.notify.webostv
|
# homeassistant.components.notify.webostv
|
||||||
|
Loading…
x
Reference in New Issue
Block a user