Describe the bug
A crash in the seonsor.py after install
2020-10-28 16:26:35 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.detached_garage_code_slot_1 fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 471, in async_device_update
await self.hass.async_add_executor_job(self.update) # type: ignore
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, *self.kwargs)
File "/config/custom_components/lock-manager/sensor.py", line 170, in update
self.data.update()
File "/usr/src/homeassistant/homeassistant/util/init.py", line 239, in wrapper
result = method(args, **kwargs)
File "/config/custom_components/lock-manager/sensor.py", line 98, in update
Environment (please complete the following information):
Ubuntu 20.04 VM
Home Assistant 0.116.4 running in docker container.
Component version 0.34 (verified it still fails in 0.32)
Lock: Schlage BE469 Touchscreen Deadbolt
additional info
I've done some basic debugging and re-programming here. I assume I have made a classic newbie blunder, but the structure I am receiving does not match the structure that is expected in the code.
It looks like the index is not a separate key in the dict.
It looks like the value is not a separate key in the dict.
Examining the actual structure being passed, there are 2 structures. The first is key 'label' mapping to "Code Count" which is the number of codes in the 'data' key. The second is a specific code info with key 'label' mapping to something like "Code 1". The actual code itself appears to be in a key 'data' mapping to a string. However, all of my codes that do exist are "**" and the ones that don't are empty. This does not appear to be an expected case and the code has no way to really handle this, as after doing a naive fix:
elif ZWAVE_NETWORK in self._hass.data:
if data[ATTR_NODE_ID] is not None:
network = self._hass.data[ZWAVE_NETWORK]
lock_values = (
network.nodes[data[ATTR_NODE_ID]]
.get_values(class_id=COMMAND_CLASS_USER_CODE)
.values()
)
for value in lock_values:
if "Code Count" in value.label:
continue
index_search = re.search('Code (\d+)', value.label)
if index_search:
index = index_search.group(1)
index_code = value.data
_LOGGER.debug(
"DEBUG: code_slot_%s value: %s",
str(index),
str(index_code),
)
# do not update if the code contains *s
if "*" in str(index_code):
_LOGGER.debug("DEBUG: Ignoring code slot with * in value.")
continue
sensor_name = f"code_slot_{index}"
data[sensor_name] = index_code
self._data = data
I am seeing the following errors:
2020-10-29 11:19:40 WARNING (SyncWorker_1) [custom_components.lock-manager.sensor] Code slot code_slot_4 had no value: 'code_slot_4'
2020-10-29 11:19:40 WARNING (SyncWorker_36) [custom_components.lock-manager.sensor] Code slot code_slot_3 had no value: 'code_slot_3'
2020-10-29 11:19:40 WARNING (SyncWorker_45) [custom_components.lock-manager.sensor] Code slot code_slot_2 had no value: 'code_slot_2'
2020-10-29 11:19:40 WARNING (SyncWorker_52) [custom_components.lock-manager.sensor] Code slot code_slot_1 had no value: 'code_slot_1'
Which matches the continue in the if * line.
I honestly suspect I have simply done something stupid and would like a little assistance.
Describe the bug A crash in the seonsor.py after install 2020-10-28 16:26:35 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.detached_garage_code_slot_1 fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 471, in async_device_update await self.hass.async_add_executor_job(self.update) # type: ignore File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, *self.kwargs) File "/config/custom_components/lock-manager/sensor.py", line 170, in update self.data.update() File "/usr/src/homeassistant/homeassistant/util/init.py", line 239, in wrapper result = method(args, **kwargs) File "/config/custom_components/lock-manager/sensor.py", line 98, in update
Environment (please complete the following information): Ubuntu 20.04 VM Home Assistant 0.116.4 running in docker container.
Component version 0.34 (verified it still fails in 0.32) Lock: Schlage BE469 Touchscreen Deadbolt
additional info I've done some basic debugging and re-programming here. I assume I have made a classic newbie blunder, but the structure I am receiving does not match the structure that is expected in the code.
It looks like the index is not a separate key in the dict.
It looks like the value is not a separate key in the dict. Examining the actual structure being passed, there are 2 structures. The first is key 'label' mapping to "Code Count" which is the number of codes in the 'data' key. The second is a specific code info with key 'label' mapping to something like "Code 1". The actual code itself appears to be in a key 'data' mapping to a string. However, all of my codes that do exist are "**" and the ones that don't are empty. This does not appear to be an expected case and the code has no way to really handle this, as after doing a naive fix:
I am seeing the following errors: 2020-10-29 11:19:40 WARNING (SyncWorker_1) [custom_components.lock-manager.sensor] Code slot code_slot_4 had no value: 'code_slot_4' 2020-10-29 11:19:40 WARNING (SyncWorker_36) [custom_components.lock-manager.sensor] Code slot code_slot_3 had no value: 'code_slot_3' 2020-10-29 11:19:40 WARNING (SyncWorker_45) [custom_components.lock-manager.sensor] Code slot code_slot_2 had no value: 'code_slot_2' 2020-10-29 11:19:40 WARNING (SyncWorker_52) [custom_components.lock-manager.sensor] Code slot code_slot_1 had no value: 'code_slot_1'
Which matches the continue in the if * line.
I honestly suspect I have simply done something stupid and would like a little assistance.