-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[solax] Cloud connection support (#16124)
* Initial rearrangement of classes and cloud response in test Signed-off-by: Konstantin Polihronov <polychronov@gmail.com>
- Loading branch information
Showing
31 changed files
with
1,590 additions
and
228 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
59 changes: 59 additions & 0 deletions
59
...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,59 @@ | ||
/** | ||
* 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 = "application/json; charset=utf-8"; | ||
|
||
private final Logger logger = LoggerFactory.getLogger(CloudHttpConnector.class); | ||
|
||
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("{tokenId}", tokenId).replace("{serialNumber}", serialNumber).trim(); | ||
} | ||
|
||
@Override | ||
public @Nullable String retrieveData() throws IOException { | ||
logger.debug("About to retrieve data from 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.