kotlin-homie / org.homieiot.mqtt / HomieMqttClient

HomieMqttClient

class HomieMqttClient

Creates a Homie MQTT client for the supplied org.homieiot.Device

Parameters

serverURI - in the format of tcp://host:port for the MQTT Broker to connect

clientID - Supplied MQTT Client ID

username - Optional username to connect to MQTT

password - Optional password to connect to MQTT

Constructors

<init>

HomieMqttClient(serverURI: String, clientID: String, username: String? = null, password: String? = null, homieRoot: String = "homie", device: Device)

Creates a Homie MQTT client for the supplied org.homieiot.Device

Functions

connect

fun connect(): Future<Any>

Connect client to MQTT library

disconnect

fun disconnect(): Unit

Disconnect MQTT Client

Companion Object Functions

fromEnv

fun fromEnv(device: Device): HomieMqttClient

Creates a new HomieMqttClient for the device default environment variables The environment must contain an MQTT_SERVER URI in format of tcp://host:port and an MQTT_CLIENT_ID variable Additionally, the method supports extracting the MQTT_USERNAME and MQTT_PASSWORD environment variables