Skip to content

Commit

Permalink
bugfixing and adding HZ2
Browse files Browse the repository at this point in the history
  • Loading branch information
OStrama committed Oct 27, 2024
1 parent 7983cce commit 17cc3d1
Show file tree
Hide file tree
Showing 4 changed files with 471 additions and 383 deletions.
62 changes: 32 additions & 30 deletions custom_components/weishaupt_modbus/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,37 +262,39 @@ def __init__(self, config_entry, modbus_item, modbus_api) -> None:
def calc_temperature(self, val: float):
"""Calcualte temperature."""

# match val:
# case None:
# return None
# case -32768:
# # No Sensor installed
# return -1
# case -32767:
# # Sensor broken
# return -2
# case 32768:
# # Dont know. Whats this?
# return None
# case range(-500, 5000):
# # Valid Temperatur range
# return int(val) / self._divider
# case _:
# return None
match val:
case None:
return None
case -32768:
# No Sensor installed, remove it from the list
self._modbus_item.is_valid = False
return -1
case -32767:
# Sensor broken set return value to -99.9 to inform user
return -99.9
case 32768:
# Dont know. Whats this?
self._modbus_item.is_valid = False
return None
case range(-500, 5000):
# Valid Temperatur range
return int(val) / self._divider
case _:
return int(val) / self._divider

if val is None:
return None
if val == -32768:
# No Sensor installed
return -1
if val == -32767:
# Sensor broken
return -2
if val == 32768:
# Dont know. Whats this?
return None
if val in range(-500, 5000):
return int(val) / self._divider
# if val is None:
# return None
# if val == -32768:
# # No Sensor installed
# return -1
# if val == -32767:
# # Sensor broken
# return -2
# if val == 32768:
# # Dont know. Whats this?
# return None
# if val in range(-500, 5000):
# return int(val) / self._divider

def calc_percentage(self, val: float):
"""Calculate percentage."""
Expand Down
Loading

0 comments on commit 17cc3d1

Please sign in to comment.