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

Add Volkszaehler sensor #16188

Merged
merged 3 commits into from Aug 27, 2018

Conversation

Projects
None yet
3 participants
@fabaff
Member

fabaff commented Aug 25, 2018

Description:

Add support for consuming values exposed by the Volkszähler API.

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

Example entry for configuration.yaml (if applicable):

sensor:
  - platform: volkszaehler
    host: demo.volkszaehler.org
    uuid: '57acbef0-88a9-11e4-934f-6b0f9ecd95a8'
    monitored_conditions:
      - average
      - consumption
      - min
      - max

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][ex-requir]).
  • New dependencies are only imported inside functions that use them ([example][ex-import]).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.
@MartinHjelmare

Nice! Just some small comments.

host = config.get(CONF_HOST)
name = config.get(CONF_NAME)
port = config.get(CONF_PORT)
uuid = config.get(CONF_UUID)

This comment has been minimized.

@MartinHjelmare

MartinHjelmare Aug 26, 2018

Member

Use dict[key] for required config keys.

self._name = name
self.type = sensor_type
self._state = None
self._unit_of_measurement = SENSOR_TYPES[sensor_type][1]

This comment has been minimized.

@MartinHjelmare

MartinHjelmare Aug 26, 2018

Member

Do we need this attribute? Icon doesn't use a dedicated attribute.

This comment has been minimized.

@fabaff
await self.vz_api.async_update()

if self.vz_api.api.data is not None:
if self.type == 'average':

This comment has been minimized.

@MartinHjelmare

MartinHjelmare Aug 26, 2018

Member

We could use getattr:

self._state = round(getattr(self.vz_api.api, self.type), 2)

This comment has been minimized.

@fabaff

fabaff Aug 27, 2018

Member

Thanks

fabaff added some commits Aug 25, 2018

@fabaff fabaff force-pushed the volkszaehler branch from ecaa662 to 237ca5d Aug 27, 2018

@MartinHjelmare

🎉

@MartinHjelmare MartinHjelmare merged commit c51170e into dev Aug 27, 2018

6 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
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.0006%) to 93.732%
Details

@wafflebot wafflebot bot removed the in progress label Aug 27, 2018

@fabaff fabaff deleted the volkszaehler branch Aug 27, 2018

mbennett pushed a commit to mbennett/home-assistant that referenced this pull request Aug 27, 2018

Add Volkszaehler sensor (home-assistant#16188)
* Add Volkszaehler sensor

* Update icons

* Improve code

cyberjacob pushed a commit to cyberjacob/home-assistant that referenced this pull request Sep 4, 2018

Add Volkszaehler sensor (home-assistant#16188)
* Add Volkszaehler sensor

* Update icons

* Improve code

@balloob balloob referenced this pull request Sep 17, 2018

Merged

0.78.0 #16666

@home-assistant home-assistant locked and limited conversation to collaborators Dec 10, 2018

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