Skip to content

Commit

Permalink
Merge pull request #125 from jontofront/1.0.7
Browse files Browse the repository at this point in the history
1.0.7
  • Loading branch information
jontofront authored Dec 16, 2024
2 parents a98be07 + 30b91af commit fab4477
Show file tree
Hide file tree
Showing 12 changed files with 379 additions and 183 deletions.
62 changes: 41 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,31 +107,51 @@ __Password__: Local password (NOT the password that you use to login to econet24

These sensors are retrieved from the `../econet/regParams` endpoint. Below is the list of available entity keys and their descriptions:

| sensor Key | Description |
|----------------------|------------------------------------------|
| `tempFeeder` | Temperature of the feeder mechanism |
| `fuelLevel` | Current fuel level in the system |
| `tempCO` | Current fireplace temperature |
| `tempCOSet` | Desired fireplace set temperature |
| `statusCWU` | Status of the hot water (CWU) system |
| `tempCWUSet` | Desired hot water (CWU) temperature |
| `tempFlueGas` | Exhaust temperature reading |
| `mode` | Current operational mode of the device |
| `fanPower` | Current fan power usage |
| `thermostat` | Thermostat status or set temperature |
| `tempExternalSensor` | Outside (external) temperature |
### Sensors

These sensors are retrieved from the `../econet/regParams` and `../econet/sysParams` endpoints. Below is the list of available entity keys, their descriptions, and the corresponding API endpoint keys:

| Entity Key | Description | Endpoint |
|----------------------|-----------------------------------------------------------|-----------------------|
| `tempFeeder` | Temperature of the feeder mechanism | `../econet/regParams` |
| `fuelLevel` | Current fuel level in the system | `../econet/regParams` |
| `tempCO` | Current fireplace temperature | `../econet/regParams` |
| `tempCOSet` | Desired fireplace set temperature | `../econet/regParams` |
| `statusCWU` | Status of the hot water (CWU) system | `../econet/regParams` |
| `tempCWU` | Current hot water (CWU) temperature | `../econet/regParams` |
| `tempCWUSet` | Desired hot water (CWU) temperature | `../econet/regParams` |
| `tempFlueGas` | Exhaust temperature reading | `../econet/regParams` |
| `mode` | Current operational mode of the device | `../econet/regParams` |
| `fanPower` | Current fan power usage | `../econet/regParams` |
| `thermostat` | Thermostat status or set temperature | `../econet/regParams` |
| `tempExternalSensor` | Outside (external) temperature | `../econet/regParams` |
| `tempLowerBuffer` | Temperature of the lower thermal buffer | `../econet/regParams` |
| `tempUpperBuffer` | Temperature of the upper thermal buffer | `../econet/regParams` |
| `quality` | Fuel quality or system quality indicator (if applicable) | `../econet/sysParams` |
| `signal` | Signal strength or communication status | `../econet/sysParams` |
| `softVer` | Software version of the controller | `../econet/sysParams` |
| `controllerID` | Unique identifier for the controller | `../econet/sysParams` |
| `moduleASoftVer` | Software version of Module A | `../econet/sysParams` |
| `moduleBSoftVer` | Software version of Module B | `../econet/sysParams` |
| `moduleCSoftVer` | Software version of Module C | `../econet/sysParams` |
| `moduleLambdaSoftVer`| Software version of the lambda module | `../econet/sysParams` |
| `modulePanelSoftVer` | Software version of the control panel | `../econet/sysParams` |


### Binary Sensors

These binary sensors are retrieved from the `../econet/regParams` endpoint. Below is the list of available entity keys and their descriptions:
| Entity Key | Description |
|----------------------|---------------------------------------------|
| `lighter` | Indicates if the lighter is active |
| `pumpCOWorks` | Indicates if the fireplace pump is working |
| `fanWorks` | Indicates if the fan is currently active |
| `pumpFireplaceWorks` | Indicates if the fireplace pump is working |
| `pumpCWUWorks` | Indicates if the hot water (CWU) pump is active |
These binary sensors are retrieved from the `../econet/regParams` and `../econet/sysParams` endpoints. Below is the list of available entity keys, their descriptions, and the corresponding API endpoint keys:

| Entity Key | Description | Endpoint |
|----------------------|--------------------------------------------------|-----------------------|
| `lighter` | Indicates if the lighter is active | `../econet/regParams` |
| `pumpCOWorks` | Indicates if the fireplace pump is working | `../econet/regParams` |
| `fanWorks` | Indicates if the fan is currently active | `../econet/regParams` |
| `pumpFireplaceWorks` | Indicates if the fireplace pump is working | `../econet/regParams` |
| `pumpCWUWorks` | Indicates if the hot water (CWU) pump is active | `../econet/regParams` |
| `mainSrv` | Indicates if the main server is operational | `../econet/sysParams` |
| `wifi` | Indicates if the Wi-Fi connection is active | `../econet/sysParams` |
| `lan` | Indicates if the LAN connection is active | `../econet/sysParams` |


## Contributing
Expand Down
20 changes: 16 additions & 4 deletions custom_components/econet300/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,21 @@ async def set_param(self, param, value) -> bool:
async def get_param_limits(self, param: str):
"""Fetch and return the limits for a particular parameter from the Econet 300 API, using a cache for efficient retrieval if available."""
if not self._cache.exists(API_EDITABLE_PARAMS_LIMITS_DATA):
limits = await self._fetch_api_data_by_key(
API_EDITABLE_PARAMS_LIMITS_URI, API_EDITABLE_PARAMS_LIMITS_DATA
)
self._cache.set(API_EDITABLE_PARAMS_LIMITS_DATA, limits)
try:
# Attempt to fetch the API data
limits = await self._fetch_api_data_by_key(
API_EDITABLE_PARAMS_LIMITS_URI, API_EDITABLE_PARAMS_LIMITS_DATA
)
# Cache the fetched data
self._cache.set(API_EDITABLE_PARAMS_LIMITS_DATA, limits)
except Exception as e:
# Log the error and return None if an exception occurs
_LOGGER.error(
"An error occurred while fetching API data from %s: %s",
API_EDITABLE_PARAMS_LIMITS_URI,
e,
)
return None

# Retrieve limits from the cache
limits = self._cache.get(API_EDITABLE_PARAMS_LIMITS_DATA)
Expand Down Expand Up @@ -312,6 +323,7 @@ async def _fetch_api_data_by_key(self, endpoint: str, data_key: str | None = Non

return data[data_key]


async def make_api(hass: HomeAssistant, cache: MemCache, data: dict):
"""Create api object."""
return await Econet300Api.create(
Expand Down
26 changes: 20 additions & 6 deletions custom_components/econet300/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging

from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,
BinarySensorEntity,
BinarySensorEntityDescription,
)
Expand Down Expand Up @@ -84,7 +85,9 @@ def create_binary_entity_description(key: str) -> EconetBinarySensorEntityDescri
entity_description = EconetBinarySensorEntityDescription(
key=key,
translation_key=camel_to_snake(key),
device_class=ENTITY_BINARY_DEVICE_CLASS_MAP.get(key, None),
device_class=ENTITY_BINARY_DEVICE_CLASS_MAP.get(
key, BinarySensorDeviceClass.RUNNING
),
icon=ENTITY_ICON.get(key, None),
icon_off=ENTITY_ICON_OFF.get(key, None),
)
Expand All @@ -95,20 +98,31 @@ def create_binary_entity_description(key: str) -> EconetBinarySensorEntityDescri
def create_binary_sensors(coordinator: EconetDataCoordinator, api: Econet300Api):
"""Create binary sensors."""
entities: list[EconetBinarySensor] = []
coordinator_data = coordinator.data["regParams"]
data_regParams = coordinator.data.get("regParams", {})
data_sysParams = coordinator.data.get("sysParams", {})

for data_key in BINARY_SENSOR_MAP_KEY["_default"]:
_LOGGER.debug("Processing binary sensor data_key: %s", data_key)
if data_key in coordinator_data:
_LOGGER.debug(
"Processing binary sensor data_key: %s from regParams & sysParams", data_key
)
if data_key in data_regParams:
entity = EconetBinarySensor(
create_binary_entity_description(data_key), coordinator, api
)
entities.append(entity)
_LOGGER.debug("Created and appended entity from regParams: %s", entity)
elif data_key in data_sysParams:
entity = EconetBinarySensor(
create_binary_entity_description(data_key), coordinator, api
)
entities.append(entity)
_LOGGER.debug("Created and appended entity: %s", entity)
_LOGGER.debug("Created and appended entity from sysParams: %s", entity)
else:
_LOGGER.warning(
"key: %s is not mapped, binary sensor entity will not be added",
"key: %s is not mapped in regParams, binary sensor entity will not be added",
data_key,
)
_LOGGER.info("Total entities created: %d", len(entities))
return entities


Expand Down
2 changes: 1 addition & 1 deletion custom_components/econet300/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async def _async_update_data(self):
try:
# Note: asyncio.TimeoutError and aiohttp.ClientError are already
# handled by the data update coordinator.
async with asyncio.timeout(10):
async with asyncio.timeout(20):
data = await self._api.fetch_sys_params()
reg_params = await self._api.fetch_reg_params()
params_edits = await self._api.fetch_param_edit_data()
Expand Down
Loading

0 comments on commit fab4477

Please sign in to comment.