Port PyMySensors from external to requirements.txt
This commit is contained in:
parent
a3906242e9
commit
4edf53899d
4 changed files with 17 additions and 19 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -16,9 +16,6 @@
|
||||||
[submodule "homeassistant/external/nzbclients"]
|
[submodule "homeassistant/external/nzbclients"]
|
||||||
path = homeassistant/external/nzbclients
|
path = homeassistant/external/nzbclients
|
||||||
url = https://github.com/jamespcole/home-assistant-nzb-clients.git
|
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"]
|
[submodule "homeassistant/components/frontend/www_static/home-assistant-polymer"]
|
||||||
path = 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
|
url = https://github.com/balloob/home-assistant-polymer.git
|
||||||
|
|
|
@ -21,9 +21,6 @@ Port of your connection to your MySensors device.
|
||||||
"""
|
"""
|
||||||
import logging
|
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.helpers.entity import Entity
|
||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
|
@ -39,12 +36,16 @@ ATTR_NODE_ID = "node_id"
|
||||||
ATTR_CHILD_ID = "child_id"
|
ATTR_CHILD_ID = "child_id"
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_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):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Setup the mysensors platform. """
|
""" Setup the mysensors platform. """
|
||||||
|
|
||||||
|
import mysensors.mysensors as mysensors
|
||||||
|
import mysensors.const as const
|
||||||
|
|
||||||
devices = {} # keep track of devices added to HA
|
devices = {} # keep track of devices added to HA
|
||||||
# Just assume celcius means that the user wants metric for now.
|
# 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.
|
# It may make more sense to make this a global config option in the future.
|
||||||
|
@ -69,7 +70,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
name = '{} {}.{}'.format(sensor.sketch_name, nid, child.id)
|
name = '{} {}.{}'.format(sensor.sketch_name, nid, child.id)
|
||||||
node[child_id][value_type] = \
|
node[child_id][value_type] = \
|
||||||
MySensorsNodeValue(
|
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])
|
new_devices.append(node[child_id][value_type])
|
||||||
else:
|
else:
|
||||||
node[child_id][value_type].update_sensor(
|
node[child_id][value_type].update_sensor(
|
||||||
|
@ -102,8 +103,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
|
|
||||||
class MySensorsNodeValue(Entity):
|
class MySensorsNodeValue(Entity):
|
||||||
""" Represents the value of a MySensors child node. """
|
""" Represents the value of a MySensors child node. """
|
||||||
# pylint: disable=too-many-arguments
|
# pylint: disable=too-many-arguments, too-many-instance-attributes
|
||||||
def __init__(self, node_id, child_id, name, value_type, metric):
|
def __init__(self, node_id, child_id, name, value_type, metric, const):
|
||||||
self._name = name
|
self._name = name
|
||||||
self.node_id = node_id
|
self.node_id = node_id
|
||||||
self.child_id = child_id
|
self.child_id = child_id
|
||||||
|
@ -111,6 +112,7 @@ class MySensorsNodeValue(Entity):
|
||||||
self.value_type = value_type
|
self.value_type = value_type
|
||||||
self.metric = metric
|
self.metric = metric
|
||||||
self._value = ''
|
self._value = ''
|
||||||
|
self.const = const
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
|
@ -130,11 +132,11 @@ class MySensorsNodeValue(Entity):
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
""" Unit of measurement of this entity. """
|
""" 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
|
return TEMP_CELCIUS if self.metric else TEMP_FAHRENHEIT
|
||||||
elif self.value_type == const.SetReq.V_HUM or \
|
elif self.value_type == self.const.SetReq.V_HUM or \
|
||||||
self.value_type == const.SetReq.V_DIMMER or \
|
self.value_type == self.const.SetReq.V_DIMMER or \
|
||||||
self.value_type == const.SetReq.V_LIGHT_LEVEL:
|
self.value_type == self.const.SetReq.V_LIGHT_LEVEL:
|
||||||
return '%'
|
return '%'
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -150,8 +152,8 @@ class MySensorsNodeValue(Entity):
|
||||||
def update_sensor(self, value, battery_level):
|
def update_sensor(self, value, battery_level):
|
||||||
""" Update a sensor with the latest value from the controller. """
|
""" Update a sensor with the latest value from the controller. """
|
||||||
_LOGGER.info("%s value = %s", self._name, value)
|
_LOGGER.info("%s value = %s", self._name, value)
|
||||||
if self.value_type == const.SetReq.V_TRIPPED or \
|
if self.value_type == self.const.SetReq.V_TRIPPED or \
|
||||||
self.value_type == const.SetReq.V_ARMED:
|
self.value_type == self.const.SetReq.V_ARMED:
|
||||||
self._value = STATE_ON if int(value) == 1 else STATE_OFF
|
self._value = STATE_ON if int(value) == 1 else STATE_OFF
|
||||||
else:
|
else:
|
||||||
self._value = value
|
self._value = value
|
||||||
|
|
1
homeassistant/external/pymysensors
vendored
1
homeassistant/external/pymysensors
vendored
|
@ -1 +0,0 @@
|
||||||
Subproject commit cd5ef892eeec0ad027727f7e8f757e7f2927da97
|
|
|
@ -77,5 +77,5 @@ python-forecastio>=1.3.3
|
||||||
# Firmata Bindings (*.arduino)
|
# Firmata Bindings (*.arduino)
|
||||||
PyMata==2.07a
|
PyMata==2.07a
|
||||||
|
|
||||||
# Mysensors serial gateway
|
# Mysensors
|
||||||
pyserial>=2.7
|
https://github.com/theolind/pymysensors/archive/master.zip#egg=pymysensors-0.1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue