Skip to content

Commit

Permalink
Fix cover without positions
Browse files Browse the repository at this point in the history
Skip creating the climate sensor for the PT100 sensor
Minor fixes
  • Loading branch information
gicamm committed Feb 12, 2023
1 parent f39b295 commit aa3523b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 2 additions & 0 deletions custom_components/comelit/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def __init__(self, id, description, closed, position, hub):
self._hub = hub
if position != -1:
self._position = position
else:
self._position = None

@property
def is_closed(self):
Expand Down
17 changes: 10 additions & 7 deletions custom_components/comelit/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class HubFields:
DATA = 'data'
PARAMETER_NAME = 'param_name'
PARAMETER_VALUE = 'param_value'
SUB_TYPE = 'sub_type'


class HubClasses:
Expand Down Expand Up @@ -332,16 +333,16 @@ def update_climate(self, id, description, data):
target = format(float(data[HubFields.TARGET_TEMPERATURE]), '.1f')
target = float(target) / 10

measured_humidity = float(data[HubFields.HUMIDITY])

is_enabled = int(data['auto_man']) == 2
is_heating = bool(int(data[HubFields.STATUS]))

state_dict = {'is_enabled': is_enabled,
'is_heating': is_heating,
'measured_temperature': measured_temp,
'target_temperature': target,
'measured_humidity': measured_humidity}
'target_temperature': target}

# support sensors without humidity
if HubFields.HUMIDITY in data:
state_dict['measured_humidity'] = float(data[HubFields.HUMIDITY])

climate = ComelitClimate(id, description, state_dict, CommandHub(self))

Expand All @@ -355,7 +356,7 @@ def update_climate(self, id, description, data):
self.climates[name].update_state(state_dict)
_LOGGER.debug("updated the climate %s", name)
except Exception as e:
_LOGGER.exception("Error updating climate %s", e)
_LOGGER.exception("Error updating climate %s %s", e, data)

def update_light(self, id, description, data):
try:
Expand Down Expand Up @@ -472,7 +473,9 @@ def update_entities(self, elements):
elif HubClasses.TEMPERATURE in id:
description = item[HubFields.DESCRIPTION]
self.update_sensor(id, description, item)
self.update_climate(id, description, item)
# skip creating the climate sensor for the PT100 sensor
if HubFields.SUB_TYPE in item and item["sub_type"] == 16:
self.update_climate(id, description, item)
elif HubClasses.LIGHT in id:
description = item[HubFields.DESCRIPTION]
self.update_light(id, description, item)
Expand Down
4 changes: 2 additions & 2 deletions custom_components/comelit/vedo.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def update_sensor(self, s):

# update the alarm area
def update_area(self, area):
_LOGGER.info(f"Updating the alarm area {area}")
_LOGGER.debug(f"Updating the alarm area {area}")
try:
id = area["id"]
name = area["name"]
Expand Down Expand Up @@ -243,7 +243,7 @@ def run(self):

if value > 1:
sensor_dict = {"index": i, "id": i, "name": description[i], "status": zone_statuses[i]}
_LOGGER.info(f"Adding {sensor_dict}")
_LOGGER.debug(f"Updating the zone {sensor_dict}")
sensors.append(sensor_dict)

if self._uid is not None:
Expand Down

0 comments on commit aa3523b

Please sign in to comment.