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

Bugfix: removed conf_platform #2811

Merged
merged 3 commits into from Aug 13, 2016
Merged

Bugfix: removed conf_platform #2811

merged 3 commits into from Aug 13, 2016

Conversation

ghost
Copy link

@ghost ghost commented Aug 13, 2016

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:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable ([example][ex-requir]).
  • New dependencies are only imported inside functions that use them ([example][ex-import]).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

@@ -21,7 +21,6 @@
CONF_BRAND = "brand"

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_PLATFORM): 'serial_pm',
Copy link
Member

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.

Copy link
Author

@ghost ghost Aug 13, 2016

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.

Copy link
Member

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

Copy link
Author

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'}

Copy link
Member

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']

Copy link
Member

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']

@balloob
Copy link
Member

balloob commented Aug 13, 2016

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

@balloob balloob merged commit 8329472 into home-assistant:dev Aug 13, 2016
@balloob balloob mentioned this pull request Aug 13, 2016
6 tasks
balloob pushed a commit that referenced this pull request Aug 14, 2016
* Bugfix: removed conf_platform

* Remove unused import

* Fix for wrong update
@home-assistant home-assistant locked and limited conversation to collaborators Mar 17, 2017
@ghost ghost deleted the pmfix branch July 20, 2017 11:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant