add possible fix for 500 Internal Server Error
Signed-off-by: Laurent ARNAL <laurent@clae.net>
parent
40202b1641
commit
cd8015d8f3
|
@ -90,10 +90,16 @@ public class EnedisHttpApi {
|
|||
this.config = config;
|
||||
}
|
||||
|
||||
public void removeAllCookie() {
|
||||
httpClient.getCookieStore().removeAll();
|
||||
}
|
||||
|
||||
public void initialize() throws LinkyException {
|
||||
logger.debug("Starting login process for user: {}", config.username);
|
||||
|
||||
try {
|
||||
removeAllCookie();
|
||||
|
||||
addCookie(LinkyConfiguration.INTERNAL_AUTH_ID, config.internalAuthId);
|
||||
logger.debug("Step 1: getting authentification");
|
||||
String data = getContent(URL_ENEDIS_AUTHENTICATE);
|
||||
|
|
|
@ -180,19 +180,6 @@ public class LinkyHandler extends BaseThingHandler {
|
|||
api.initialize();
|
||||
updateStatus(ThingStatus.ONLINE);
|
||||
|
||||
if (thing.getProperties().isEmpty()) {
|
||||
UserInfo userInfo = api.getUserInfo();
|
||||
PrmInfo prmInfo = api.getPrmInfo(userInfo.userProperties.internId);
|
||||
PrmDetail details = api.getPrmDetails(userInfo.userProperties.internId, prmInfo.idPrm);
|
||||
updateProperties(Map.of(USER_ID, userInfo.userProperties.internId, PUISSANCE,
|
||||
details.situationContractuelleDtos[0].structureTarifaire().puissanceSouscrite().valeur()
|
||||
+ " kVA",
|
||||
PRM_ID, prmInfo.idPrm));
|
||||
}
|
||||
|
||||
prmId = thing.getProperties().get(PRM_ID);
|
||||
userId = thing.getProperties().get(USER_ID);
|
||||
|
||||
updateData();
|
||||
|
||||
disconnect();
|
||||
|
@ -214,11 +201,31 @@ public class LinkyHandler extends BaseThingHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private synchronized void updateMetaData() throws LinkyException {
|
||||
EnedisHttpApi api = this.enedisApi;
|
||||
if (api != null) {
|
||||
if (thing.getProperties().isEmpty()) {
|
||||
UserInfo userInfo = api.getUserInfo();
|
||||
PrmInfo prmInfo = api.getPrmInfo(userInfo.userProperties.internId);
|
||||
PrmDetail details = api.getPrmDetails(userInfo.userProperties.internId, prmInfo.idPrm);
|
||||
updateProperties(Map.of(USER_ID, userInfo.userProperties.internId, PUISSANCE,
|
||||
details.situationContractuelleDtos[0].structureTarifaire().puissanceSouscrite().valeur()
|
||||
+ " kVA",
|
||||
PRM_ID, prmInfo.idPrm));
|
||||
}
|
||||
|
||||
prmId = thing.getProperties().get(PRM_ID);
|
||||
userId = thing.getProperties().get(USER_ID);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request new data and updates channels
|
||||
*/
|
||||
private synchronized void updateData() {
|
||||
boolean connectedBefore = isConnected();
|
||||
try {
|
||||
updateMetaData();
|
||||
updatePowerData();
|
||||
updateDailyWeeklyData();
|
||||
updateMonthlyData();
|
||||
|
@ -226,6 +233,10 @@ public class LinkyHandler extends BaseThingHandler {
|
|||
if (!connectedBefore && isConnected()) {
|
||||
disconnect();
|
||||
}
|
||||
} catch (LinkyException e) {
|
||||
logger.error("Exception occurs during data update", e);
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void updatePowerData() {
|
||||
|
|
Loading…
Reference in New Issue