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

Added Confirmed Restart #1445

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mikimikeCH
Copy link
Contributor

Description

Added Confirmed Restart / Master Reset functionality
Testet with ETS6 Bus Monitor

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)
  • Code quality improvements to existing code or addition of tests

Checklist

  • The documentation has been adjusted accordingly
  • Tests have been added that prove the fix is effective or that the feature works
  • The changes are documented in the changelog (docs/changelog.md)

Changed procedures.nm_individual_address_write back to procedures.nm_invididual_address_write
Copy link

codecov bot commented Apr 22, 2024

Codecov Report

Attention: Patch coverage is 68.85246% with 19 lines in your changes missing coverage. Please review.

Project coverage is 96.44%. Comparing base (15d37ef) to head (d9741ca).
Report is 83 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1445      +/-   ##
==========================================
- Coverage   96.61%   96.44%   -0.18%     
==========================================
  Files         151      151              
  Lines        9801     9862      +61     
==========================================
+ Hits         9469     9511      +42     
- Misses        332      351      +19     
Files Coverage Δ
xknx/management/procedures.py 92.30% <78.26%> (-4.76%) ⬇️
xknx/telegram/apci.py 97.39% <63.15%> (-1.54%) ⬇️

Comment on lines +38 to +43
RestartResponseError = [
"No Error",
"Access denied",
"Unsupported Erase Code",
"Invalid Channel Number",
]
Copy link
Member

Choose a reason for hiding this comment

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

This should be some kind of mapping (dict maybe) or enum, not a plain list.
Maybe move it to xknx/telegram/apci_const.py or xknx/management/const.py something like that.


CODE = APCIService.CONFIRMED_RESTART

def __init__(self, erase_code: bytes, channel: bytes) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

It would be handier to use int instead of bytes for channel and erase_code (or an enum for the latter if applicable).

Maybe set the default value of channel: int = 0 - for some of the erase codes other values are invalid so I guess it would be a proper default.

CODE = APCIService.CONFIRMED_RESTART

def __init__(self, erase_code: bytes, channel: bytes) -> None:
"""Initialize a new instance of FunctionPropertyCommand."""
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"""Initialize a new instance of FunctionPropertyCommand."""
"""Initialize a new instance of ConfirmedRestart."""


def __str__(self) -> str:
"""Return object as readable string."""
return "<Confirmed Restart />"
Copy link
Member

Choose a reason for hiding this comment

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

add the objects attributes so it is easier to debug


CODE = APCIService.CONFIRMED_RESTART_RESPONSE

def __init__(self, error_code: bytes, time: bytes) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

Consider using int or enum for error_code and int for time. Maybe rename time to time_sec or process_time (like in the specs).

@classmethod
def from_knx(cls, raw: bytes) -> RestartResponse:
"""Parse/deserialize from KNX/IP raw data."""
error_code, time = struct.unpack("!BH", raw[2:])
Copy link
Member

Choose a reason for hiding this comment

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

to en/decode time, you could use DPTTimePeriodSec.from_knx() and .to_knx() (but it is just a uint, so may not be necessary 🙃

Comment on lines +29 to +35
CONFIRMED_RESTART = b"\x01"
FACTORY_RESET = b"\x02"
RESET_IA = b"\x03"
RESET_AP = b"\x04"
RESET_PARAM = b"\x05"
RESET_LINKS = b"\x06"
FACTORY_RESET_WITHOUT_IA = b"\x07"
Copy link
Member

Choose a reason for hiding this comment

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

Consider using integers like in the specifications (eg. CONFIRMED_RESTART = 0x01)
Maybe move to xknx/telegram/apci_const.py or xknx/management/const.py something like that.

Copy link
Contributor

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. Thank you for your contributions.

@github-actions github-actions bot added the stale label Jul 26, 2024
@github-actions github-actions bot removed the stale label Aug 2, 2024
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.

2 participants