Skip to content

Commit

Permalink
Use actions instead of buttons for virtual remotes (#139)
Browse files Browse the repository at this point in the history
* Remove SVs from EXCLUDED_FROM_SENSOR

* Use actions instead of buttons for virtual remotes
  • Loading branch information
SukramJ authored Jan 7, 2022
1 parent 1772171 commit e36f896
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Version 0.15.0 (2022-01-07)
- Use actions instead of buttons for virtual remotes

Version 0.14.1 (2022-01-06)
- Remove SVs from EXCLUDED_FROM_SENSOR

Version 0.14.0 (2022-01-06)
- Switch some HM-LC-Bl1 to cover
- Use decorators on central methods
Expand Down
16 changes: 8 additions & 8 deletions hahomematic/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def create_entities(self) -> set[BaseEntity]:
parameter_data=parameter_data,
)
if self._device_address.startswith(tuple(HM_VIRTUAL_REMOTES)):
entity = self.create_button(
entity = self.create_action(
channel_address=channel_address,
parameter=parameter,
parameter_data=parameter_data,
Expand Down Expand Up @@ -396,10 +396,10 @@ def create_entities(self) -> set[BaseEntity]:
new_entities.extend(custom_entities)
return set(new_entities)

def create_button(
def create_action(
self, channel_address: str, parameter: str, parameter_data: dict[str, Any]
) -> HmButton | None:
"""Create the buttons associated to this device"""
) -> HmAction | None:
"""Create the actions associated to this device"""
unique_id = generate_unique_id(
domain=self._central.domain,
instance_name=self._central.instance_name,
Expand All @@ -408,21 +408,21 @@ def create_button(
prefix=f"button_{self._central.instance_name}",
)
_LOGGER.debug(
"create_event: Creating button for %s, %s, %s",
"create_event: Creating action for %s, %s, %s",
channel_address,
parameter,
self._interface_id,
)

if button := HmButton(
if action := HmAction(
device=self,
unique_id=unique_id,
channel_address=channel_address,
parameter=parameter,
parameter_data=parameter_data,
):
button.add_to_collections()
return button
action.add_to_collections()
return action
return None

def create_event(
Expand Down
2 changes: 2 additions & 0 deletions hahomematic/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def generate_unique_id(
) -> str:
"""
Build unique id from address and parameter.
Instance_name is addionally used for heating groups.
Prefix is used for events and buttons.
"""
unique_id = address.replace(":", "_").replace("-", "_")
if parameter:
Expand Down
2 changes: 0 additions & 2 deletions hahomematic/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
_LOGGER = logging.getLogger(__name__)

EXCLUDED_FROM_SENSOR = [
"Connection",
"pcCCUID",
"RF-Gateway-Alarm",
]

EXCLUDED = [
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def readme():
},
PACKAGE_NAME = "hahomematic"
HERE = os.path.abspath(os.path.dirname(__file__))
VERSION = "0.14.0"
VERSION = "0.15.0"

PACKAGES = find_packages(exclude=["tests", "tests.*", "dist", "build"])

Expand Down

0 comments on commit e36f896

Please sign in to comment.