moved setting name to constructor

pull/52/head
jamespcole 2015-03-09 07:15:41 +11:00
parent a2f438c6ef
commit 7772d5af62
3 changed files with 12 additions and 9 deletions

View File

@ -125,13 +125,14 @@ class VeraLight(ToggleDevice):
def __init__(self, vera_device, extra_data=None):
self.vera_device = vera_device
self.extra_data = extra_data
if self.extra_data and self.extra_data.get('name'):
self._name = self.extra_data.get('name')
self._name = self.vera_device.name
@property
def name(self):
""" Get the mame of the light. """
if self.extra_data and self.extra_data.get('name'):
return self.extra_data.get('name')
return self.vera_device.name
return self._name
@property
def state_attributes(self):

View File

@ -125,6 +125,9 @@ class VeraSensor(Device):
def __init__(self, vera_device, extra_data=None):
self.vera_device = vera_device
self.extra_data = extra_data
if self.extra_data and self.extra_data.get('name'):
self._name = self.extra_data.get('name')
self._name = self.vera_device.name
def __str__(self):
return "%s %s %s" % (self.name, self.vera_device.deviceId, self.state)
@ -136,9 +139,7 @@ class VeraSensor(Device):
@property
def name(self):
""" Get the mame of the sensor. """
if self.extra_data and self.extra_data.get('name'):
return self.extra_data.get('name')
return self.vera_device.name
return self._name
@property
def state_attributes(self):

View File

@ -126,13 +126,14 @@ class VeraSwitch(ToggleDevice):
def __init__(self, vera_device, extra_data=None):
self.vera_device = vera_device
self.extra_data = extra_data
if self.extra_data and self.extra_data.get('name'):
self._name = self.extra_data.get('name')
self._name = self.vera_device.name
@property
def name(self):
""" Get the mame of the switch. """
if self.extra_data and self.extra_data.get('name'):
return self.extra_data.get('name')
return self.vera_device.name
return self._name
@property
def state_attributes(self):