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

Rewrite opentherm_gw to a component #17133

Merged
merged 7 commits into from Oct 9, 2018

Conversation

@mvn23
Contributor

mvn23 commented Oct 4, 2018

Description:

Rewrite opentherm_gw to a component. This will allow us to expose internal data as sensors.

Related issue (if applicable): ref. #16670

Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#6637

Example entry for configuration.yaml (if applicable):

opentherm_gw:
  device: /dev/ttyUSB0

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated 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:

  • N/A
# class OpenThermSensor(Entity):
# """Basic functionality for opentherm_gw sensor."""
#

This comment has been minimized.

@houndci-bot

houndci-bot Oct 4, 2018

trailing whitespace

Show resolved Hide resolved homeassistant/components/opentherm_gw.py Outdated
hass, 'climate', DOMAIN, conf.get(CONF_CLIMATE)))
#hass.async_create_task(async_load_platform(
# hass, 'sensor', DOMAIN, conf.get(CONF_MONITORED_VARIABLES)))
#hass.async_create_task(async_load_platform(

This comment has been minimized.

@houndci-bot

houndci-bot Oct 4, 2018

block comment should start with '# '

hass.async_add_job(connect_and_subscribe, hass, conf)
hass.async_create_task(async_load_platform(
hass, 'climate', DOMAIN, conf.get(CONF_CLIMATE)))
#hass.async_create_task(async_load_platform(

This comment has been minimized.

@houndci-bot

houndci-bot Oct 4, 2018

block comment should start with '# '

Show resolved Hide resolved homeassistant/components/opentherm_gw.py
vol.Optional(CONF_BINARY_SENSORS, default=SENSOR_SCHEMA({})):
SENSOR_SCHEMA,
}),
}, extra = vol.ALLOW_EXTRA)

This comment has been minimized.

@houndci-bot

houndci-bot Oct 4, 2018

unexpected spaces around keyword / parameter equals

import asyncio
import voluptuous as vol
from homeassistant.helpers.discovery import (async_load_platform,

This comment has been minimized.

@houndci-bot

houndci-bot Oct 4, 2018

'homeassistant.helpers.discovery.async_listen_platform' imported but unused

@@ -0,0 +1,74 @@
import asyncio

This comment has been minimized.

@houndci-bot

houndci-bot Oct 4, 2018

'asyncio' imported but unused

Add OpenTherm Gateway sensor platform.
* Remove library imports from platforms (use hass.data instead)
* Update .coveragerc
* Update docstrings to use new component documentation url
gw_vars.DATA_MASTER_OT_VERSION: [
None, None, "Thermostat OpenTherm Version"],
gw_vars.DATA_SLAVE_OT_VERSION: [None, None, "Boiler OpenTherm Version"],
gw_vars.DATA_MASTER_PRODUCT_TYPE: [None, None, "Thermostat Product Type"],

This comment has been minimized.

@houndci-bot

houndci-bot Oct 6, 2018

line too long (82 > 79 characters)

None, UNIT_HOUR, "Hot Water Burner Hours"],
gw_vars.DATA_MASTER_OT_VERSION: [
None, None, "Thermostat OpenTherm Version"],
gw_vars.DATA_SLAVE_OT_VERSION: [None, None, "Boiler OpenTherm Version"],

This comment has been minimized.

@houndci-bot

houndci-bot Oct 6, 2018

line too long (80 > 79 characters)

None, None, "Central Heating Burner Starts"],
gw_vars.DATA_CH_PUMP_STARTS: [None, None, "Central Heating Pump Starts"],
gw_vars.DATA_DHW_PUMP_STARTS: [None, None, "Hot Water Pump Starts"],
gw_vars.DATA_DHW_BURNER_STARTS: [None, None, "Hot Water Burner Starts"],

This comment has been minimized.

@houndci-bot

houndci-bot Oct 6, 2018

line too long (80 > 79 characters)

gw_vars.DATA_OEM_DIAG: [None, None, "OEM Diagnostic Code"],
gw_vars.DATA_CH_BURNER_STARTS: [
None, None, "Central Heating Burner Starts"],
gw_vars.DATA_CH_PUMP_STARTS: [None, None, "Central Heating Pump Starts"],

This comment has been minimized.

@houndci-bot

houndci-bot Oct 6, 2018

line too long (81 > 79 characters)

Show resolved Hide resolved homeassistant/components/sensor/opentherm_gw.py Outdated
Show resolved Hide resolved homeassistant/components/opentherm_gw.py Outdated
@MartinHjelmare

This comment has been minimized.

Member

MartinHjelmare commented Oct 7, 2018

Please only do the conversion to component in this PR. Add the new platforms in separate PRs, one platform and PR at a time.

mvn23 added some commits Oct 7, 2018

Remove import from platform, use hass.data instead.
Update .coveragerc
Update docstrings
Update requirements_all.txt
General code cleanup

@mvn23 mvn23 changed the title from [WIP] Rewrite opentherm_gw to a component to Rewrite opentherm_gw to a component Oct 7, 2018

For more details about this component, please refer to the documentation at
http://home-assistant.io/components/climate.opentherm_gw/
For more details about this platform, please refer to the documentation at
http://home-assistant.io/components/opentherm_gw/

This comment has been minimized.

@MartinHjelmare

MartinHjelmare Oct 7, 2018

Member

The url is wrong. Revert to old url. Each platform should have its own docs page.

Show resolved Hide resolved homeassistant/components/opentherm_gw.py
CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
vol.Required(CONF_DEVICE): cv.string,
vol.Optional(CONF_CLIMATE, default=CLIMATE_SCHEMA({})):

This comment has been minimized.

@MartinHjelmare

MartinHjelmare Oct 7, 2018

Member

Just pass an empty dict as default value. It will be automatically passed to the schema.

async def async_setup(hass, config):
"""Set up the OpenTherm Gateway component."""
conf = config.get(DOMAIN)
if conf is None:

This comment has been minimized.

@MartinHjelmare

MartinHjelmare Oct 7, 2018

Member

This can't happen.

async def async_setup(hass, config):
"""Set up the OpenTherm Gateway component."""
conf = config.get(DOMAIN)

This comment has been minimized.

@MartinHjelmare

MartinHjelmare Oct 7, 2018

Member

Use dict[key].

DATA_DEVICE: pyotgw.pyotgw(),
DATA_GW_VARS: pyotgw.vars,
}
hass.async_add_job(connect_and_subscribe, hass, conf)

This comment has been minimized.

@MartinHjelmare

MartinHjelmare Oct 7, 2018

Member

Use hass.async_create_task.

Fix review findings.
Avoid using hass.data within connect_and_subscribe.
@mvn23

This comment has been minimized.

Contributor

mvn23 commented Oct 9, 2018

Thanks for the review, all issues should be addressed.

@MartinHjelmare

Looks good! Can be merged when docs PR is linked in the description and build passes.

@frenck

This comment has been minimized.

Member

frenck commented Oct 9, 2018

Docs appeared! Thanks, @mvn23 👍

@frenck frenck removed the docs-missing label Oct 9, 2018

@MartinHjelmare MartinHjelmare merged commit fc67f5e into home-assistant:dev Oct 9, 2018

5 checks passed

Hound No violations found. Woof!
WIP ready for review
Details
cla-bot Everyone involved has signed the CLA
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.07%) to 93.557%
Details

@wafflebot wafflebot bot removed the in progress label Oct 9, 2018

@mvn23 mvn23 deleted the mvn23:opentherm_gw branch Oct 9, 2018

@balloob balloob referenced this pull request Oct 26, 2018

Merged

0.81 #17809

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment