Fix callback and async (#31281)
* Fix callback and async * Fix a return * Fix test * Fix mqtt tests * Fix some more callbacks
This commit is contained in:
1 parent
ee602e40a6
commit
e9e44dbd97
90 files changed
+627
-883
No files matched your search
@@ -1,5 +1,4 @@
|
||||
"""Support for a local MQTT broker."""
|
||||
import asyncio
|
||||
import logging
|
||||
import tempfile
|
||||
|
||||
@@ -29,8 +28,7 @@ HBMQTT_CONFIG_SCHEMA = vol.Any(
|
||||
)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_start(hass, password, server_config):
|
||||
async def async_start(hass, password, server_config):
|
||||
"""Initialize MQTT Server.
|
||||
|
||||
This method is a coroutine.
|
||||
@@ -47,17 +45,16 @@ def async_start(hass, password, server_config):
|
||||
server_config = gen_server_config
|
||||
|
||||
broker = Broker(server_config, hass.loop)
|
||||
yield from broker.start()
|
||||
await broker.start()
|
||||
except BrokerException:
|
||||
_LOGGER.exception("Error initializing MQTT server")
|
||||
return False, None
|
||||
finally:
|
||||
passwd.close()
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_shutdown_mqtt_server(event):
|
||||
async def async_shutdown_mqtt_server(event):
|
||||
"""Shut down the MQTT server."""
|
||||
yield from broker.shutdown()
|
||||
await broker.shutdown()
|
||||
|
||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, async_shutdown_mqtt_server)
|
||||
|
||||
|
||||
Reference in new issue
Block a user