Add mysensors tcp ethernet gateway (#1861)

* Bump version of pymysensors to 0.6, which includes the tcp gateway.
* Update requirements_all.txt.
* Replace CONF_PORT with CONF_DEVICE and ATTR_PORT with ATTR_DEVICE.
* Add tcp_port in config.
* Try to guess if tcp or serial gateway is configured, by validating
	device name as an ip address. If successful setup tcp gateway, if it
	fails, setup serial gateway.
* Update device_state_attributes to show correct device, ethernet or
	serial.
This commit is contained in:
Paulus Schoutsen committed 2016-04-19 21:00:56 -07:00
1 parent 2e79e9d5bb
commit 9d391becc1
8 files changed
+71 -39

No files matched your search

+11 -6
View File
@@ -6,8 +6,8 @@ https://home-assistant.io/components/light.mysensors/
"""
import logging
from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_RGB_COLOR, Light)
from homeassistant.components.light import (ATTR_BRIGHTNESS, ATTR_RGB_COLOR,
Light)
from homeassistant.const import ATTR_BATTERY_LEVEL, STATE_OFF, STATE_ON
from homeassistant.loader import get_component
from homeassistant.util.color import rgb_hex_to_rgb_list
@@ -100,15 +100,20 @@ class MySensorsLight(Light):
@property
def device_state_attributes(self):
"""Return device specific state attributes."""
device_attr = {
self.mysensors.ATTR_PORT: self.gateway.port,
address = getattr(self.gateway, 'server_address', None)
if address:
device = '{}:{}'.format(address[0], address[1])
else:
device = self.gateway.port
attr = {
self.mysensors.ATTR_DEVICE: device,
self.mysensors.ATTR_NODE_ID: self.node_id,
self.mysensors.ATTR_CHILD_ID: self.child_id,
ATTR_BATTERY_LEVEL: self.battery_level,
}
for value_type, value in self._values.items():
device_attr[self.gateway.const.SetReq(value_type).name] = value
return device_attr
attr[self.gateway.const.SetReq(value_type).name] = value
return attr
@property
def available(self):