Config update

This commit is contained in:
Martin Bauer
2019-06-11 19:28:39 +02:00
parent 4f3c9abd0d
commit fab83c86f4
9 changed files with 157 additions and 297 deletions

View File

@@ -58,6 +58,9 @@ class FhemConnection:
_LOGGER.info("Connected to FHEM {}:{}".format(self._host, self._port))
self._writer = writer
self.connected = True
for device in self.devices.values():
await device.async_update_ha_state()
self.reconnect_time = self.reconnect_time_start
writer.writelines([
"displayattr .*\n".encode(),
@@ -71,6 +74,8 @@ class FhemConnection:
except OSError:
_LOGGER.warning("Connection to FHEM failed {}:{}".format(self._host, self._port))
self.connected = False
for device in self.devices.values():
await device.async_update_ha_state()
await asyncio.sleep(self.reconnect_time)
self.reconnect_time = min(2 * self.reconnect_time, self.reconnect_time)
self.hass.loop.create_task(self._connection())

View File

@@ -25,7 +25,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up lights for KNX platform."""
connection = hass.data[DATA_FHEM]
#_LOGGER.error("FHEM platform config\n" + str(config))
light = FhemLight(connection, config[CONF_NAME], config[CONF_FHEM_IDS], dimmer=config[CONF_DIMMER])
for dev_id in config[CONF_FHEM_IDS]:
@@ -91,7 +90,7 @@ class FhemLight(Light):
self.connection.fhem_set(self._ids[0], 'off')
async def line_received(self, line):
_LOGGER.info("FHEM line received (device): " + self.name + ": " + line)
_LOGGER.debug("FHEM line received (device): " + self.name + ": " + line)
if line.startswith('dim:'):
self._available = True
_, new_dim_state, new_level = line.split(':')