[easee] Adjust configuration to new API limits (#18168)

* dedicated polling interval for session data

Signed-off-by: Alexander Friese <af944580@googlemail.com>
pull/18179/head
Alexander Friese 2025-01-24 21:13:54 +01:00 committed by GitHub
parent a1fd18e4e3
commit 00d15574db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 65 additions and 11 deletions

View File

@ -23,14 +23,15 @@ Auto-discovery is supported and will discover all circuits and chargers assigned
The following configuration parameters are available for the binding/bridge:
| Configuration Parameter | Required | Description |
|-------------------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| username | yes | The username to login at Easee Cloud service. This should be an e-mail address or phone number. |
| passord | yes | Your password to login at Easee Cloud service. |
| siteId | yes | The ID of the site containing the wallbox(es) and circuit(s) that should be integrated into openHAB. The ID of your site can be found via the sites overview (<https://easee.cloud/sites>). You just need to click one of the sites listed there, the id will be part of the URL which is then opened. It will be a number with typically 6 digits. |
| dataPollingInterval | no | Interval (seconds) in which live data values are retrieved from the Easee Cloud API. (default = 60) |
| webRequestInitialDelay | no | Initial time (seconds) to wait before first request is sent to the Easee Cloud API. (default = 10) |
| webRequestInterval | no | Interval (seconds) between two subsequent requests to be sent to the Easee Cloud API. (default = 2) |
| Configuration Parameter | Required | Description |
|------------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| username | yes | The username to login at Easee Cloud service. This should be an e-mail address or phone number. |
| passord | yes | Your password to login at Easee Cloud service. |
| siteId | yes | The ID of the site containing the wallbox(es) and circuit(s) that should be integrated into openHAB. The ID of your site can be found via the sites overview (<https://easee.cloud/sites>). You just need to click one of the sites listed there, the id will be part of the URL which is then opened. It will be a number with typically 6 digits. |
| dataPollingInterval | no | Interval (seconds) in which live data values are retrieved from the Easee Cloud API. (default = 60) |
| sessionDataPollingInterval | no | Interval (seconds) in which session data values are retrieved from the Easee Cloud API. (default = 360) |
| webRequestInitialDelay | no | Initial time (seconds) to wait before first request is sent to the Easee Cloud API. (default = 10) |
| webRequestInterval | no | Interval (seconds) between two subsequent requests to be sent to the Easee Cloud API. (default = 2) |
## Thing configuration

View File

@ -29,6 +29,7 @@ public class EaseeConfiguration {
private Integer asyncTimeout = 120;
private Integer syncTimeout = 120;
private Integer dataPollingInterval = 60;
private Integer sessionDataPollingInterval = 360;
private Integer webRequestInitialDelay = 10;
private Integer webRequestInterval = 2;
@ -80,6 +81,14 @@ public class EaseeConfiguration {
this.dataPollingInterval = dataPollingInterval;
}
public Integer getSessionDataPollingInterval() {
return sessionDataPollingInterval;
}
public void setSessionDataPollingInterval(Integer sessionDataPollingInterval) {
this.sessionDataPollingInterval = sessionDataPollingInterval;
}
public Integer getWebRequestInitialDelay() {
return webRequestInitialDelay;
}
@ -102,8 +111,9 @@ public class EaseeConfiguration {
builder.append("EaseeConfiguration [username=").append(username).append(", password=").append(password)
.append(", siteId=").append(siteId).append(", asyncTimeout=").append(asyncTimeout)
.append(", syncTimeout=").append(syncTimeout).append(", dataPollingInterval=")
.append(dataPollingInterval).append(", webRequestInitialDelay=").append(webRequestInitialDelay)
.append(", webRequestInterval=").append(webRequestInterval).append("]");
.append(dataPollingInterval).append(", sessionDataPollingInterval=").append(sessionDataPollingInterval)
.append(", webRequestInitialDelay=").append(webRequestInitialDelay).append(", webRequestInterval=")
.append(webRequestInterval).append("]");
return builder.toString();
}
}

View File

@ -62,10 +62,19 @@ public class EaseeChargerHandler extends BaseThingHandler implements EaseeThingH
* Schedule for polling live data
*/
private final AtomicReference<@Nullable Future<?>> dataPollingJobReference;
private final AtomicReference<@Nullable Future<?>> sessionDataPollingJobReference;
public EaseeChargerHandler(Thing thing) {
super(thing);
this.dataPollingJobReference = new AtomicReference<>(null);
this.sessionDataPollingJobReference = new AtomicReference<>(null);
}
void reInit() {
if (isInitialized()) {
dispose();
initialize();
}
}
@Override
@ -117,6 +126,9 @@ public class EaseeChargerHandler extends BaseThingHandler implements EaseeThingH
private void startPolling() {
updateJobReference(dataPollingJobReference, scheduler.scheduleWithFixedDelay(this::pollingRun,
POLLING_INITIAL_DELAY, getBridgeConfiguration().getDataPollingInterval(), TimeUnit.SECONDS));
updateJobReference(sessionDataPollingJobReference, scheduler.scheduleWithFixedDelay(this::sessionDataPollingRun,
POLLING_INITIAL_DELAY, getBridgeConfiguration().getSessionDataPollingInterval(), TimeUnit.SECONDS));
}
/**
@ -129,6 +141,18 @@ public class EaseeChargerHandler extends BaseThingHandler implements EaseeThingH
// proceed if charger is online
if (getThing().getStatus() == ThingStatus.ONLINE) {
enqueueCommand(new GetConfiguration(this, chargerId, this::updateOnlineStatus));
}
}
/**
* Poll the Easee Cloud API session data endpoint one time.
*/
void sessionDataPollingRun() {
String chargerId = getConfig().get(EaseeBindingConstants.THING_CONFIG_ID).toString();
logger.debug("polling session data for {}", chargerId);
// proceed if charger is online
if (getThing().getStatus() == ThingStatus.ONLINE) {
enqueueCommand(new LatestChargingSession(this, chargerId, this::updateOnlineStatus));
}
}
@ -175,6 +199,7 @@ public class EaseeChargerHandler extends BaseThingHandler implements EaseeThingH
public void dispose() {
logger.debug("Handler disposed.");
cancelJobReference(dataPollingJobReference);
cancelJobReference(sessionDataPollingJobReference);
}
/**

View File

@ -35,6 +35,7 @@ import org.openhab.binding.easee.internal.config.EaseeConfiguration;
import org.openhab.binding.easee.internal.connector.CommunicationStatus;
import org.openhab.binding.easee.internal.connector.WebInterface;
import org.openhab.binding.easee.internal.discovery.EaseeSiteDiscoveryService;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.config.discovery.DiscoveryService;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.ThingStatus;
@ -174,6 +175,15 @@ public class EaseeSiteHandler extends BaseBridgeHandler implements EaseeBridgeHa
webInterface.dispose();
}
@Override
protected void updateConfiguration(Configuration configuration) {
super.updateConfiguration(configuration);
getChildChargerHandlers().forEach((name, handler) -> {
logger.debug("notify {}: config update", name);
handler.reInit();
});
}
@Override
public EaseeConfiguration getBridgeConfiguration() {
return this.getConfigAs(EaseeConfiguration.class);

View File

@ -36,6 +36,12 @@
<description>Interval in which data is polled from EaseeCloud (in seconds).</description>
<default>60</default>
</parameter>
<parameter name="sessionDataPollingInterval" type="integer" required="false" min="60" max="1200" unit="s"
groupName="connection">
<label>Session Data Polling Interval</label>
<description>Interval in which session data is polled from EaseeCloud (in seconds).</description>
<default>360</default>
</parameter>
<parameter name="webRequestInitialDelay" type="integer" required="false" min="5" max="60" unit="s"
groupName="connection">
<label>Initial Web Request Delay</label>

View File

@ -30,6 +30,8 @@ thing-type.config.easee.site.group.general.label = General
thing-type.config.easee.site.group.general.description = General settings.
thing-type.config.easee.site.password.label = Password
thing-type.config.easee.site.password.description = Your password to login at Easee Cloud service.
thing-type.config.easee.site.sessionDataPollingInterval.label = Session Data Polling Interval
thing-type.config.easee.site.sessionDataPollingInterval.description = Interval in which session data is polled from EaseeCloud (in seconds).
thing-type.config.easee.site.siteId.label = Site ID
thing-type.config.easee.site.siteId.description = The ID of the site containing the charger(s) and circuit(s) that should be integrated into openHAB.
thing-type.config.easee.site.username.label = Username
@ -37,7 +39,7 @@ thing-type.config.easee.site.username.description = The username to login at Eas
thing-type.config.easee.site.webRequestInitialDelay.label = Initial Web Request Delay
thing-type.config.easee.site.webRequestInitialDelay.description = Initial time to wait before first request is sent to EaseeCloud (in seconds).
thing-type.config.easee.site.webRequestInterval.label = Web Request Interval
thing-type.config.easee.site.webRequestInterval.description = Interval between two subsequent requests are sent to EaseeCloud (in seconds).
thing-type.config.easee.site.webRequestInterval.description = Interval between two subsequent requests to be sent to EaseeCloud (in seconds).
# channel group types