Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #91

Closed
wants to merge 17 commits into from
Closed

Dev #91

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ body:
attributes:
value: |
## Environment
- type: checkboxes
id: checkboxes-3
attributes:
label: Connected devices
description: I have the following devices connected. For more information, see
[ecoNET300_DTR_1.0_ENG](https://thermostahl.ro/wp-content/uploads/2020/08/ecoNET300_DTR_1.0_ENG.pdf)
options:
- ecoMAX800 series
- ecoMAX850 series
- ecoMAX860 series
- ecoSTER
- ecoNET 300
- type: input
id: econet300_version
validations:
Expand Down
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,12 @@
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"cSpell.words": [
"aiohttp",
"econet",
"hass",
"homeassistant",
"MILLIWATT",
"PARAMSUNITSNAMES"
],
}
41 changes: 40 additions & 1 deletion custom_components/econet300/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
API_EDITABLE_PARAMS_LIMITS_URI,
API_REG_PARAMS_DATA_PARAM_DATA,
API_REG_PARAMS_DATA_URI,
API_REG_PARAMS_PARAM_DATA,
API_REG_PARAMS_URI,
API_SYS_PARAMS_PARAM_HW_VER,
API_SYS_PARAMS_PARAM_MODEL_ID,
API_SYS_PARAMS_PARAM_SW_REV,
Expand Down Expand Up @@ -204,7 +206,7 @@ def hw_ver(self) -> str:
return self._hw_version

async def init(self):
"""Econet300 Api initilization."""
"""Econet300 Api initialization."""
sys_params = await self._client.get_params(API_SYS_PARAMS_URI)

if API_SYS_PARAMS_PARAM_UID not in sys_params:
Expand Down Expand Up @@ -323,6 +325,43 @@ async def _fetch_reg_key(self, reg, data_key: str | None = None):

return data[data_key]

async def fetch_reg_params(self) -> dict[str, Any]:
"""Fetch and return the regParam data from ip/econet/regParams endpoint."""
_LOGGER.info("Calling fetch_reg_params method")
regParams = await self._fetch_reg_names(
API_REG_PARAMS_URI, API_REG_PARAMS_PARAM_DATA
)
_LOGGER.debug("Fetched regParams data: %s", regParams)

if API_REG_PARAMS_PARAM_DATA in regParams:
_LOGGER.info(
"Response contains expected keys. API_REG_PARAMS_PARAM_DATA: %s",
regParams[API_REG_PARAMS_PARAM_DATA],
)
else:
_LOGGER.warning(
"Response does not contain expected keys. API_REG_PARAMS_PARAM_DATA is missing."
)
_LOGGER.debug("Full response data: %s", regParams)

return regParams

async def _fetch_reg_names(self, reg, data_key_key_name: str | None = None):
"""Fetch a key from the json-encoded data returned by the API for a given registry If key is None, then return whole data."""
data = await self._client.get_params(reg)

if data is None:
raise DataError(f"Data fetched by API for reg: {reg} is None")

if data_key_key_name is None:
return data

if data_key_key_name not in data:
_LOGGER.debug(data)
raise DataError(f"Data for key: {data_key_key_name} does not exist")

return data[data_key_key_name]


async def make_api(hass: HomeAssistant, cache: MemCache, data: dict):
"""Create api object."""
Expand Down
5 changes: 4 additions & 1 deletion custom_components/econet300/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Common code for econet300 integration."""

import asyncio
from datetime import timedelta
import logging
Expand Down Expand Up @@ -43,7 +44,9 @@ async def _async_update_data(self):
# Note: asyncio.TimeoutError and aiohttp.ClientError are already
# handled by the data update coordinator.
async with asyncio.timeout(10):
return await self._api.fetch_data()
data = await self._api.fetch_data()
Copy link

Choose a reason for hiding this comment

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

Not good here u should return collection data or even better data concatination

reg_params = await self._api.fetch_reg_params()
return data, reg_params
except AuthError as err:
raise ConfigEntryAuthFailed from err
except ApiError as err:
Expand Down
4 changes: 2 additions & 2 deletions custom_components/econet300/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@
## Map names for params data in API_REG_PARAMS_DATA_URI
API_RM_CURRENT_DATA_PARAMS_URI = "rmCurrentDataParams"

## Mapunits for params data map API_RM_CURRENT_DATA_PARAMS_URI
## Map units for params data map API_RM_CURRENT_DATA_PARAMS_URI
API_RM_PARAMSUNITSNAMES_URI = "rmParamsUnitsNames"

# Boiler staus keys map
# Boiler status keys map
# boiler mode names from endpoint http://LocalIP/econet/rmParamsEnums?
OPERATION_MODE_NAMES = {
0: STATE_OFF,
Expand Down
3 changes: 2 additions & 1 deletion custom_components/econet300/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,5 @@ async def async_setup_entry(
entities.extend(create_controller_sensors(coordinator, api))
entities.extend(create_mixer_sensors(coordinator, api))

return async_add_entities(entities)
async_add_entities(entities)
return True
4 changes: 2 additions & 2 deletions custom_components/econet300/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"name": "Fan"
},
"aditional_feeder": {
"name": "Aditional feeder"
"name": "Additional feeder"
},
"pump_fireplace_works": {
"name": "Boiler Pump"
Expand Down Expand Up @@ -139,7 +139,7 @@
"name": "Mixer 1 servo position"
},
"status_wifi": {
"name": "Wireless network connected"
"name": "Wi-Fi"
},
"temp_co": {
"name": "Heating temperature"
Expand Down
4 changes: 2 additions & 2 deletions custom_components/econet300/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"name": "Fan"
},
"aditional_feeder": {
"name": "Aditional feeder"
"name": "Additional feeder"
},
"pump_fireplace_works": {
"name": "Boiler Pump"
Expand Down Expand Up @@ -139,7 +139,7 @@
"name": "Mixer 1 servo position"
},
"status_wifi": {
"name": "Wireless network connected"
"name": "Wi-Fi"
},
"temp_co": {
"name": "Heating temperature"
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
colorlog==6.8.2
homeassistant>=2024.9.2
ruff==0.6.5
ruff==0.7.2
codespell==2.3.0
2 changes: 1 addition & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
colorlog==6.7.0
homeassistant>=2024.3.0
ruff==0.6.8
ruff==0.7.2
codespell==2.3.0
1 change: 0 additions & 1 deletion tests/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion tests/common.py

This file was deleted.

95 changes: 95 additions & 0 deletions tests/fixtures/SControl MK1/regParams.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"settingsVer": 255531,
"editableParamsVer": 46,
"schedulesVer": 64806,
"remoteMenuVer": {},
"currentDataParamsEditsVer": 3,
"curr": {
"thermostat": 0,
"totalGain": 148327.40625,
"pumpCOWorks": true,
"fan2Exhaust": false,
"feederWorks": false,
"feeder": false,
"ecoSterMode2": 2,
"ecoSterMode3": 255,
"ecoSterContacts2": false,
"ecoSterMode1": 2,
"mixerPumpWorks4": false,
"mixerPumpWorks5": false,
"lambdaSet": 255,
"ecoSterContacts1": false,
"mixerPumpWorks2": false,
"ecoSterContacts3": false,
"contactGZCActive": false,
"fuelLevel": 12,
"tempOpticalSensor": 2.8025969286496341e-45,
"fanPower": 0.0,
"tempCOSet": 65,
"tempBack": 30.560226440429688,
"mixerTemp1": 31.992202758789062,
"mixerTemp3": null,
"mixerTemp2": null,
"mixerTemp5": null,
"mixerTemp4": null,
"blowFan1Active": false,
"statusCO": 2,
"boilerPower": 0,
"feederOuter": false,
"pumpCWUWorks": false,
"pumpCWU": true,
"alarmOutput": false,
"fan": false,
"lighter": false,
"lambdaStatus": 0,
"transmission": 12,
"fuelStream": 0.0,
"lighterWorks": false,
"mode": 5,
"alarmOutputWorks": false,
"feederOuterWorks": false,
"lambdaLevel": 211,
"tempExternalSensor": 7.1714935302734375,
"ecoSterTemp3": null,
"ecoSterTemp2": 23.559999465942383,
"ecoSterTemp1": 21.84178352355957,
"ecoSterNumber": 3,
"contactGZC": false,
"blowFan1": false,
"blowFan2": false,
"tempCO": 34.062744140625,
"pumpCO": true,
"mixerPumpWorks1": true,
"statusCWU": 0,
"pumpCirculation": false,
"ecoSterDaySched1": false,
"ecoSterDaySched2": false,
"ecoSterDaySched3": false,
"mixerPumpWorks3": false,
"outerBoilerWorks": false,
"pumpFireplace": false,
"pumpSolar": false,
"mixerSetTemp4": 32,
"mixerSetTemp5": 32,
"feeder2AdditionalWorks": false,
"pumpSolarWorks": false,
"mixerSetTemp1": 45,
"mixerSetTemp2": 32,
"mixerSetTemp3": 32,
"ecoSterSetTemp1": 20.700000762939453,
"blowFan2Active": false,
"tempCWU": 43.525177001953125,
"boilerPowerKW": 0.0,
"tempCWUSet": 50,
"pumpCirculationWorks": false,
"outerBoiler": false,
"tempFlueGas": 28.7421875,
"fan2ExhaustWorks": false,
"pumpFireplaceWorks": false,
"tempFeeder": 19.111846923828125,
"fanWorks": false,
"ecoSterSetTemp2": 23.100000381469727,
"ecoSterSetTemp3": null,
"feeder2Additional": false
}
}
Loading
Loading