diff --git a/.gitmodules b/.gitmodules index 174bba680f002d..4ecccece153bf8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,9 +16,6 @@ [submodule "homeassistant/external/nzbclients"] path = homeassistant/external/nzbclients url = https://github.com/jamespcole/home-assistant-nzb-clients.git -[submodule "homeassistant/external/pymysensors"] - path = homeassistant/external/pymysensors - url = https://github.com/theolind/pymysensors [submodule "homeassistant/components/frontend/www_static/home-assistant-polymer"] path = homeassistant/components/frontend/www_static/home-assistant-polymer url = https://github.com/balloob/home-assistant-polymer.git diff --git a/homeassistant/components/sensor/mysensors.py b/homeassistant/components/sensor/mysensors.py index 4f3c2610c5ab05..ad9649f9966b8c 100644 --- a/homeassistant/components/sensor/mysensors.py +++ b/homeassistant/components/sensor/mysensors.py @@ -21,9 +21,6 @@ """ import logging -# pylint: disable=no-name-in-module, import-error -import homeassistant.external.pymysensors.mysensors.mysensors as mysensors -import homeassistant.external.pymysensors.mysensors.const as const from homeassistant.helpers.entity import Entity from homeassistant.const import ( @@ -39,12 +36,16 @@ ATTR_CHILD_ID = "child_id" _LOGGER = logging.getLogger(__name__) -REQUIREMENTS = ['pyserial>=2.7'] +REQUIREMENTS = ['https://github.com/theolind/pymysensors/archive/master.zip' + '#egg=pymysensors-0.1'] def setup_platform(hass, config, add_devices, discovery_info=None): """ Setup the mysensors platform. """ + import mysensors.mysensors as mysensors + import mysensors.const as const + devices = {} # keep track of devices added to HA # Just assume celcius means that the user wants metric for now. # It may make more sense to make this a global config option in the future. @@ -69,7 +70,7 @@ def sensor_update(update_type, nid): name = '{} {}.{}'.format(sensor.sketch_name, nid, child.id) node[child_id][value_type] = \ MySensorsNodeValue( - nid, child_id, name, value_type, is_metric) + nid, child_id, name, value_type, is_metric, const) new_devices.append(node[child_id][value_type]) else: node[child_id][value_type].update_sensor( @@ -102,8 +103,8 @@ def sensor_update(update_type, nid): class MySensorsNodeValue(Entity): """ Represents the value of a MySensors child node. """ - # pylint: disable=too-many-arguments - def __init__(self, node_id, child_id, name, value_type, metric): + # pylint: disable=too-many-arguments, too-many-instance-attributes + def __init__(self, node_id, child_id, name, value_type, metric, const): self._name = name self.node_id = node_id self.child_id = child_id @@ -111,6 +112,7 @@ def __init__(self, node_id, child_id, name, value_type, metric): self.value_type = value_type self.metric = metric self._value = '' + self.const = const @property def should_poll(self): @@ -130,11 +132,11 @@ def state(self): @property def unit_of_measurement(self): """ Unit of measurement of this entity. """ - if self.value_type == const.SetReq.V_TEMP: + if self.value_type == self.const.SetReq.V_TEMP: return TEMP_CELCIUS if self.metric else TEMP_FAHRENHEIT - elif self.value_type == const.SetReq.V_HUM or \ - self.value_type == const.SetReq.V_DIMMER or \ - self.value_type == const.SetReq.V_LIGHT_LEVEL: + elif self.value_type == self.const.SetReq.V_HUM or \ + self.value_type == self.const.SetReq.V_DIMMER or \ + self.value_type == self.const.SetReq.V_LIGHT_LEVEL: return '%' return None @@ -150,8 +152,8 @@ def state_attributes(self): def update_sensor(self, value, battery_level): """ Update a sensor with the latest value from the controller. """ _LOGGER.info("%s value = %s", self._name, value) - if self.value_type == const.SetReq.V_TRIPPED or \ - self.value_type == const.SetReq.V_ARMED: + if self.value_type == self.const.SetReq.V_TRIPPED or \ + self.value_type == self.const.SetReq.V_ARMED: self._value = STATE_ON if int(value) == 1 else STATE_OFF else: self._value = value diff --git a/homeassistant/external/pymysensors b/homeassistant/external/pymysensors deleted file mode 160000 index cd5ef892eeec0a..00000000000000 --- a/homeassistant/external/pymysensors +++ /dev/null @@ -1 +0,0 @@ -Subproject commit cd5ef892eeec0ad027727f7e8f757e7f2927da97 diff --git a/requirements.txt b/requirements.txt index c7a569fad333a1..f9d11975e97a62 100644 --- a/requirements.txt +++ b/requirements.txt @@ -77,5 +77,5 @@ python-forecastio>=1.3.3 # Firmata Bindings (*.arduino) PyMata==2.07a -# Mysensors serial gateway -pyserial>=2.7 +# Mysensors +https://github.com/theolind/pymysensors/archive/master.zip#egg=pymysensors-0.1