diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6d78690..62b52d8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,7 +34,7 @@ repos: - aioresponses - pytest - types-requests - - myPyllant==0.6.4 + - myPyllant==0.6.5 - polyfactory - repo: local hooks: diff --git a/custom_components/mypyllant/__init__.py b/custom_components/mypyllant/__init__.py index 2c4f9b3..82389fe 100644 --- a/custom_components/mypyllant/__init__.py +++ b/custom_components/mypyllant/__init__.py @@ -9,12 +9,18 @@ from aiohttp.client_exceptions import ClientResponseError from homeassistant.config_entries import ConfigEntry from homeassistant.const import Platform -from homeassistant.core import HomeAssistant +from homeassistant.core import ( + HomeAssistant, + SupportsResponse, + ServiceCall, + ServiceResponse, +) from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed + from myPyllant.api import MyPyllantAPI from myPyllant.const import DEFAULT_BRAND from myPyllant.models import DeviceData, DeviceDataBucketResolution, System - +from myPyllant.tests import generate_test_data from .const import ( API_DOWN_PAUSE_INTERVAL, DEFAULT_COUNTRY, @@ -26,6 +32,7 @@ OPTION_REFRESH_DELAY, OPTION_UPDATE_INTERVAL, QUOTA_PAUSE_INTERVAL, + SERVICE_GENERATE_TEST_DATA, ) from .utils import is_quota_exceeded_exception @@ -85,6 +92,22 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: hass.data[DOMAIN][entry.entry_id]["daily_data_coordinator"] = daily_data_coordinator await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) + + async def handle_generate_test_data(call: ServiceCall) -> ServiceResponse: + return await generate_test_data.main( + user=username, + password=password, + brand=brand, + country=country, + write_results=False, + ) + + hass.services.async_register( + DOMAIN, + SERVICE_GENERATE_TEST_DATA, + handle_generate_test_data, + supports_response=SupportsResponse.ONLY, + ) return True diff --git a/custom_components/mypyllant/const.py b/custom_components/mypyllant/const.py index 2b3f3b7..35ad25e 100644 --- a/custom_components/mypyllant/const.py +++ b/custom_components/mypyllant/const.py @@ -22,3 +22,4 @@ SERVICE_SET_DHW_TIME_PROGRAM = "set_dhw_time_program" SERVICE_SET_DHW_CIRCULATION_TIME_PROGRAM = "set_dhw_circulation_time_program" SERVICE_SET_VENTILATION_FAN_STAGE = "set_ventilation_fan_stage" +SERVICE_GENERATE_TEST_DATA = "generate_test_data" diff --git a/custom_components/mypyllant/manifest.json b/custom_components/mypyllant/manifest.json index 57110c2..fb3a3b4 100644 --- a/custom_components/mypyllant/manifest.json +++ b/custom_components/mypyllant/manifest.json @@ -7,6 +7,6 @@ "integration_type": "hub", "iot_class": "cloud_polling", "issue_tracker": "https://github.com/signalkraft/mypyllant-component/issues", - "requirements": ["myPyllant==0.6.4"], + "requirements": ["myPyllant==0.6.5"], "version": "v0.6.1" } diff --git a/dev-requirements.txt b/dev-requirements.txt index e311665..699ff39 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -13,5 +13,5 @@ ruff~=0.1.9 pytest==7.4.3 pytest-cov==4.1.0 pytest-homeassistant-custom-component==0.13.77 -myPyllant==0.6.4 +myPyllant==0.6.5 dacite~=1.7.0 \ No newline at end of file