-
-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
Add Volkszaehler sensor #16188
Conversation
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.
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) |
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.
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] |
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.
Do we need this attribute? Icon doesn't use a dedicated attribute.
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.
No.
await self.vz_api.async_update() | ||
|
||
if self.vz_api.api.data is not None: | ||
if self.type == 'average': |
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.
We could use getattr
:
self._state = round(getattr(self.vz_api.api, self.type), 2)
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.
Thanks
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.
🎉
* Add Volkszaehler sensor * Update icons * Improve code
* Add Volkszaehler sensor * Update icons * Improve code
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):Checklist:
tox
. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTS
variable ([example][ex-requir]).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.