-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
Basic entity class for Imeon inverter integration #145778
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
Merged
zweckj
merged 10 commits into
home-assistant:dev
from
Imeon-Inverters-for-Home-Assistant:basic-entity
Jun 9, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3bcdad8
Display serial number of the device
TheBushBoy f88e503
Use a common entity class
TheBushBoy 95466c6
Test for the new basic entity
TheBushBoy dc8e8e7
Merge branch 'dev' into basic-entity
Imeon-Energy 33484d2
Remove entity_description
TheBushBoy ad8213a
Merge branch 'dev' into basic-entity
Imeon-Energy 090f3ae
Merge branch 'dev' into basic-entity
Imeon-Energy 695faa4
Remove @dataclass
Imeon-Energy 529b63b
Remove import entity.py
Imeon-Energy 9f3508d
Merge branch 'dev' into basic-entity
Imeon-Energy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""Imeon inverter base class for entities.""" | ||
|
||
from homeassistant.config_entries import ConfigEntry | ||
from homeassistant.helpers.device_registry import DeviceInfo | ||
from homeassistant.helpers.entity import EntityDescription | ||
from homeassistant.helpers.update_coordinator import CoordinatorEntity | ||
|
||
from .const import DOMAIN | ||
from .coordinator import InverterCoordinator | ||
|
||
type InverterConfigEntry = ConfigEntry[InverterCoordinator] | ||
|
||
|
||
class InverterEntity(CoordinatorEntity[InverterCoordinator]): | ||
"""Common elements for all entities.""" | ||
|
||
_attr_has_entity_name = True | ||
|
||
def __init__( | ||
self, | ||
coordinator: InverterCoordinator, | ||
entry: InverterConfigEntry, | ||
entity_description: EntityDescription, | ||
) -> None: | ||
"""Pass coordinator to CoordinatorEntity.""" | ||
super().__init__(coordinator) | ||
self.entity_description = entity_description | ||
self._inverter = coordinator.api.inverter | ||
self.data_key = entity_description.key | ||
assert entry.unique_id | ||
self._attr_unique_id = f"{entry.unique_id}_{self.data_key}" | ||
self._attr_device_info = DeviceInfo( | ||
identifiers={(DOMAIN, entry.unique_id)}, | ||
name="Imeon inverter", | ||
manufacturer="Imeon Energy", | ||
model=self._inverter.get("inverter"), | ||
sw_version=self._inverter.get("software"), | ||
serial_number=self._inverter.get("serial"), | ||
configuration_url=self._inverter.get("url"), | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.