Fix bug with monitored_conditions in Ambient PWS (#20837)
* Make monitored_conditions more specific in Ambient PWS * Revert messing around with storing monitored_conditions elsewhere * Come on, Aaron * Fix bug with monitored_conditions in Ambient PWS
This commit is contained in:
parent
55f9db6992
commit
b5b03f5b7f
1 changed files with 12 additions and 2 deletions
|
@ -28,6 +28,8 @@ from .const import (
|
|||
REQUIREMENTS = ['aioambient==0.1.0']
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DATA_CONFIG = 'config'
|
||||
|
||||
DEFAULT_SOCKET_MIN_RETRY = 15
|
||||
|
||||
TYPE_24HOURRAININ = '24hourrainin'
|
||||
|
@ -234,12 +236,20 @@ async def async_setup(hass, config):
|
|||
|
||||
conf = config[DOMAIN]
|
||||
|
||||
# Store config for use during entry setup:
|
||||
hass.data[DOMAIN][DATA_CONFIG] = conf
|
||||
|
||||
if conf[CONF_APP_KEY] in configured_instances(hass):
|
||||
return True
|
||||
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={'source': SOURCE_IMPORT}, data=conf))
|
||||
DOMAIN,
|
||||
context={'source': SOURCE_IMPORT},
|
||||
data={
|
||||
CONF_API_KEY: conf[CONF_API_KEY],
|
||||
CONF_APP_KEY: conf[CONF_APP_KEY]
|
||||
}))
|
||||
|
||||
return True
|
||||
|
||||
|
@ -257,7 +267,7 @@ async def async_setup_entry(hass, config_entry):
|
|||
Client(
|
||||
config_entry.data[CONF_API_KEY],
|
||||
config_entry.data[CONF_APP_KEY], session),
|
||||
config_entry.data.get(CONF_MONITORED_CONDITIONS, []))
|
||||
hass.data[DOMAIN][DATA_CONFIG].get(CONF_MONITORED_CONDITIONS, []))
|
||||
hass.loop.create_task(ambient.ws_connect())
|
||||
hass.data[DOMAIN][DATA_CLIENT][config_entry.entry_id] = ambient
|
||||
except WebsocketConnectionError as err:
|
||||
|
|
Loading…
Add table
Reference in a new issue