Changes due to manifest.json. Awaiting coroutines instead of creating tasks (#23321)

pull/23341/head
Andre Lengwenus 2019-04-24 04:20:20 +02:00 committed by Paulus Schoutsen
parent aa26f90420
commit 662375bdd7
6 changed files with 32 additions and 44 deletions

View File

@ -1,6 +1,8 @@
"""Support for LCN devices.""" """Support for LCN devices."""
import logging import logging
import pypck
from pypck.connection import PchkConnectionManager
import voluptuous as vol import voluptuous as vol
from homeassistant.const import ( from homeassistant.const import (
@ -149,9 +151,6 @@ def get_connection(connections, connection_id=None):
async def async_setup(hass, config): async def async_setup(hass, config):
"""Set up the LCN component.""" """Set up the LCN component."""
import pypck
from pypck.connection import PchkConnectionManager
hass.data[DATA_LCN] = {} hass.data[DATA_LCN] = {}
conf_connections = config[DOMAIN][CONF_CONNECTIONS] conf_connections = config[DOMAIN][CONF_CONNECTIONS]
@ -201,7 +200,6 @@ class LcnDevice(Entity):
def __init__(self, config, address_connection): def __init__(self, config, address_connection):
"""Initialize the LCN device.""" """Initialize the LCN device."""
import pypck
self.pypck = pypck self.pypck = pypck
self.config = config self.config = config
self.address_connection = address_connection self.address_connection = address_connection

View File

@ -1,4 +1,6 @@
"""Support for LCN binary sensors.""" """Support for LCN binary sensors."""
import pypck
from homeassistant.components.binary_sensor import BinarySensorDevice from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.const import CONF_ADDRESS from homeassistant.const import CONF_ADDRESS
@ -13,8 +15,6 @@ async def async_setup_platform(hass, hass_config, async_add_entities,
if discovery_info is None: if discovery_info is None:
return return
import pypck
devices = [] devices = []
for config in discovery_info: for config in discovery_info:
address, connection_id = config[CONF_ADDRESS] address, connection_id = config[CONF_ADDRESS]
@ -50,9 +50,8 @@ class LcnRegulatorLockSensor(LcnDevice, BinarySensorDevice):
async def async_added_to_hass(self): async def async_added_to_hass(self):
"""Run when entity about to be added to hass.""" """Run when entity about to be added to hass."""
await super().async_added_to_hass() await super().async_added_to_hass()
self.hass.async_create_task( await self.address_connection.activate_status_request_handler(
self.address_connection.activate_status_request_handler( self.setpoint_variable)
self.setpoint_variable))
@property @property
def is_on(self): def is_on(self):
@ -84,9 +83,8 @@ class LcnBinarySensor(LcnDevice, BinarySensorDevice):
async def async_added_to_hass(self): async def async_added_to_hass(self):
"""Run when entity about to be added to hass.""" """Run when entity about to be added to hass."""
await super().async_added_to_hass() await super().async_added_to_hass()
self.hass.async_create_task( await self.address_connection.activate_status_request_handler(
self.address_connection.activate_status_request_handler( self.bin_sensor_port)
self.bin_sensor_port))
@property @property
def is_on(self): def is_on(self):
@ -115,9 +113,8 @@ class LcnLockKeysSensor(LcnDevice, BinarySensorDevice):
async def async_added_to_hass(self): async def async_added_to_hass(self):
"""Run when entity about to be added to hass.""" """Run when entity about to be added to hass."""
await super().async_added_to_hass() await super().async_added_to_hass()
self.hass.async_create_task( await self.address_connection.activate_status_request_handler(
self.address_connection.activate_status_request_handler( self.source)
self.source))
@property @property
def is_on(self): def is_on(self):

View File

@ -1,4 +1,6 @@
"""Support for LCN covers.""" """Support for LCN covers."""
import pypck
from homeassistant.components.cover import CoverDevice from homeassistant.components.cover import CoverDevice
from homeassistant.const import CONF_ADDRESS from homeassistant.const import CONF_ADDRESS
@ -12,8 +14,6 @@ async def async_setup_platform(hass, hass_config, async_add_entities,
if discovery_info is None: if discovery_info is None:
return return
import pypck
devices = [] devices = []
for config in discovery_info: for config in discovery_info:
address, connection_id = config[CONF_ADDRESS] address, connection_id = config[CONF_ADDRESS]
@ -43,9 +43,8 @@ class LcnCover(LcnDevice, CoverDevice):
async def async_added_to_hass(self): async def async_added_to_hass(self):
"""Run when entity about to be added to hass.""" """Run when entity about to be added to hass."""
await super().async_added_to_hass() await super().async_added_to_hass()
self.hass.async_create_task( await self.address_connection.activate_status_request_handler(
self.address_connection.activate_status_request_handler( self.motor)
self.motor))
@property @property
def is_closed(self): def is_closed(self):

View File

@ -1,4 +1,6 @@
"""Support for LCN lights.""" """Support for LCN lights."""
import pypck
from homeassistant.components.light import ( from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_TRANSITION, SUPPORT_BRIGHTNESS, SUPPORT_TRANSITION, ATTR_BRIGHTNESS, ATTR_TRANSITION, SUPPORT_BRIGHTNESS, SUPPORT_TRANSITION,
Light) Light)
@ -16,8 +18,6 @@ async def async_setup_platform(
if discovery_info is None: if discovery_info is None:
return return
import pypck
devices = [] devices = []
for config in discovery_info: for config in discovery_info:
address, connection_id = config[CONF_ADDRESS] address, connection_id = config[CONF_ADDRESS]
@ -56,9 +56,8 @@ class LcnOutputLight(LcnDevice, Light):
async def async_added_to_hass(self): async def async_added_to_hass(self):
"""Run when entity about to be added to hass.""" """Run when entity about to be added to hass."""
await super().async_added_to_hass() await super().async_added_to_hass()
self.hass.async_create_task( await self.address_connection.activate_status_request_handler(
self.address_connection.activate_status_request_handler( self.output)
self.output))
@property @property
def supported_features(self): def supported_features(self):
@ -138,9 +137,8 @@ class LcnRelayLight(LcnDevice, Light):
async def async_added_to_hass(self): async def async_added_to_hass(self):
"""Run when entity about to be added to hass.""" """Run when entity about to be added to hass."""
await super().async_added_to_hass() await super().async_added_to_hass()
self.hass.async_create_task( await self.address_connection.activate_status_request_handler(
self.address_connection.activate_status_request_handler( self.output)
self.output))
@property @property
def is_on(self): def is_on(self):

View File

@ -1,4 +1,6 @@
"""Support for LCN sensors.""" """Support for LCN sensors."""
import pypck
from homeassistant.const import CONF_ADDRESS, CONF_UNIT_OF_MEASUREMENT from homeassistant.const import CONF_ADDRESS, CONF_UNIT_OF_MEASUREMENT
from . import LcnDevice, get_connection from . import LcnDevice, get_connection
@ -13,8 +15,6 @@ async def async_setup_platform(hass, hass_config, async_add_entities,
if discovery_info is None: if discovery_info is None:
return return
import pypck
devices = [] devices = []
for config in discovery_info: for config in discovery_info:
address, connection_id = config[CONF_ADDRESS] address, connection_id = config[CONF_ADDRESS]
@ -50,9 +50,8 @@ class LcnVariableSensor(LcnDevice):
async def async_added_to_hass(self): async def async_added_to_hass(self):
"""Run when entity about to be added to hass.""" """Run when entity about to be added to hass."""
await super().async_added_to_hass() await super().async_added_to_hass()
self.hass.async_create_task( await self.address_connection.activate_status_request_handler(
self.address_connection.activate_status_request_handler( self.variable)
self.variable))
@property @property
def state(self): def state(self):
@ -91,9 +90,8 @@ class LcnLedLogicSensor(LcnDevice):
async def async_added_to_hass(self): async def async_added_to_hass(self):
"""Run when entity about to be added to hass.""" """Run when entity about to be added to hass."""
await super().async_added_to_hass() await super().async_added_to_hass()
self.hass.async_create_task( await self.address_connection.activate_status_request_handler(
self.address_connection.activate_status_request_handler( self.source)
self.source))
@property @property
def state(self): def state(self):

View File

@ -1,4 +1,6 @@
"""Support for LCN switches.""" """Support for LCN switches."""
import pypck
from homeassistant.components.switch import SwitchDevice from homeassistant.components.switch import SwitchDevice
from homeassistant.const import CONF_ADDRESS from homeassistant.const import CONF_ADDRESS
@ -12,8 +14,6 @@ async def async_setup_platform(hass, hass_config, async_add_entities,
if discovery_info is None: if discovery_info is None:
return return
import pypck
devices = [] devices = []
for config in discovery_info: for config in discovery_info:
address, connection_id = config[CONF_ADDRESS] address, connection_id = config[CONF_ADDRESS]
@ -46,9 +46,8 @@ class LcnOutputSwitch(LcnDevice, SwitchDevice):
async def async_added_to_hass(self): async def async_added_to_hass(self):
"""Run when entity about to be added to hass.""" """Run when entity about to be added to hass."""
await super().async_added_to_hass() await super().async_added_to_hass()
self.hass.async_create_task( await self.address_connection.activate_status_request_handler(
self.address_connection.activate_status_request_handler( self.output)
self.output))
@property @property
def is_on(self): def is_on(self):
@ -91,9 +90,8 @@ class LcnRelaySwitch(LcnDevice, SwitchDevice):
async def async_added_to_hass(self): async def async_added_to_hass(self):
"""Run when entity about to be added to hass.""" """Run when entity about to be added to hass."""
await super().async_added_to_hass() await super().async_added_to_hass()
self.hass.async_create_task( await self.address_connection.activate_status_request_handler(
self.address_connection.activate_status_request_handler( self.output)
self.output))
@property @property
def is_on(self): def is_on(self):