Skip to content
This repository was archived by the owner on Aug 15, 2024. It is now read-only.

Commit 6e76f43

Browse files
authored
Merge pull request #153 from oischinger/premium_subscription
Increase update rate for premium subscription
2 parents b52970a + e52bbf0 commit 6e76f43

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

custom_components/vicare/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@
2323
from homeassistant.helpers import entity_registry as er
2424
from homeassistant.helpers.storage import STORAGE_DIR
2525

26-
from .const import DEFAULT_SCAN_INTERVAL, DOMAIN, PLATFORMS, VICARE_DEVICE_CONFIG
26+
from .const import (
27+
CONF_PREMIUM,
28+
DEFAULT_SCAN_INTERVAL,
29+
DOMAIN,
30+
PLATFORMS,
31+
VICARE_DEVICE_CONFIG,
32+
)
2733
from .helpers import get_unique_device_id
2834

2935
_LOGGER = logging.getLogger(__name__)
@@ -147,6 +153,10 @@ def setup_vicare_api(hass, entry):
147153
vicare_api = vicare_login(hass, entry.data)
148154
scan_interval = max(DEFAULT_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL * len(vicare_api.devices))
149155

156+
# Premium subscription allows 3000 vs 1450 API calls per day
157+
if CONF_PREMIUM in entry.data and entry.data[CONF_PREMIUM]:
158+
scan_interval = scan_interval/2
159+
150160
_LOGGER.info(
151161
"Setting up API with scan interval %i seconds.", scan_interval
152162
)

custom_components/vicare/config_flow.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from homeassistant.helpers.device_registry import format_mac
2121

2222
from . import vicare_login
23-
from .const import DOMAIN, VICARE_NAME
23+
from .const import CONF_PREMIUM, DOMAIN, VICARE_NAME
2424

2525
_LOGGER = logging.getLogger(__name__)
2626

@@ -41,6 +41,7 @@ async def async_step_user(
4141
vol.Required(CONF_USERNAME): cv.string,
4242
vol.Required(CONF_PASSWORD): cv.string,
4343
vol.Required(CONF_CLIENT_ID): cv.string,
44+
vol.Optional(CONF_PREMIUM): cv.boolean,
4445
}
4546
errors: dict[str, str] = {}
4647
description_placeholders: dict[str, str] = {}

custom_components/vicare/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
CONF_CIRCUIT = "circuit"
2222

2323
DEFAULT_SCAN_INTERVAL = 60
24+
CONF_PREMIUM = "subscription_premium"
2425

2526
VICARE_CUBIC_METER = "cubicMeter"
2627
VICARE_KWH = "kilowattHour"

custom_components/vicare/strings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"username": "[%key:common::config_flow::data::email%]",
99
"password": "[%key:common::config_flow::data::password%]",
1010
"client_id": "[%key:common::config_flow::data::api_key%]",
11+
"subscription_premium": "Premium subscription (3000 API calls/day)",
1112
"heating_type": "Heating type"
1213
}
1314
}

custom_components/vicare/translations/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"client_id": "API Key",
1818
"heating_type": "Heating type",
1919
"password": "Password",
20-
"username": "Email"
20+
"username": "Email",
21+
"subscription_premium": "Premium subscription (3000 API calls/day)"
2122
},
2223
"description": "Set up ViCare integration. To generate API key go to https://developer.viessmann.com"
2324
}

0 commit comments

Comments
 (0)