Auto set friendly name in state attributes

This commit is contained in:
Paulus Schoutsen committed 2015-02-28 20:10:39 -08:00
1 parent 80ffe74af6
commit b38146bdef
5 files changed
+17 -30

No files matched your search

+1 -7
View File
@@ -1,7 +1,6 @@
""" Demo platform that has two fake switchces. """
from homeassistant.helpers import ToggleDevice
from homeassistant.const import (
STATE_ON, STATE_OFF, DEVICE_DEFAULT_NAME, ATTR_FRIENDLY_NAME)
from homeassistant.const import STATE_ON, STATE_OFF, DEVICE_DEFAULT_NAME
def get_devices(hass, config):
@@ -38,11 +37,6 @@ class DemoSwitch(ToggleDevice):
""" Returns the name of the device if any. """
return self._state
@property
def state_attributes(self):
""" Returns optional state attributes. """
return {ATTR_FRIENDLY_NAME: self._name}
@property
def is_on(self):
""" True if device is on. """
-4
View File
@@ -2,7 +2,6 @@
import logging
from homeassistant.helpers import ToggleDevice
from homeassistant.const import ATTR_FRIENDLY_NAME
from homeassistant.components.switch import (
ATTR_TODAY_MWH, ATTR_CURRENT_POWER_MWH)
@@ -75,12 +74,9 @@ class WemoSwitch(ToggleDevice):
cur_info = self.wemo.insight_params
return {
ATTR_FRIENDLY_NAME: self.wemo.name,
ATTR_CURRENT_POWER_MWH: cur_info['currentpower'],
ATTR_TODAY_MWH: cur_info['todaymw']
}
else:
return {ATTR_FRIENDLY_NAME: self.wemo.name}
@property
def is_on(self):