-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
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
Bugfix: removed conf_platform #2811
Conversation
@@ -21,7 +21,6 @@ | |||
CONF_BRAND = "brand" | |||
|
|||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ | |||
vol.Required(CONF_PLATFORM): 'serial_pm', |
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'm confused, why doesn't this work ? It should work. platform
should always be set to serial_pm
, or else this platform would have never been loaded.
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'm also confused. It worked here before I installed 0.26
With the 0.26 release, I get the following error message:
ERROR:homeassistant.bootstrap:Invalid config for [sensor.serial_pm]: required key not provided @ data['platform']. Got None
When I removed the CONF_PLATFORM as a required parameter, it loads the sensor (platform is still given in the configuration)
I still don't understand the internal not good enough to say what might be the problem with this.
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.
You can try adding a print(p_validated)
before this line; https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/bootstrap.py#L135
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.
Looks good:
{'name': 'SDS21', 'serial_device': '/dev/ttyUSB0', 'brand': 'novafitness,sds021', 'platform': 'serial_pm'}
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.
Managed a repro:
› python3
Python 3.4.3 (default, Aug 11 2015, 08:57:25)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from homeassistant.components.sensor.serial_pm import PLATFORM_SCHEMA
>>> PLATFORM_SCHEMA({'name': 'SDS21', 'serial_device': '/dev/ttyUSB0', 'brand': 'novafitness,sds021', 'platform': 'serial_pm'})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/paulus/dev/python/home-assistant/lib/python3.4/site-packages/voluptuous-0.9.2-py3.4.egg/voluptuous/schema_builder.py", line 192, in __call__
File "/Users/paulus/dev/python/home-assistant/lib/python3.4/site-packages/voluptuous-0.9.2-py3.4.egg/voluptuous/schema_builder.py", line 486, in validate_dict
File "/Users/paulus/dev/python/home-assistant/lib/python3.4/site-packages/voluptuous-0.9.2-py3.4.egg/voluptuous/schema_builder.py", line 324, in validate_mapping
voluptuous.error.MultipleInvalid: required key not provided @ data['platform']
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 think we've hit a bug in voluptuous.
import voluptuous as vol
schema1 = vol.Schema({vol.Required('platform'): str})
schema2 = schema1.extend({vol.Required('platform'): 'serial_pm'})
data = {'platform': 'serial_pm'}
print('schema1')
print(schema1(data))
print('schema2')
print(schema2(data))
results in the output:
› python3 pm_test.py
schema1
{'platform': 'serial_pm'}
schema2
Traceback (most recent call last):
File "pm_test.py", line 20, in <module>
print(schema2(data))
File "/Users/paulus/dev/python/home-assistant/lib/python3.4/site-packages/voluptuous-0.9.2-py3.4.egg/voluptuous/schema_builder.py", line 192, in __call__
File "/Users/paulus/dev/python/home-assistant/lib/python3.4/site-packages/voluptuous-0.9.2-py3.4.egg/voluptuous/schema_builder.py", line 486, in validate_dict
File "/Users/paulus/dev/python/home-assistant/lib/python3.4/site-packages/voluptuous-0.9.2-py3.4.egg/voluptuous/schema_builder.py", line 324, in validate_mapping
voluptuous.error.MultipleInvalid: required key not provided @ data['platform']
I'll merge this and will include it in a hotfix if we end up doing one later this weekend. Reported the bug here: alecthomas/voluptuous#192 |
* Bugfix: removed conf_platform * Remove unused import * Fix for wrong update
Description: Bugfix, serial_pm doesn't load with the current code in 0.26
Related issue (if applicable): fixes ERROR:homeassistant.bootstrap:Invalid config for [sensor.serial_pm]: required key not provided @ data['platform']. Got None
Checklist:
If user exposed functionality or configuration variables are added/changed:
If code communicates with devices, web services, or a:
tox
run successfully. Your PR cannot be merged unless tests passREQUIREMENTS
variable ([example][ex-requir]).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.If the code does not interact with devices:
tox
run successfully. Your PR cannot be merged unless tests pass