Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
scottyphillips committed Jan 14, 2022
1 parent 36d621f commit c08f8e6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
27 changes: 13 additions & 14 deletions custom_components/echonetlite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,27 +210,26 @@ def __init__(self, instance, api, entry):

# Detect HVAC - eventually we will use factory here.
self._update_flags_full_list = []
flags = []
if self._eojgc == 1 and self._eojcc == 48:
_LOGGER.debug(f"Create new HomeAirConditioner instance for: {self._eojgc}-{self._eojcc}-{self._eojci}")
for value in HVAC_API_CONNECTOR_DEFAULT_FLAGS:
if value in self._getPropertyMap:
self._update_flags_full_list.append(value)
self._instance = echonet.HomeAirConditioner(self._host, self._api)
_LOGGER.debug(f"Create new HomeAirConditioner instance at: {self._host}")
flags = HVAC_API_CONNECTOR_DEFAULT_FLAGS
elif self._eojgc == 2 and self._eojcc == 144:
_LOGGER.debug(f"Create new GeneralLighting instance for: {self._eojgc}-{self._eojcc}-{self._eojci}")
for value in LIGHT_API_CONNECTOR_DEFAULT_FLAGS:
if value in self._getPropertyMap:
self._update_flags_full_list.append(value)
self._instance = echonet.GeneralLighting(self._host, self._api, self._eojci)
_LOGGER.debug(f"Create new GeneralLighting instance at: {self._host}")
flags = LIGHT_API_CONNECTOR_DEFAULT_FLAGS
else:
_LOGGER.debug(f"Create new default instance for: {self._eojgc}-{self._eojcc}-{self._eojci}")
self._update_flags_full_list = [ENL_STATUS]
_LOGGER.debug(f"Create new Generic instance for {self._eojgc}-{self._eojcc}-{self._eojci} at {self._host}")
flags = [ENL_STATUS]
for item in self._getPropertyMap:
if item not in list(EPC_SUPER.keys()):
if item in list(EPC_CODE[self._eojgc][self._eojcc].keys()):
self._update_flags_full_list.append(item)
flags.append(item)

self._instance = echonet.Factory(self._host, self._api, self._eojgc, self._eojcc, self._eojci)
for value in flags:
if value in self._getPropertyMap:
self._update_flags_full_list.append(value)
self._update_data[value] = None
self._instance = echonet.Factory(self._host, self._api, self._eojgc, self._eojcc, self._eojci)

# Split list of codes into batches of 10
start_index = 0
Expand Down
7 changes: 6 additions & 1 deletion custom_components/echonetlite/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@ def target_temperature_step(self):
@property
def hvac_mode(self):
"""Return current operation ie. heat, cool, idle."""
return self._connector._update_data[ENL_HVAC_MODE] if self._connector._update_data[ENL_STATUS] == "On" else "off"
if self._connector._update_data[ENL_STATUS] == "On":
if self._connector._update_data[ENL_HVAC_MODE] == 'auto':
return HVAC_MODE_HEAT_COOL
else:
return self._connector._update_data[ENL_HVAC_MODE]
return "off"

@property
def hvac_action(self):
Expand Down
6 changes: 4 additions & 2 deletions custom_components/echonetlite/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,11 @@ def device_info(self):
@property
def native_value(self) -> StateType:
"""Return the state of the sensor."""
if self._sensor_attributes[CONF_TYPE] == DEVICE_CLASS_TEMPERATURE:
if self._instance._update_data[self._op_code] is None:
return STATE_UNAVAILABLE
elif self._sensor_attributes[CONF_TYPE] == DEVICE_CLASS_TEMPERATURE:
if self._op_code in self._instance._update_data:
if self._instance._update_data[self._op_code] == 126 or self._instance._update_data[self._op_code] is None:
if self._instance._update_data[self._op_code] == 126:
return STATE_UNAVAILABLE
else:
return self._instance._update_data[self._op_code]
Expand Down

0 comments on commit c08f8e6

Please sign in to comment.