jason0x43 / hubitatmaker

A Python library for interfacing with a Hubitat hub via its Maker API
MIT License
9 stars 6 forks source link

Integration Setup fails if HSM is not enabled in the MakerAPI #8

Closed bmorgenthaler closed 3 years ago

bmorgenthaler commented 3 years ago

If "Allow control of modes" and "Allow control of HSM" are not enabled in Hubitat MakerAPI then the integration setup fails and never completes. The following is in the home assistant logs:

2020-11-30 14:49:32 DEBUG (MainThread) [hubitatmaker.hub] Loaded modes 2020-11-30 14:49:32 DEBUG (MainThread) [hubitatmaker.hub] Loaded hsm status 2020-11-30 14:49:32 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Hubitat for hubitat Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 236, in async_setup result = await component.async_setup_entry(hass, self) # type: ignore File "/config/custom_components/hubitat/__init__.py", line 33, in async_setup_entry if not await hub.async_setup(): File "/config/custom_components/hubitat/device.py", line 184, in async_setup await self._hub.start() File "/usr/local/lib/python3.8/site-packages/hubitatmaker/hub.py", line 158, in start await self._load_hsm_status() File "/usr/local/lib/python3.8/site-packages/hubitatmaker/hub.py", line 336, in _load_hsm_status self._hsm_status = hsm["hsm"] KeyError: 'hsm'

jason0x43 commented 3 years ago

Ah, that's probably a case I didn't test. I added HSM and mode support to the support library (hubitatmaker) a while back. I probably turned on support for those and never turned them back off, so I didn't notice the break. It should be an easy fix.