Skip to content

Commit

Permalink
Fix Monitored Condition Exception (#82)
Browse files Browse the repository at this point in the history
* Fix Monitored Condition Exception

* Fix __init__ error

* Updates to versions
  • Loading branch information
GuyKh authored Jan 16, 2024
1 parent a852d13 commit f18b65b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v0.1.22

* Fix Monitored Condition backward compatibility


## v0.1.21

- [BREAKING CHANGE]: Rename `sensor.ims_rain` sensor to `sensor.ims_is_raining`
Expand Down
15 changes: 13 additions & 2 deletions custom_components/ims/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,19 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

def _get_config_value(config_entry: ConfigEntry, key: str) -> Any:
if config_entry.options:
return config_entry.options[key]
return config_entry.data[key]
val = config_entry.options.get(key)
if val:
return val
else:
_LOGGER.warning("Key %s is missing from config_entry.options", key)
return None
val = config_entry.data.get(key)
if val:
return val
else:
_LOGGER.warning("Key %s is missing from config_entry.data", key)
return None



def _filter_domain_configs(elements, domain):
Expand Down
6 changes: 3 additions & 3 deletions custom_components/ims/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async def async_step_user(self, user_input=None):
vol.Required(CONF_MODE, default=DEFAULT_FORECAST_MODE): vol.In(
FORECAST_MODES
),
vol.Optional(CONF_MONITORED_CONDITIONS, default=[]): cv.multi_select(
vol.Optional(CONF_MONITORED_CONDITIONS, default=SENSOR_DESCRIPTIONS_KEYS): cv.multi_select(
SENSOR_DESCRIPTIONS_KEYS
),
vol.Required(CONF_IMAGES_PATH, default="/tmp"): cv.string,
Expand Down Expand Up @@ -142,7 +142,7 @@ async def async_step_import(self, import_input=None):
if CONF_IMAGES_PATH not in config:
config[CONF_IMAGES_PATH] = DEFAULT_IMAGE_PATH
if CONF_MONITORED_CONDITIONS not in config:
config[CONF_MONITORED_CONDITIONS] = []
config[CONF_MONITORED_CONDITIONS] = SENSOR_DESCRIPTIONS_KEYS
return await self.async_step_user(config)


Expand Down Expand Up @@ -215,7 +215,7 @@ async def async_step_init(self, user_input=None):
CONF_MONITORED_CONDITIONS,
default=self.config_entry.options.get(
CONF_MONITORED_CONDITIONS,
self.config_entry.data.get(CONF_MONITORED_CONDITIONS, []),
self.config_entry.data.get(CONF_MONITORED_CONDITIONS, SENSOR_DESCRIPTIONS_KEYS),
),
): cv.multi_select(SENSOR_DESCRIPTIONS_KEYS),
vol.Optional(
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ims/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/t0mer/ims-custom-component/issues",
"requirements": ["weatheril>=0.32.0"],
"version": "0.1.21"
"version": "0.1.22"
}
4 changes: 2 additions & 2 deletions custom_components/ims/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@
): cv.positive_int,
vol.Optional(IMS_PLATFORM): cv.string,
vol.Optional(CONF_MODE, default=FORECAST_MODE_HOURLY): vol.In(FORECAST_MODES),
vol.Optional(CONF_MONITORED_CONDITIONS, default=None): cv.multi_select(
SENSOR_DESCRIPTIONS_DICT
vol.Optional(CONF_MONITORED_CONDITIONS, default=SENSOR_DESCRIPTIONS_KEYS): cv.multi_select(
SENSOR_DESCRIPTIONS_KEYS
),
}
)
Expand Down

0 comments on commit f18b65b

Please sign in to comment.