-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
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
base: dev
Are you sure you want to change the base?
Add TIS Control integration #136334
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.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
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.
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"], |
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.
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
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.
https://github.com/TISControlHass/TISControlProtocol
could you please double check this url?
thanks
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.
publish tagged releases that are published automatically using CI
This part is missing
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.
okay i'll set up the ci and update the pull request afterwards.
thanks
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.
Kindly review the repository of the library
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.
|
||
async def async_step_user(self, user_input: dict | None = None) -> ConfigFlowResult: | ||
"""Handle a flow initiated by the user.""" | ||
errors = {} |
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.
typing
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.
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 |
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.
in case someone had multiple bridges (is that a thing), is there an identifer we can add to this?
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.
basically the protocol assumes that all the communication is done with a single bridge so no need here for an identifier
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) |
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.
what's happening here, please walk me through the intended update logic
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 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 :
- 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
- binary feedback : the devices have physical control buttons onboard so when the user pushes them we fire this feedback to update the entity
- 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
Co-authored-by: Josef Zweck <[email protected]>
Co-authored-by: Josef Zweck <[email protected]>
Co-authored-by: Josef Zweck <[email protected]>
Co-authored-by: Josef Zweck <[email protected]>
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. |
@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 👍 |
Breaking change
Proposed change
Added an integration for TIS Control devices (and tests) to home assistant core.
Type of change
Additional information
Checklist
ruff format 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
.To help with the load of incoming pull requests: