mirror of
https://github.com/home-assistant/core.git
synced 2025-11-08 02:19:31 +00:00
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:
@@ -6,8 +6,8 @@ https://home-assistant.io/components/sensor.mysensors/
|
||||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.const import (
|
||||
ATTR_BATTERY_LEVEL, STATE_OFF, STATE_ON, TEMP_CELSIUS, TEMP_FAHRENHEIT)
|
||||
from homeassistant.const import (ATTR_BATTERY_LEVEL, STATE_OFF, STATE_ON,
|
||||
TEMP_CELSIUS, TEMP_FAHRENHEIT)
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.loader import get_component
|
||||
|
||||
@@ -157,8 +157,13 @@ class MySensorsSensor(Entity):
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return device specific state attributes."""
|
||||
address = getattr(self.gateway, 'server_address', None)
|
||||
if address:
|
||||
device = '{}:{}'.format(address[0], address[1])
|
||||
else:
|
||||
device = self.gateway.port
|
||||
attr = {
|
||||
self.mysensors.ATTR_PORT: self.gateway.port,
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user