-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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 lektrico integration #102371
Add lektrico integration #102371
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.
Just a bit of feedback for you - I am not a core developer so feel free to ignore anything I say and wait for core feedback
await coordinator.async_config_entry_first_refresh() | ||
|
||
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator |
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.
Probably worth ensuring that coordinator.last_update_success is True. unless I am mistaken, UpdateFailed() being raise d in your coordinator will not interrupt this part of the flow
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.
Thank you, I added it.
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.
Is this another previous review fix which has been removed when rebasing?
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.
Is this another previous review fix which has been removed when rebasing?
No, I removed coordinator.last_update_success as suggested in Feb 16.
class LektricoSensorEntityDescription(SensorEntityDescription): | ||
"""A class that describes the Lektrico sensor entities.""" | ||
|
||
value: Callable[[Any], float | str | int] | None = 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.
Why is this optional none? You seem to always do it
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.
Thank you for your help.
I'm having problems with this proposed change:
If I replace
value: Callable[[Any], float | str | int] | None = None
with
value: Callable[[Any], float | str | int]
and I remove None from def native_value(self), I get this error:
2023-11-02 09:00:06.149 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing platform homeassistant.components.lektrico.sensor
Traceback (most recent call last):
File "/workspaces/core/homeassistant/loader.py", line 836, in get_platform
cache[full_name] = self._import_platform(platform_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/core/homeassistant/loader.py", line 853, in _import_platform
return importlib.import_module(f"{self.pkg_path}.{platform_name}")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1204, in _gcd_import
File "", line 1176, in _find_and_load
File "", line 1147, in _find_and_load_unlocked
File "", line 690, in _load_unlocked
File "", line 940, in exec_module
File "", line 241, in _call_with_frames_removed
File "/workspaces/core/homeassistant/components/lektrico/sensor.py", line 36, in
@DataClass
^^^^^^^^^
File "/usr/local/lib/python3.11/dataclasses.py", line 1230, in dataclass
return wrap(cls)
^^^^^^^^^
File "/usr/local/lib/python3.11/dataclasses.py", line 1220, in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dataclasses.py", line 1027, in _process_class
_init_fn(all_init_fields,
File "/usr/local/lib/python3.11/dataclasses.py", line 545, in _init_fn
raise TypeError(f'non-default argument {f.name!r} '
TypeError: non-default argument 'value' follows default argument
2023-11-02 09:00:06.164 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform lektrico.sensor: Platform not found (Exception importing homeassistant.components.lektrico.sensor).
if self.entity_description.value is None: | ||
return 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.
So this sensor would just always be none?
883142c
to
2680df6
Compare
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 additional comments. I did not review sensor.py or the tests yet.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
6de2599
to
f5ec8ea
Compare
7532a4c
to
0327374
Compare
38de2b5
to
55e193c
Compare
Proposed change
Add Lektrico integration
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: