-
-
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
Update to EnvoyReader 0.2, support for more hardware #16212
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.
Some small changes; additionally, please make sure you check off the appropriate boxes in the PR description as they are completed.
@@ -32,20 +32,20 @@ | |||
ICON = 'mdi:flash' | |||
|
|||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ | |||
vol.Required(CONF_IP_ADDRESS): cv.string, | |||
vol.Optional(CONF_IP_ADDRESS, default="envoy"): cv.string, |
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.
Make "envoy"
a constant and reference that here. Additionally, because of this, I assume documentation changes re in order?
@@ -81,27 +81,23 @@ def icon(self): | |||
|
|||
def update(self): | |||
"""Get the energy production data from the Enphase Envoy.""" | |||
import envoy_reader | |||
from envoy_reader import EnvoyReader | |||
|
|||
if self._type == "production": |
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 know this wasn't the case originally, but since you're in here, these strings should be constants, as well.
vol.Optional(CONF_MONITORED_CONDITIONS, default=list(SENSORS)): | ||
vol.All(cv.ensure_list, [vol.In(list(SENSORS))])}) | ||
|
||
|
||
def setup_platform(hass, config, add_entities, discovery_info=None): |
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.
Revert change of add_entities
. We've renamed that function.
|
||
if self._type == "production": | ||
self._state = int(envoy_reader.production(self._ip_address)) | ||
self._state = EnvoyReader(self._ip_address).production() |
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.
If we add a map between sensor type and EnvoyReader
method name, by extending SENSORS
, we can simplify this code block significantly, by using getattr
.
Changing the keys in |
@MartinHjelmare |
You could add an item in the tuples of |
No, we might as just break it instead of making the code more complicated. Thanks for the ideas though. |
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 to me! @bachya what say you?
…16212) * Add support for older Envoy models * Stop requiring envoy model name in config * Update to envoy_reader0.2 * Minor formatting fixes * run script/gen_requirements_all.py * Minor formatting fixes * Change some strings to constants, use getattr to call function
Description:
Related issue (if applicable):
fixes #16210, fixes #16137
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#6088
Breaking Change: Change keys in monitored_conditions from
7_days_production
and7_days_consumption
toseven_days_production
andseven_days_consumption
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).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.If the code does not interact with devices: