Hotfix device name with autodiscovery (#3791)

This commit is contained in:
Pascal Vizeli 2016-10-10 13:46:23 +02:00 committed by GitHub
parent b6e008be71
commit 76a1a54369

View File

@ -353,7 +353,8 @@ def _get_devices(device_type, keys):
name = _create_ha_name( name = _create_ha_name(
name=device.NAME, name=device.NAME,
channel=channel, channel=channel,
param=param param=param,
count=len(channels)
) )
device_dict = { device_dict = {
CONF_PLATFORM: "homematic", CONF_PLATFORM: "homematic",
@ -377,22 +378,22 @@ def _get_devices(device_type, keys):
return device_arr return device_arr
def _create_ha_name(name, channel, param): def _create_ha_name(name, channel, param, count):
"""Generate a unique object name.""" """Generate a unique object name."""
# HMDevice is a simple device # HMDevice is a simple device
if channel == 1 and param is None: if count == 1 and param is None:
return name return name
# Has multiple elements/channels # Has multiple elements/channels
if channel > 1 and param is None: if count > 1 and param is None:
return "{} {}".format(name, channel) return "{} {}".format(name, channel)
# With multiple param first elements # With multiple param first elements
if channel == 1 and param is not None: if count == 1 and param is not None:
return "{} {}".format(name, param) return "{} {}".format(name, param)
# Multiple param on object with multiple elements # Multiple param on object with multiple elements
if channel > 1 and param is not None: if count > 1 and param is not None:
return "{} {} {}".format(name, channel, param) return "{} {} {}".format(name, channel, param)
@ -600,12 +601,6 @@ class HMDevice(Entity):
if self._state: if self._state:
self._state = self._state.upper() self._state = self._state.upper()
# Generate name
if not self._name:
self._name = _create_ha_name(name=self._address,
channel=self._channel,
param=self._state)
@property @property
def should_poll(self): def should_poll(self):
"""Return false. Homematic states are pushed by the XML RPC Server.""" """Return false. Homematic states are pushed by the XML RPC Server."""