Skip to content

Conversation

@hikirsch
Copy link
Owner

No description provided.

@hikirsch hikirsch changed the title initial commit Initial version of client Jul 29, 2024
htd/__init__.py Outdated
Comment on lines 19 to 23
_ip_address: str = None
_port: int = None
_command_delay_sec: float = None
_retry_attempts: int = None
_socket_timeout_sec: float = None
Copy link

Choose a reason for hiding this comment

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

nitpick: I don't think you need this as they're all defined in your constructor.

htd/__init__.py Outdated
Comment on lines 33 to 37
self._ip_address = ip_address
self._port = port
self._retry_attempts = retry_attempts
self._command_delay_sec = command_delay / ONE_SECOND
self._socket_timeout_sec = socket_timeout / ONE_SECOND
Copy link

Choose a reason for hiding this comment

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

nitpick(cont.): and you can still type them here

Suggested change
self._ip_address = ip_address
self._port = port
self._retry_attempts = retry_attempts
self._command_delay_sec = command_delay / ONE_SECOND
self._socket_timeout_sec = socket_timeout / ONE_SECOND
self._ip_address: str = ip_address
self._port: int = port
self._retry_attempts: int = retry_attempts
self._command_delay_sec: float = command_delay / ONE_SECOND
self._socket_timeout_sec: float = socket_timeout / ONE_SECOND

htd/utils.py Outdated
Comment on lines 21 to 27
# convert the volume into a usable value. the device will transmit a number
# between 196 - 255. if it's at max volume, the raw volume will come as 0.
# this is probably because the gateway only transmits 8 bits per byte.
# 255 is 0b11111111. since there's no volume = 0 (use mute I guess), if the
# volume hits 0, it's because it's at max volume, so we make it 256.
# credit for this goes to lounsbrough
def convert_volume(raw_volume: int) -> (int, int):
Copy link

Choose a reason for hiding this comment

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

nitpick: imo, in-line comments are better with this simple formatting. I would use doc strings for functions so that you can parse the info if you ever care to.

Suggested change
# convert the volume into a usable value. the device will transmit a number
# between 196 - 255. if it's at max volume, the raw volume will come as 0.
# this is probably because the gateway only transmits 8 bits per byte.
# 255 is 0b11111111. since there's no volume = 0 (use mute I guess), if the
# volume hits 0, it's because it's at max volume, so we make it 256.
# credit for this goes to lounsbrough
def convert_volume(raw_volume: int) -> (int, int):
def convert_volume(raw_volume: int) -> (int, int):
"""
convert the volume into a usable value. the device will transmit a number
between 196 - 255. if it's at max volume, the raw volume will come as 0.
this is probably because the gateway only transmits 8 bits per byte.
255 is 0b11111111. since there's no volume = 0 (use mute I guess), if the
volume hits 0, it's because it's at max volume, so we make it 256.
credit for this goes to lounsbrough
"""

Adam Kirschner added 4 commits August 3, 2024 11:19
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.

3 participants