From 9463c84603a9e7310b98dd9b9727f9ebd1be14b0 Mon Sep 17 00:00:00 2001 From: MartinHjelmare Date: Tue, 8 Dec 2015 02:47:15 +0100 Subject: [PATCH] Clean up --- homeassistant/components/sensor/mysensors.py | 8 ++--- homeassistant/components/switch/mysensors.py | 36 +++----------------- 2 files changed, 9 insertions(+), 35 deletions(-) diff --git a/homeassistant/components/sensor/mysensors.py b/homeassistant/components/sensor/mysensors.py index f1ce4f38271..9c4d3d3fcc4 100644 --- a/homeassistant/components/sensor/mysensors.py +++ b/homeassistant/components/sensor/mysensors.py @@ -62,14 +62,14 @@ class MySensorsSensor(Entity): port (str): Gateway port. node_id (str): Id of node. child_id (str): Id of child. - name (str): Sketch name. + name (str): Entity name. value_type (str): Value type of child. Value is entity state. Attributes: port (str): Gateway port. node_id (str): Id of node. child_id (str): Id of child. - _name (str): Sketch name. + _name (str): Entity name. value_type (str): Value type of child. Value is entity state. battery_level (int): Node battery level. _values (dict): Child values. Non state values set as state attributes. @@ -83,7 +83,7 @@ class MySensorsSensor(Entity): self._values = {} def as_dict(self): - """Return a dict representation of this Entity.""" + """Return a dict representation of this entity.""" return { 'port': self.port, 'name': self._name, @@ -101,7 +101,7 @@ class MySensorsSensor(Entity): @property def name(self): - """The name of this sensor.""" + """The name of this entity.""" return self._name @property diff --git a/homeassistant/components/switch/mysensors.py b/homeassistant/components/switch/mysensors.py index 541c305fafa..a2557900141 100644 --- a/homeassistant/components/switch/mysensors.py +++ b/homeassistant/components/switch/mysensors.py @@ -12,7 +12,6 @@ from homeassistant.components.switch import SwitchDevice from homeassistant.const import ( ATTR_BATTERY_LEVEL, - TEMP_CELCIUS, TEMP_FAHRENHEIT, STATE_ON, STATE_OFF) import homeassistant.components.mysensors as mysensors @@ -62,14 +61,14 @@ class MySensorsSwitch(SwitchDevice): port (str): Gateway port. node_id (str): Id of node. child_id (str): Id of child. - name (str): Sketch name. + name (str): Entity name. value_type (str): Value type of child. Value is entity state. Attributes: port (str): Gateway port. node_id (str): Id of node. child_id (str): Id of child. - _name (str): Sketch name. + _name (str): Entity name. value_type (str): Value type of child. Value is entity state. battery_level (int): Node battery level. _values (dict): Child values. Non state values set as state attributes. @@ -83,7 +82,7 @@ class MySensorsSwitch(SwitchDevice): self._values = {} def as_dict(self): - """Return a dict representation of this Entity.""" + """Return a dict representation of this entity.""" return { 'port': self.port, 'name': self._name, @@ -101,34 +100,9 @@ class MySensorsSwitch(SwitchDevice): @property def name(self): - """The name of this sensor.""" + """The name of this entity.""" return self._name - @property - def unit_of_measurement(self): - """Unit of measurement of this entity.""" - # pylint:disable=too-many-return-statements - if self.value_type == mysensors.CONST.SetReq.V_TEMP: - return TEMP_CELCIUS if mysensors.IS_METRIC else TEMP_FAHRENHEIT - elif self.value_type == mysensors.CONST.SetReq.V_HUM or \ - self.value_type == mysensors.CONST.SetReq.V_DIMMER or \ - self.value_type == mysensors.CONST.SetReq.V_PERCENTAGE or \ - self.value_type == mysensors.CONST.SetReq.V_LIGHT_LEVEL: - return '%' - elif self.value_type == mysensors.CONST.SetReq.V_WATT: - return 'W' - elif self.value_type == mysensors.CONST.SetReq.V_KWH: - return 'kWh' - elif self.value_type == mysensors.CONST.SetReq.V_VOLTAGE: - return 'V' - elif self.value_type == mysensors.CONST.SetReq.V_CURRENT: - return 'A' - elif self.value_type == mysensors.CONST.SetReq.V_IMPEDANCE: - return 'ohm' - elif mysensors.CONST.SetReq.V_UNIT_PREFIX in self._values: - return self._values[mysensors.CONST.SetReq.V_UNIT_PREFIX] - return None - @property def device_state_attributes(self): """Return device specific state attributes.""" @@ -167,7 +141,7 @@ class MySensorsSwitch(SwitchDevice): self.update_ha_state() def turn_off(self): - """Turn the pin to low/off.""" + """Turn the switch off.""" mysensors.GATEWAYS[self.port].set_child_value( self.node_id, self.child_id, self.value_type, 0) self._values[self.value_type] = STATE_OFF