Skip to content
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

Rename Telegram.group_address to Telegram.destination_address. #510

Merged
merged 9 commits into from
Nov 28, 2020

Conversation

basilfx
Copy link
Contributor

@basilfx basilfx commented Nov 25, 2020

Description

This PR is a part of #253, for easier reviewing.

In this PR, I refactored Telegram.group_address to Telegram.address telegram.destination_address. Based on the type of address, the CEMIFrame is build with the proper flags set. This changes allows for the other changes of #253 to support non-broadcast APCI services.

All high-level devices still use group_address, which still makes sense over there. They just update a Telegram.destination_address with their group_address.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • I have performed a self-review of my own code
  • The documentation has been adjusted accordingly
  • The changes generate no new warnings
  • Tests have been added that prove the fix is effective or that the feature works
  • The changes are documented in the changelog
  • The Homeassistant plugin has been adjusted in case of new config options

Copy link
Member

@marvin-w marvin-w left a comment

Choose a reason for hiding this comment

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

I like this change. Thank you! Splitting it apart makes a lot of sense considering the size of the original PR. Once the minor issue is fixed we can merge this.

xknx/telegram/telegram.py Outdated Show resolved Hide resolved
@basilfx basilfx force-pushed the feature/telegram_address branch from f99fa91 to 767540e Compare November 25, 2020 23:52
Copy link
Member

@marvin-w marvin-w left a comment

Choose a reason for hiding this comment

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

Looks nice, thank you!

Hint: Please don't force push once someone reviewed it as it's hard to find the actual changes.

@basilfx
Copy link
Contributor Author

basilfx commented Nov 25, 2020

I'm aware of the hint, but in this case I did it directly since the change was so small ;-)

Next time I'll do a fixup commit and then squash once approved.

@marvin-w
Copy link
Member

Cool! 👍

And yes, it was really small 👯

No need to manually squash. We can just squash the whole PR when merging.

@coveralls
Copy link

coveralls commented Nov 26, 2020

Coverage Status

Coverage increased (+0.005%) to 94.499% when pulling 7ad8f3d on basilfx:feature/telegram_address into ffec8c1 on XKNX:master.

@farmio
Copy link
Member

farmio commented Nov 26, 2020

Since a Telegram has a destination address and a source address it would be nice to call it eg. one of "destination_address", "dest_address", "destination".
I know our Telegram object currently doesn't contain the source address, but I'd like to add it for eg. #497 and I can imagine other useful cases for source address in Device class.

@basilfx
Copy link
Contributor Author

basilfx commented Nov 26, 2020

@farmio Yes, that would be awesome. But I would prefer to do it in another PR. It's quite some work to adapt it, and it doesn't 'help' me to achieve the goal of #253.

@farmio
Copy link
Member

farmio commented Nov 26, 2020

Just to get this straight: I just want to avoid renaming Telegram.group_address twice.
Adding source to Telegram should definitely be done in another PR (whenever and by whoever likes to)

@basilfx
Copy link
Contributor Author

basilfx commented Nov 26, 2020

That's fine. So let's call it destination_address address then? That should be OK to adapt :)

@farmio
Copy link
Member

farmio commented Nov 26, 2020

Great! Descriptive is always nice. 😃

This renames `Telegram.group_address` to `Telegram.address`. This
makes it possible to use a telegram for non-broadcast types of
messages.
Per feedback, rename this to `Telegram.destination_address`.
@basilfx basilfx force-pushed the feature/telegram_address branch from 767540e to 6028759 Compare November 26, 2020 19:49
@basilfx
Copy link
Contributor Author

basilfx commented Nov 26, 2020

Rebased the PR and adapted Telegram.address to Telegram.destination_address.

@basilfx basilfx changed the title Rename Telegram.group_address to Telegram.address. Rename Telegram.group_address to Telegram.destination_address. Nov 26, 2020
@marvin-w
Copy link
Member

marvin-w commented Nov 28, 2020

@basilfx Please fix the merge conflicts and the linting error (black formatting).

https://travis-ci.org/github/XKNX/xknx/jobs/746142703#L349

Pre-commit will do this automatically for you.

EDIT: Took care of it already.

@basilfx
Copy link
Contributor Author

basilfx commented Nov 28, 2020

Pushed one more to changelog.md since the field was renamed.

@marvin-w marvin-w merged commit f1f654f into XKNX:master Nov 28, 2020
@marvin-w
Copy link
Member

Thanks! Merged.

@@ -110,13 +110,13 @@ def to_knx(self, value):

async def process(self, telegram, always_callback=False):
"""Process incoming or outgoing telegram."""
if not self.has_group_address(telegram.group_address):
if not self.has_group_address(telegram.destination_address):
Copy link
Member

@farmio farmio Nov 28, 2020

Choose a reason for hiding this comment

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

will this raise TypeError if destination_address is a PhysicalAddress ? Could this even happen? Is this tested?

if type(self) is not type(other):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants