Skip to content
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

Merged

Conversation

@syssi
Copy link
Member

commented Mar 26, 2019

Breaking Change:

The option key mac isn't allowed to be empty now. Please remove the key if it's empty.

# not allowed anymore
xiaomi_aqara:
    gateways:
        - key: gkdaptzfdjl48ds9
          mac:

# valid
xiaomi_aqara:
    gateways:
        - key: gkdaptzfdjl48ds9

# valid
xiaomi_aqara:
    gateways:
        - key: gkdaptzfdjl48ds9
          mac: 0242cba9b678

Description:

Fixes a regression introduces by #21834:

2019-03-26 17:53:25 ERROR (MainThread) [homeassistant.config] Invalid config for [xiaomi_aqara]:
[mac] is an invalid option for [xiaomi_aqara]. Check: xiaomi_aqara->xiaomi_aqara->gateways->0->mac. (See /home/homeassistant/.homeassistant/configuration.yaml, line 1025). Please check the docs at https://home-assistant.io/components/xiaomi_aqara/

@karlkar Could you review/test this fix?

Allowed configurations are

# Valid
xiaomi_aqara:
    gateways:
        - key: gkdaptzfdjl48ds9

# Valid
xiaomi_aqara:
    gateways:
        - mac: 0242cba9b678
          key: gkdaptzfdjl48ds9

# Valid
xiaomi_aqara:
    gateways:
        - mac: 0242cba9b678
          key: gkdaptzfdjl48ds9
        - mac: 9242cba9b679
          key: vfdaptzfdjl48d3j

# Invalid
xiaomi_aqara:
    gateways:
        - key: gkdaptzfdjl48ds9
        - mac: 9242cba9b679
          key: vfdaptzfdjl48d3j

# Invalid
xiaomi_aqara:
    gateways:
        - key: gkdaptzfdjl48ds9
        - key: vfdaptzfdjl48d3j
@karlkar

This comment has been minimized.

Copy link
Contributor

commented Mar 26, 2019

Woopsie. Looks like I forgot to commit some local changes.
Now it is ok. Sorry for that.

@syssi syssi added this to the 0.91.0 milestone Mar 28, 2019

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)

This comment has been minimized.

Copy link
@amelchio

amelchio Mar 29, 2019

Contributor

Since this is pop'ed with a default value, I don't think you need a default here(?)

This comment has been minimized.

Copy link
@syssi

syssi Mar 29, 2019

Author Member

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?

This comment has been minimized.

Copy link
@syssi

syssi Mar 29, 2019

Author Member

This comment has been minimized.

Copy link
@amelchio

amelchio Mar 29, 2019

Contributor

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.

This comment has been minimized.

Copy link
@MartinHjelmare

MartinHjelmare Mar 29, 2019

Member

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.

This comment has been minimized.

Copy link
@MartinHjelmare

MartinHjelmare Mar 29, 2019

Member
vol.Optional(CONF_MAC): GW_MAC,

This comment has been minimized.

Copy link
@MartinHjelmare

MartinHjelmare Mar 29, 2019

Member

And use dict.get when accessing that config key.

@balloob balloob merged commit f46a837 into home-assistant:dev Mar 29, 2019

4 of 6 checks passed

Build Error Workflow: Build Error
Details
ci/circleci: Build Error Your tests failed on CircleCI
Details
Hound No violations found. Woof!
cla-bot Everyone involved has signed the CLA
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.06%) to 93.34%
Details

@ghost ghost removed the in progress label Mar 29, 2019

balloob added a commit that referenced this pull request Mar 29, 2019

Fix regression of the xiaomi_aqara config validation (#22435)
* Fix regression of the xiaomi_aqara config validation

* Make the key optional again

* Add base schema

* Remove the GW_MAC default

@balloob balloob referenced this pull request Apr 3, 2019

Merged

0.91.0 #22688

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.