Merge pull request #42836 from home-assistant/rc

pull/42908/head 0.117.4
Paulus Schoutsen 2020-11-04 17:20:54 +01:00 committed by GitHub
commit 7a96f8a4eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 38 additions and 29 deletions

View File

@ -34,6 +34,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
await coordinator.async_refresh()
if not coordinator.last_update_success:
coordinator.shutdown()
raise ConfigEntryNotReady
hass.data.setdefault(DOMAIN, {})

View File

@ -3,6 +3,6 @@
"name": "Gree Climate",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/gree",
"requirements": ["greeclimate==0.9.2"],
"requirements": ["greeclimate==0.9.5"],
"codeowners": ["@cmroche"]
}
}

View File

@ -49,6 +49,9 @@ from .const import (
CONF_OFF_DELAY,
CONF_REMOVE_DEVICE,
CONF_SIGNAL_REPETITIONS,
DATA_CLEANUP_CALLBACKS,
DATA_LISTENER,
DATA_RFXOBJECT,
DEVICE_PACKET_TYPE_LIGHTING4,
EVENT_RFXTRX_EVENT,
SERVICE_SEND,
@ -93,8 +96,6 @@ DATA_TYPES = OrderedDict(
)
_LOGGER = logging.getLogger(__name__)
DATA_RFXOBJECT = "rfxobject"
DATA_LISTENER = "ha_stop"
def _bytearray_string(data):
@ -188,6 +189,8 @@ async def async_setup_entry(hass, entry: config_entries.ConfigEntry):
"""Set up the RFXtrx component."""
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][DATA_CLEANUP_CALLBACKS] = []
await async_setup_internal(hass, entry)
for domain in DOMAINS:
@ -212,12 +215,17 @@ async def async_unload_entry(hass, entry: config_entries.ConfigEntry):
hass.services.async_remove(DOMAIN, SERVICE_SEND)
for cleanup_callback in hass.data[DOMAIN][DATA_CLEANUP_CALLBACKS]:
cleanup_callback()
listener = hass.data[DOMAIN][DATA_LISTENER]
listener()
rfx_object = hass.data[DOMAIN][DATA_RFXOBJECT]
await hass.async_add_executor_job(rfx_object.close_connection)
hass.data.pop(DOMAIN)
return True
@ -428,6 +436,14 @@ def get_device_id(device, data_bits=None):
return (f"{device.packettype:x}", f"{device.subtype:x}", id_string)
def connect_auto_add(hass, entry_data, callback_fun):
"""Connect to dispatcher for automatic add."""
if entry_data[CONF_AUTOMATIC_ADD]:
hass.data[DOMAIN][DATA_CLEANUP_CALLBACKS].append(
hass.helpers.dispatcher.async_dispatcher_connect(SIGNAL_EVENT, callback_fun)
)
class RfxtrxEntity(RestoreEntity):
"""Represents a Rfxtrx device.

View File

@ -19,11 +19,10 @@ from homeassistant.core import callback
from homeassistant.helpers import event as evt
from . import (
CONF_AUTOMATIC_ADD,
CONF_DATA_BITS,
CONF_OFF_DELAY,
SIGNAL_EVENT,
RfxtrxEntity,
connect_auto_add,
find_possible_pt2262_device,
get_device_id,
get_pt2262_cmd,
@ -147,10 +146,7 @@ async def async_setup_entry(
async_add_entities([sensor])
# Subscribe to main RFXtrx events
if discovery_info[CONF_AUTOMATIC_ADD]:
hass.helpers.dispatcher.async_dispatcher_connect(
SIGNAL_EVENT, binary_sensor_update
)
connect_auto_add(hass, discovery_info, binary_sensor_update)
class RfxtrxBinarySensor(RfxtrxEntity, BinarySensorEntity):

View File

@ -33,3 +33,7 @@ SERVICE_SEND = "send"
DEVICE_PACKET_TYPE_LIGHTING4 = 0x13
EVENT_RFXTRX_EVENT = "rfxtrx_event"
DATA_RFXOBJECT = "rfxobject"
DATA_LISTENER = "ha_stop"
DATA_CLEANUP_CALLBACKS = "cleanup_callbacks"

View File

@ -6,12 +6,11 @@ from homeassistant.const import CONF_DEVICES, STATE_OPEN
from homeassistant.core import callback
from . import (
CONF_AUTOMATIC_ADD,
CONF_DATA_BITS,
CONF_SIGNAL_REPETITIONS,
DEFAULT_SIGNAL_REPETITIONS,
SIGNAL_EVENT,
RfxtrxCommandEntity,
connect_auto_add,
get_device_id,
get_rfx_object,
)
@ -81,8 +80,7 @@ async def async_setup_entry(
async_add_entities([entity])
# Subscribe to main RFXtrx events
if discovery_info[CONF_AUTOMATIC_ADD]:
hass.helpers.dispatcher.async_dispatcher_connect(SIGNAL_EVENT, cover_update)
connect_auto_add(hass, discovery_info, cover_update)
class RfxtrxCover(RfxtrxCommandEntity, CoverEntity):

View File

@ -12,12 +12,11 @@ from homeassistant.const import CONF_DEVICES, STATE_ON
from homeassistant.core import callback
from . import (
CONF_AUTOMATIC_ADD,
CONF_DATA_BITS,
CONF_SIGNAL_REPETITIONS,
DEFAULT_SIGNAL_REPETITIONS,
SIGNAL_EVENT,
RfxtrxCommandEntity,
connect_auto_add,
get_device_id,
get_rfx_object,
)
@ -95,8 +94,7 @@ async def async_setup_entry(
async_add_entities([entity])
# Subscribe to main RFXtrx events
if discovery_info[CONF_AUTOMATIC_ADD]:
hass.helpers.dispatcher.async_dispatcher_connect(SIGNAL_EVENT, light_update)
connect_auto_add(hass, discovery_info, light_update)
class RfxtrxLight(RfxtrxCommandEntity, LightEntity):

View File

@ -20,11 +20,10 @@ from homeassistant.const import (
from homeassistant.core import callback
from . import (
CONF_AUTOMATIC_ADD,
CONF_DATA_BITS,
DATA_TYPES,
SIGNAL_EVENT,
RfxtrxEntity,
connect_auto_add,
get_device_id,
get_rfx_object,
)
@ -127,8 +126,7 @@ async def async_setup_entry(
async_add_entities([entity])
# Subscribe to main RFXtrx events
if discovery_info[CONF_AUTOMATIC_ADD]:
hass.helpers.dispatcher.async_dispatcher_connect(SIGNAL_EVENT, sensor_update)
connect_auto_add(hass, discovery_info, sensor_update)
class RfxtrxSensor(RfxtrxEntity):

View File

@ -8,13 +8,12 @@ from homeassistant.const import CONF_DEVICES, STATE_ON
from homeassistant.core import callback
from . import (
CONF_AUTOMATIC_ADD,
CONF_DATA_BITS,
CONF_SIGNAL_REPETITIONS,
DEFAULT_SIGNAL_REPETITIONS,
DOMAIN,
SIGNAL_EVENT,
RfxtrxCommandEntity,
connect_auto_add,
get_device_id,
get_rfx_object,
)
@ -92,8 +91,7 @@ async def async_setup_entry(
async_add_entities([entity])
# Subscribe to main RFXtrx events
if discovery_info[CONF_AUTOMATIC_ADD]:
hass.helpers.dispatcher.async_dispatcher_connect(SIGNAL_EVENT, switch_update)
connect_auto_add(hass, discovery_info, switch_update)
class RfxtrxSwitch(RfxtrxCommandEntity, SwitchEntity):

View File

@ -1,7 +1,7 @@
"""Constants used by Home Assistant components."""
MAJOR_VERSION = 0
MINOR_VERSION = 117
PATCH_VERSION = "3"
PATCH_VERSION = "4"
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
__version__ = f"{__short_version__}.{PATCH_VERSION}"
REQUIRED_PYTHON_VER = (3, 7, 1)

View File

@ -696,7 +696,7 @@ gpiozero==1.5.1
gps3==0.33.3
# homeassistant.components.gree
greeclimate==0.9.2
greeclimate==0.9.5
# homeassistant.components.greeneye_monitor
greeneye_monitor==2.1

View File

@ -352,7 +352,7 @@ google-cloud-pubsub==0.39.1
google-nest-sdm==0.1.6
# homeassistant.components.gree
greeclimate==0.9.2
greeclimate==0.9.5
# homeassistant.components.griddy
griddypower==0.1.0