mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Make monitored_conditions more specific in Ambient PWS (#20803)
* Make monitored_conditions more specific in Ambient PWS * Revert messing around with storing monitored_conditions elsewhere * Come on, Aaron
This commit is contained in:
parent
e59240fa00
commit
c7df4cf092
@ -96,12 +96,9 @@ SENSOR_TYPES = {
|
|||||||
CONFIG_SCHEMA = vol.Schema({
|
CONFIG_SCHEMA = vol.Schema({
|
||||||
DOMAIN:
|
DOMAIN:
|
||||||
vol.Schema({
|
vol.Schema({
|
||||||
vol.Required(CONF_APP_KEY):
|
vol.Required(CONF_APP_KEY): cv.string,
|
||||||
cv.string,
|
vol.Required(CONF_API_KEY): cv.string,
|
||||||
vol.Required(CONF_API_KEY):
|
vol.Optional(CONF_MONITORED_CONDITIONS):
|
||||||
cv.string,
|
|
||||||
vol.Optional(
|
|
||||||
CONF_MONITORED_CONDITIONS, default=list(SENSOR_TYPES)):
|
|
||||||
vol.All(cv.ensure_list, [vol.In(SENSOR_TYPES)]),
|
vol.All(cv.ensure_list, [vol.In(SENSOR_TYPES)]),
|
||||||
})
|
})
|
||||||
}, extra=vol.ALLOW_EXTRA)
|
}, extra=vol.ALLOW_EXTRA)
|
||||||
@ -140,8 +137,7 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
Client(
|
Client(
|
||||||
config_entry.data[CONF_API_KEY],
|
config_entry.data[CONF_API_KEY],
|
||||||
config_entry.data[CONF_APP_KEY], session),
|
config_entry.data[CONF_APP_KEY], session),
|
||||||
config_entry.data.get(
|
config_entry.data.get(CONF_MONITORED_CONDITIONS, []))
|
||||||
CONF_MONITORED_CONDITIONS, list(SENSOR_TYPES)))
|
|
||||||
hass.loop.create_task(ambient.ws_connect())
|
hass.loop.create_task(ambient.ws_connect())
|
||||||
hass.data[DOMAIN][DATA_CLIENT][config_entry.entry_id] = ambient
|
hass.data[DOMAIN][DATA_CLIENT][config_entry.entry_id] = ambient
|
||||||
except WebsocketConnectionError as err:
|
except WebsocketConnectionError as err:
|
||||||
@ -206,6 +202,15 @@ class AmbientStation:
|
|||||||
|
|
||||||
_LOGGER.debug('New station subscription: %s', data)
|
_LOGGER.debug('New station subscription: %s', data)
|
||||||
|
|
||||||
|
# If the user hasn't specified monitored conditions, use only
|
||||||
|
# those that their station supports (and which are defined
|
||||||
|
# here):
|
||||||
|
if not self.monitored_conditions:
|
||||||
|
self.monitored_conditions = [
|
||||||
|
k for k in station['lastData'].keys()
|
||||||
|
if k in SENSOR_TYPES
|
||||||
|
]
|
||||||
|
|
||||||
self.stations[station['macAddress']] = {
|
self.stations[station['macAddress']] = {
|
||||||
ATTR_LAST_DATA: station['lastData'],
|
ATTR_LAST_DATA: station['lastData'],
|
||||||
ATTR_LOCATION: station['info']['location'],
|
ATTR_LOCATION: station['info']['location'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user