Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/teverett/hsclient
A Java API Client for the HomeSeer JSON API
https://github.com/teverett/hsclient
api-client homeseer iot java
Last synced: 24 days ago
JSON representation
A Java API Client for the HomeSeer JSON API
- Host: GitHub
- URL: https://github.com/teverett/hsclient
- Owner: teverett
- License: bsd-3-clause
- Created: 2019-12-30T20:53:50.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-13T20:41:15.000Z (10 months ago)
- Last Synced: 2024-01-14T05:54:24.160Z (10 months ago)
- Topics: api-client, homeseer, iot, java
- Language: Java
- Homepage:
- Size: 288 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![CI](https://github.com/teverett/hsclient/workflows/CI/badge.svg)
# HomeSeer Java Client
A Java client for the HomeSeer JSON API.
The java interface API for hsClient is here [HSClient.java](https://github.com/teverett/hsclient/blob/master/src/main/java/com/khubla/hsclient/HSClient.java)
Versions 1.12+ of hsClient also have client support for the Z-Wave plugin API [here](https://github.com/teverett/hsclient/blob/master/src/main/java/com/khubla/hsclient/plugins/zwave/ZWavePlugin.java)
The client was built based on [this pdf](https://homeseer.com/support/homeseer/HS3/hs3sdk.pdf) and [this documentation](https://docs.homeseer.com/display/HSPI/JSON+API)
HomeSeer versions hsClient was tested against include:
* HS4 version 4.1.2.0+
* HS3 Pro (SEL) Edition 3.0.0.548
* HS3 Pro (SEL) Edition 3.0.0.550hsClient is one of numerous HomeSeer support applications created by khubla.com, including
* [hsClient](https://github.com/teverett/hsclient)
* [hsInflux](https://github.com/teverett/hsinflux)
* [hsMQTT](https://github.com/teverett/hsOpenAPI)
* [hsOpenAPI](https://github.com/teverett/hsOpenAPI)## License
hsclient is distributed under the BSD 3-Clause License.
## Maven coordinates
```
com.khubla.hsclient
hsclient
1.17```
## Usage
Simply instantiate an [HSClient](https://github.com/teverett/hsclient/blob/master/src/main/java/com/khubla/hsclient/HSClient.java) and call the API methods
To get all Devices:
```java
final HSClient hsClient = new HSClientImpl();
hsclient.connect(URL, USERNAME, PASSWORD);
try {
final Map allDevices = hsClient.getDevicesByRef();
} finally {
hsClient.close();
}
```To get all Events:
```java
HSConfiguration hsConfiguration = new HSConfiguration(URL, USERNAME, PASSWORD);
final HSClient hsClient = new HSClientImpl();
hsclient.connect(hsConfiguration);
try {
final Map allEvents = hsClient.getEventsById();
} finally {
hsClient.close();
}
```To get a single Device:
```java
HSConfiguration hsConfiguration = new HSConfiguration(URL, USERNAME, PASSWORD);
final HSClient hsClient = new HSClientImpl();
hsclient.connect(hsConfiguration);
try {
final Device device = hsClient.getDevice(DEVICEREF);
} finally {
hsClient.close();
}
```### Using the poller
hsClient includes a multithreaded poller which calls a callback interface. To use the poller, provide an implementation of `DataPointCallback` to the class `Poller`.
In hsClient V1.13+, the poller uses the "getdeviceschanged" API for more efficient polling. The poller can be configured to only send data when device values change, or can be configured to send data for all devices on every polling cycle.
Example polling:
```java
HSConfiguration hsConfiguration = new HSConfiguration(URL, USERNAME, PASSWORD);
Poller poller = new Poller(hsConfiguration, POLLINTERVAL_MS, MY_DATAPOINTCALLBACK, THREADCOUNT, true);
poller.run();
```