Package dev.digiried.wattpilot
Class WattpilotClient
java.lang.Object
dev.digiried.wattpilot.WattpilotClient
Client for the Fronius Wattpilot wallbox.
- Author:
- Florian Hotze - Initial contribution
-
Constructor Summary
ConstructorsConstructorDescriptionWattpilotClient(org.eclipse.jetty.client.HttpClient httpClient) Create a new Fronius Wattpilot client using the givenHttpClient.WattpilotClient(org.eclipse.jetty.client.HttpClient httpClient, int pingInterval, int pingTimeout) Creates a new Fronius Wattpilot client using the givenHttpClientand the provided ping interval and timeout. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(WattpilotClientListener listener) Adds aWattpilotClientListenerto the client.Connect the client to the wallbox.Disconnect the client from the wallbox.Get theWattpilotInfoof the wallbox.Get the current status of the wallbox.booleanWhether the client is connected to the wallbox.voidremoveListener(WattpilotClientListener listener) Removes aWattpilotClientListenerfrom the client.sendCommand(Command command) Send aCommandto the wallbox and return aCompletableFuturethat will be completed when the response is received.
-
Constructor Details
-
WattpilotClient
public WattpilotClient(org.eclipse.jetty.client.HttpClient httpClient) Create a new Fronius Wattpilot client using the givenHttpClient.- Parameters:
httpClient- the HTTP client to use, allows configuring HTTP settings
-
WattpilotClient
public WattpilotClient(org.eclipse.jetty.client.HttpClient httpClient, int pingInterval, int pingTimeout) Creates a new Fronius Wattpilot client using the givenHttpClientand the provided ping interval and timeout.- Parameters:
httpClient- the HTTP client to use, allows configuring HTTP settingspingInterval- the ping intervalpingTimeout- the ping timeout, must be less thanpingInterval
-
-
Method Details
-
addListener
Adds aWattpilotClientListenerto the client.- Parameters:
listener- the listener to add
-
removeListener
Removes aWattpilotClientListenerfrom the client.- Parameters:
listener- the listener to remove
-
connect
Connect the client to the wallbox.Connection is established asynchronously. Either use the returned
CompletableFutureor implementWattpilotClientListener.connected()andWattpilotClientListener.disconnected(java.lang.String, java.lang.Throwable)to get notified about connection establishment or failure.- Parameters:
host- the hostname or IP address of the wallboxpassword- the password to authenticate with- Returns:
- future that completes once the client has successfully connected
- Throws:
IOException- if the synchronous preparations for the connection establishment fail
-
disconnect
Disconnect the client from the wallbox.This operation is idempotent, meaning it can be called multiple times without side effects.
- Returns:
- future that completes once the client has successfully disconnected
-
isConnected
public boolean isConnected()Whether the client is connected to the wallbox.- Returns:
- true if connected
-
getDeviceInfo
Get theWattpilotInfoof the wallbox.- Returns:
- the device info or
nullif not available yet
-
getStatus
Get the current status of the wallbox.- Returns:
- the current status or
nullif not available yet
-
sendCommand
Send aCommandto the wallbox and return aCompletableFuturethat will be completed when the response is received.- Parameters:
command- the command to send- Returns:
- a
CompletableFuturethat will be completed when the response is received, or completed exceptionally with anIOExceptionif the command could not be sent
-