forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial rearrangement of classes and cloud response in test * Refactoring of packages and initial version of retrieval of data * Test for parsed raw data * Move the enums for status and type to the root model package * Another package refactoring + basic handler functionality * Handler works now, most build warnings removed * Add initial exception handling during the update * Small code style fixes and channel for inverter status * Add all defined channels from the XML in the handler * Add translations of the status and support for zones and I18N * Update readme * Fix error handling in the Cloud connection handler * Manual fixes openhab#16249 and openhab#16214 due to refactored packages and classes * Fix the headers for the new / refactored / moved classes for 2024 Signed-off-by: Konstantin Polihronov <[email protected]>
- Loading branch information
Showing
31 changed files
with
1,553 additions
and
224 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...lax/src/main/java/org/openhab/binding/solax/internal/connectivity/CloudHttpConnector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* Copyright (c) 2010-2024 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.solax.internal.connectivity; | ||
|
||
import java.io.IOException; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
import org.eclipse.jetty.http.HttpMethod; | ||
import org.openhab.core.io.net.http.HttpUtil; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* The {@link CloudHttpConnector} class uses HttpUtil to retrieve the raw JSON data from Inverter's Wi-Fi module. | ||
* | ||
* @author Konstantin Polihronov - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class CloudHttpConnector implements SolaxConnector { | ||
|
||
private static final int HTTP_REQUEST_TIME_OUT = 5000; | ||
|
||
// private static final String CONTENT_TYPE = "text/html; charset=utf-8"; | ||
private static final String CONTENT_TYPE = "application/json; charset=utf-8"; | ||
|
||
private final Logger logger = LoggerFactory.getLogger(CloudHttpConnector.class); | ||
|
||
private static final String TOKEN_ID_REPLACEMENT_PATTERN = "{tokenId}"; | ||
// The serial number of the Wifi dongle is the password for the connection (default) | ||
private static final String SERIAL_NUMBER_REPLACEMENT_PATTERN = "{serialNumber}"; | ||
private static final String URI = """ | ||
https://www.solaxcloud.com/proxyApp/proxy/api/getRealtimeInfo.do?tokenId={tokenId}&sn={serialNumber} | ||
"""; | ||
|
||
private String uri; | ||
|
||
public CloudHttpConnector(String tokenId, String serialNumber) { | ||
this(URI, tokenId, serialNumber); | ||
} | ||
|
||
public CloudHttpConnector(String uri, String tokenId, String serialNumber) { | ||
this.uri = uri.replace(TOKEN_ID_REPLACEMENT_PATTERN, tokenId) | ||
.replace(SERIAL_NUMBER_REPLACEMENT_PATTERN, serialNumber).trim(); | ||
} | ||
|
||
@Override | ||
public @Nullable String retrieveData() throws IOException { | ||
logger.trace("Uri: {}", uri); | ||
String result = HttpUtil.executeUrl(HttpMethod.GET.name(), uri, null, CONTENT_TYPE, HTTP_REQUEST_TIME_OUT); | ||
logger.trace("Retrieved content = {}", result); | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,6 @@ | |
public interface RawDataBean { | ||
@Nullable | ||
String getRawData(); | ||
|
||
public void setRawData(String rawData); | ||
} |
Oops, something went wrong.