Use PLATFORM_SCHEMA_BASE as base schema for additional components.#20578
Conversation
| """Discover and add a MQTT camera.""" | ||
| try: | ||
| discovery_hash = discovery_payload[ATTR_DISCOVERY_HASH] | ||
| discovery_hash = discovery_payload.pop(ATTR_DISCOVERY_HASH) |
There was a problem hiding this comment.
Pop discovery_hash from the config dict since this is used by MQTT discovery, and not part of the schema.
| """Discover and add a MQTT climate device.""" | ||
| try: | ||
| discovery_hash = discovery_payload[ATTR_DISCOVERY_HASH] | ||
| discovery_hash = discovery_payload.pop(ATTR_DISCOVERY_HASH) |
There was a problem hiding this comment.
Pop discovery_hash from the config dict since this is used by MQTT discovery, and not part of the schema.
| default=DEFAULT_AWAY_TIMEOUT): cv.positive_int, | ||
| vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string | ||
| }) | ||
| }).extend(mqtt.MQTT_RO_PLATFORM_SCHEMA.schema) |
There was a problem hiding this comment.
The platform schema should extend standard MQTT schema which includes state_topic, qos, etc.
| ] | ||
|
|
||
| PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ | ||
| vol.Optional(CONF_ENTITY_NAMESPACE): cv.string, |
There was a problem hiding this comment.
entity_namespace is used in one of wunderground test cases.
Not sure if it's correct to add it here, or if the testcase is stale?
There was a problem hiding this comment.
I think we should add it to the base platform schema. It's an option used in the entity component code, so all EntityPlatforms are affected.
There was a problem hiding this comment.
According to the docs:
These options are being phased out and are only available for single platform integrations.
But sure, maybe makes sense to add to the base schema.
There was a problem hiding this comment.
Yes, but now we're talking about potentially breaking all platforms in one go. So it's needs to be a conscious decision.
| 'method': 'GET', | ||
| 'value_template': '{{ value_json.key }}', | ||
| 'name': 'foo', | ||
| 'unit_of_measurement': 'MB', |
There was a problem hiding this comment.
This looks like test case copy/paste error
| assert hass.states.get(DOMAIN + '.test').state == STATE_OPEN | ||
|
|
||
|
|
||
| async def test_disable_automatic_add(hass, monkeypatch): |
There was a problem hiding this comment.
automatic_add is not supported for RFLink cover so remove the test.
@javicalle Maybe you can confirm it's correct to remove the test case?
There was a problem hiding this comment.
I think you're right
I have reviewed the cover component and it is as you say.
Sorry for the inconvenience.
| 'platform': 'mqtt', | ||
| 'name': 'test', | ||
| 'state_topic': 'test-topic', | ||
| 'power_state_topic': 'test-topic', |
There was a problem hiding this comment.
Copy/paste error.
| 'platform': 'mqtt', | ||
| 'name': 'test', | ||
| 'state_topic': 'test-topic', | ||
| 'power_state_topic': 'test-topic', |
There was a problem hiding this comment.
Copy/paste error.
| 'platform': 'filter', | ||
| 'name': 'test', | ||
| 'entity_id': 'sensor.test_monitored', | ||
| 'history_period': '00:05', |
There was a problem hiding this comment.
No history_period configuration variable documented, copy/paste error?
| ) | ||
| for value in options: | ||
| cv.PLATFORM_SCHEMA(value) | ||
| cv.PLATFORM_SCHEMA_BASE(value) |
There was a problem hiding this comment.
I'm not so sure about this one.
What's the point of this test case?
There was a problem hiding this comment.
I think it's that the base platform schema should require 'platform' key, and allow extra.
There was a problem hiding this comment.
OK, that makes sense.
MartinHjelmare
left a comment
There was a problem hiding this comment.
I've looked it over and it looks good besides the entity namespace key. We probably need to add that to PLATFORM_SCHEMA in config_validation.py.
@balloob should comment on that.
|
Yeah, we should add it to the base schema validation. |
|
OK, fixed now. I'm also a bit worried about breaking platforms which don't have tests and where configuration keys are missing from the schema. Maybe that simply has to be worked out in the beta cycle? |
|
We should add a test for the entity namespace key, since it's a global option. Platform specific options aren't that dangerous. So I think it's ok to go ahead with this, after adding that test. We're hopefully improving config validation this way. |
|
Not having this go into the next release, 86 was a bit rough on config validation already. |
|
@MartinHjelmare I'm really not sure how to write the new test.. As discussed on discord, this test tests How to rewrite it to use |
|
Test added which tests entity_namespace is in PLATFORM_SCHEMA |
|
Should we separate entity namespace key addition to a separate PR that we include in 0.87, to avoid breaking any alarm_control_panel platforms? |
|
@MartinHjelmare Good idea! Edit: Done in #20693 |
ffe2153 to
9fa549c
Compare
So can this be merged now that 0.87 beta is cut? |
Fix the configuration validation error issue due to Home Assistant disallow arbitrary configuration attributes in MQTT platforms. See the issue log of HA for details: home-assistant/core#20578
|
Hi awesome dev folks, |
|
This hasn't been released yet. |
|
@MartinHjelmare I think it's a request to make this change extra visible in the future 0.88 release notes, to increase the chance that users take notice. |
Edit by @balloob: Breaking change should be listed in main release notes. Not just breaking changes section.
Description:
Use PLATFORM_SCHEMA_BASE as base schema for remaining components.
PLATFORM_SCHEMA_BASE doesn't set
extra=vol.ALLOW_EXTRAwhich means misspelled or unknown configuration variables will no longer be silently accepted.Remove
PLATFORM_SCHEMA_2and removeextra=vol.ALLOW_EXTRAfromPLATFORM_SCHEMA#19871 should now be fixed.
This is a follow-up to #20224 .
Checklist:
tox. Your PR cannot be merged unless tests pass