Skip to content

Commit

Permalink
Added generate test data service
Browse files Browse the repository at this point in the history
  • Loading branch information
signalkraft committed Dec 29, 2023
1 parent dd65147 commit 78bda1d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ repos:
- aioresponses
- pytest
- types-requests
- myPyllant==0.6.4
- myPyllant==0.6.5
- polyfactory
- repo: local
hooks:
Expand Down
27 changes: 25 additions & 2 deletions custom_components/mypyllant/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -26,6 +32,7 @@
OPTION_REFRESH_DELAY,
OPTION_UPDATE_INTERVAL,
QUOTA_PAUSE_INTERVAL,
SERVICE_GENERATE_TEST_DATA,
)
from .utils import is_quota_exceeded_exception

Expand Down Expand Up @@ -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


Expand Down
1 change: 1 addition & 0 deletions custom_components/mypyllant/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion custom_components/mypyllant/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 78bda1d

Please sign in to comment.