-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move homeworks base entity to separate module (#126097)
* Move homeworks base entity to separate module * Move calculate_unique_id to util.py
- Loading branch information
Showing
7 changed files
with
50 additions
and
38 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,35 @@ | ||
"""Support for Lutron Homeworks Series 4 and 8 systems.""" | ||
|
||
from __future__ import annotations | ||
|
||
from pyhomeworks.pyhomeworks import Homeworks | ||
|
||
from homeassistant.helpers.entity import Entity | ||
|
||
from .util import calculate_unique_id | ||
|
||
|
||
class HomeworksEntity(Entity): | ||
"""Base class of a Homeworks device.""" | ||
|
||
_attr_has_entity_name = True | ||
_attr_should_poll = False | ||
|
||
def __init__( | ||
self, | ||
controller: Homeworks, | ||
controller_id: str, | ||
addr: str, | ||
idx: int, | ||
name: str | None, | ||
) -> None: | ||
"""Initialize Homeworks device.""" | ||
self._addr = addr | ||
self._idx = idx | ||
self._controller_id = controller_id | ||
self._attr_name = name | ||
self._attr_unique_id = calculate_unique_id( | ||
self._controller_id, self._addr, self._idx | ||
) | ||
self._controller = controller | ||
self._attr_extra_state_attributes = {"homeworks_address": self._addr} |
This file contains 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 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,6 @@ | ||
"""Support for Lutron Homeworks Series 4 and 8 systems.""" | ||
|
||
|
||
def calculate_unique_id(controller_id: str, addr: str, idx: int) -> str: | ||
"""Calculate entity unique id.""" | ||
return f"homeworks.{controller_id}.{addr}.{idx}" |