Skip to content

Add TIS Control integration #136334

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

Draft
wants to merge 14 commits into
base: dev
Choose a base branch
from
Draft

Add TIS Control integration #136334

wants to merge 14 commits into from

Conversation

KarimTIS
Copy link

Breaking change

Proposed change

Added an integration for TIS Control devices (and tests) to home assistant core.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @KarimTIS

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@KarimTIS KarimTIS marked this pull request as draft January 25, 2025 11:17
@KarimTIS KarimTIS marked this pull request as ready for review January 25, 2025 11:17
Copy link
Member

@zweckj zweckj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for your contribution 👍, some initial feedback

"documentation": "https://www.home-assistant.io/integrations/tis_control",
"homekit": {},
"iot_class": "local_polling",
"requirements": ["TISControlProtocol==0.5.13"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unable to find the repository hosting this source code, the repository needs to be public, be assigned with an OSI approved license and publish tagged releases that are published automatically using CI

Copy link
Author

@KarimTIS KarimTIS Mar 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/TISControlHass/TISControlProtocol
could you please double check this url?
thanks

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

publish tagged releases that are published automatically using CI

This part is missing

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay i'll set up the ci and update the pull request afterwards.
thanks

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kindly review the repository of the library

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The repo is still not matching PyPi.

The repo has a single release:
image

That release is also on PyPi, but there are many other recent releases, including a release published just two days ago. To me, it appears as if the public repo is not the full story:
image

There's something wrong also with this:
image


async def async_step_user(self, user_input: dict | None = None) -> ConfigFlowResult:
"""Handle a flow initiated by the user."""
errors = {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typing

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should i use empty dict instead or what exactly in here?


if not errors:
return self.async_create_entry(
title="TIS Control Bridge", data=user_input
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case someone had multiple bridges (is that a thing), is there an identifer we can add to this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basically the protocol assumes that all the communication is done with a single bridge so no need here for an identifier

Comment on lines +82 to +119
async def async_added_to_hass(self) -> None:
"""Subscribe to events."""

@callback
def handle_event(event: Event):
"""Handle the event."""
# check if event is for this switch
if event.event_type == str(self.device_id):
if event.data["feedback_type"] == "control_response":
channel_value = event.data["additional_bytes"][2]
channel_number = event.data["channel_number"]
if int(channel_number) == self.channel_number:
self._state = (
STATE_ON if int(channel_value) == 100 else STATE_OFF
)
elif event.data["feedback_type"] == "binary_feedback":
n_bytes = ceil(event.data["additional_bytes"][0] / 8)
channels_status = "".join(
int_to_8_bit_binary(event.data["additional_bytes"][i])
for i in range(1, n_bytes + 1)
)
self._state = (
STATE_ON
if channels_status[self.channel_number - 1] == "1"
else STATE_OFF
)
elif event.data["feedback_type"] == "update_response":
additional_bytes = event.data["additional_bytes"]
channel_status = int(additional_bytes[self.channel_number])
self._state = STATE_ON if channel_status > 0 else STATE_OFF
elif event.data["feedback_type"] == "offline_device":
self._state = STATE_UNKNOWN

# await self.async_update_ha_state(True)
self.schedule_update_ha_state()

self.listener = self.hass.bus.async_listen(MATCH_ALL, handle_event)
_ = await self.api.protocol.sender.send_packet(self.update_packet)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's happening here, please walk me through the intended update logic

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So basically the library uses ha bus for notifying the entities with updates
each type of devices has a code known as device id so the first thing we do is that we filter events by device id to only listen to relevant events.

the event contains feedback type key which tells the entity what kind of feedback is it receiving, we have the following types :

  1. control response : when the user sends an update command from homeassistant's ui and we recieve acknowledgment that the packet was recieved we fire this event to update the state
  2. binary feedback : the devices have physical control buttons onboard so when the user pushes them we fire this feedback to update the entity
  3. update response : the gateway will keep pullling the devices every specific interval for updates automatically that's when we fire feedback type

now whenever we recieve a feedback we are mainly interested in two things : channel number and channel state
our devices have multiple channels eg 4 channel relay will have a single device id but 4 channels from 1 to 4 each channel will be represented by a switch entity in this case

i hope this clarifies all the points required

@home-assistant home-assistant bot marked this pull request as draft March 18, 2025 12:24
@KarimTIS KarimTIS marked this pull request as ready for review March 23, 2025 02:30
@home-assistant home-assistant bot requested a review from zweckj March 23, 2025 02:30
Copy link

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes.
Thank you for your contribution!

@github-actions github-actions bot added the stale label May 22, 2025
@github-actions github-actions bot removed the stale label May 22, 2025
@emontnemery
Copy link
Contributor

emontnemery commented Jun 26, 2025

@KarimTIS You need to sort out the concerns about the library so it matches these requirements https://developers.home-assistant.io/docs/api_lib_index#basic-library-requirements, without that there won't be a full review of the integration

Please mark the PR as "Ready for review" when you've addressed the concerns about the library 👍

@emontnemery emontnemery marked this pull request as draft June 26, 2025 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants