fix: remove checks for state for sentry mode#66
Conversation
|
Given the request in the main HA, I'll leave this open for any further fixes we can batch together. |
|
Regarding the issue in HA PR home-assistant/core#32938, we only know that sentry mode is available when we query |
|
I think you can just set the EDIT: Actually, that won't work because the entity itself won't run async_update after it's disabled. I think perhaps you do a data.get('sentry_mode') which will set the value to None which is unavailable in HA. self.__sentry_mode = data.get('sentry_mode') is True if data.get('sentry_mode') else NoneBut that's just off the top of my head and it looks ugly. Users will then have to choose to disable it if they don't want the unavailable item. That will also suppress the EDIT 2: KeyError catch probably will look cleaner to be honest. Should also set the default value to None. |
|
@alandtse , I have added a flag to know if sentry mode is available. If not, nothing should happen and sentry mode is always False. As long as there is no flag at the vehicle level, then the switch will exist but do nothing. Can a switch be set to disabled? |
alandtse
left a comment
There was a problem hiding this comment.
As long as there is no flag at the vehicle level, then the switch will exist but do nothing. Can a switch be set to disabled?
Yes with the available property.
feat: add sentry mode availability flag
change key check rename is_available to available rename is_enabled to is_on remove get_value
|
Argh... I am too late. I removed the unecessary |
|
Ooops. I thought you were done since you addressed everything. If you know anything about using pytest, it'd be nice to have a suite of tests for sentry mode. That may be a worthwhile PR to add and then we can remove it in that one too. |
Similar to PR #64, and as requested in PR #61, remove check for current state in case it is not accurate.