New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix regression of the xiaomi_aqara config validation #22435
Fix regression of the xiaomi_aqara config validation #22435
Conversation
Woopsie. Looks like I forgot to commit some local changes. |
vol.Optional(CONF_PORT, default=9898): cv.port, | ||
vol.Optional(CONF_DISABLE, default=False): cv.boolean, | ||
GATEWAY_CONFIG_MAC_OPTIONAL = GATEWAY_CONFIG.extend({ | ||
vol.Optional(CONF_MAC, default=None): vol.Any(GW_MAC, None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is pop'ed with a default value, I don't think you need a default here(?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remove the default this configuration isn't valid anymore:
xiaomi_aqara:
gateways:
- key: ffffffffffffffff
mac:
This configuration is still valid:
xiaomi_aqara:
gateways:
- key: ffffffffffffffff
Do you suggest a removal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid a (small?) breaking change it shouldn't be changed cp. HA 0.91:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I thought that would be an explicit None
and thus accepted. I may be wrong, I am not so strong with schemas.
I will tag @MartinHjelmare because he may like to comment. But this is such a minor issue, I think we should merge to get the fix into a beta and a follow-up PR can clean it up if we want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should allow specifying an option key without a value. The only case where that is useful is where we want to activate components, ie the top level keys in the config. All other cases are just confusing and error prone.
Remove the default and mark it a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vol.Optional(CONF_MAC): GW_MAC,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And use dict.get
when accessing that config key.
* Fix regression of the xiaomi_aqara config validation * Make the key optional again * Add base schema * Remove the GW_MAC default
Breaking Change:
The option key
mac
isn't allowed to be empty now. Please remove the key if it's empty.Description:
Fixes a regression introduces by #21834:
@karlkar Could you review/test this fix?
Allowed configurations are