gardena-api-client
v1.0.1
Published
Queries the dynamic websocket URL of Gardena Smart Garden API for device status updates
Maintainers
Readme
gardena-api-client
Queries Gardena Smart Garden API for status updates on your Smart Gardening devices. To do so the client determines the dynamically generated websocket URL based on your API key and login credentials.
Remarks
The client automatically recovers from connection or network loss. In case you change your login credentials of the Gardena cloud or change the API key you have to adapt your local configuration (see usage examples below).
Prerequisites
You need your login (username and password) for your Gardena System to create an API key here: GARDENA Smart System API
Usage
Quickstart
import * as gardena from 'gardena-api-client'
const options = {
username: "[email protected]",
password: "pa$$w0rd",
apikey: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
log: (entry) => console.log(entry),
callback: (message) => console.log(message)
}
gardena.connect(options)Details
Once installed and imported simply call the connect(options) and hand in the configuration object.
const options = { }username[text]: Login to Gardena cloud (your e-mail address)password[text]: Password for Gardena cloud loginapikey[text]: API key from GARDENA Smart System APIlog[function]: Callback function for log messagescallback[function]: Callback function for Gardena device updates
Callback Examples
import * as gardena from 'gardena-api-client'
const options = {
username: "[email protected]",
password: "pa$$w0rd",
apikey: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
log: onLog,
callback: onMessage
}
/**
* Called when Gardena client generates a log message
* @param {string} data Log message as string
*/
let onLog = (data) => console.log(data)
/**
* Called when a Gardena device updates a status
* @param {string} message JSON as plain text.
*/
let onMessage = (message) => {
let json = JSON.parse(message)
console.log(JSON.stringify(json))
}
gardena.connect(options)