Class AbstractKobotEntity

  • All Implemented Interfaces:
    crackers.kobots.mqtt.homeassistant.KobotHAEntity , kotlin.Comparable

    
    public abstract class AbstractKobotEntity
     implements KobotHAEntity
                        

    Abstraction for common attributes and methods for all Kobot entities for integration with Home Assistant via MQTT. Because its part of this package, it assumes usage of the mqttClient singleton.

    Devices and entities may be removed from HomeAssistant at any time, so the discovery message is sent on every connection. Birth and last-will messages, and retention flags are not used because the client can be used for other things besides HA and it assumes these devices are "smart enough" to

    Note the uniqueId and name properties are the name of the entity, not the device (see DeviceIdentifier -- a device may have several entities). The entityId in Home Assistant will be constructed from the component, uniqueId, and name -- e.g. light.sparkle_night_light.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      String getIcon() The icon HA will use to display this entity.
      String getStatusTopic() The MQTT topic for the devices state (send).
      final String getUniqueId() The unique ID of the device.
      final String getName() The friendly name of the device.
      final DeviceIdentifier getDeviceIdentifier() More detailed information about the device.
      JSONObject discovery() A generic configuration for the device, which can be used to generate the discovery message because there are too many "base" configuration parameters to be able to handle them cleanly, so just dump it on the child class to figure it out.
      <Error class: unknown class> start()
      Unit sendCurrentState(String state) Send the current state message for this device, if HA is available.
      Unit remove() Removes the entity from HA: sends an empty configuration, if HA is available.
      • Methods inherited from class crackers.kobots.mqtt.homeassistant.KobotHAEntity

        compareTo, currentState, getComponent
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getIcon

         String getIcon()

        The icon HA will use to display this entity.

      • getStatusTopic

         String getStatusTopic()

        The MQTT topic for the devices state (send). Allows for over-rides.

      • getUniqueId

         final String getUniqueId()

        The unique ID of the device. NOTE If this is not unique across all devices, then HomeAssistant will throw an error on discovery, but it wont be seen here.

      • getName

         final String getName()

        The friendly name of the device. This may be renamed in the HomeAssistant UI.

      • discovery

         JSONObject discovery()

        A generic configuration for the device, which can be used to generate the discovery message because there are too many "base" configuration parameters to be able to handle them cleanly, so just dump it on the child class to figure it out.

      • start

         <Error class: unknown class> start()
      • sendCurrentState

         Unit sendCurrentState(String state)

        Send the current state message for this device, if HA is available. This is a public method so that it can be triggered externally, such as in the case of effects running.

      • remove

         Unit remove()

        Removes the entity from HA: sends an empty configuration, if HA is available. Note that this will disable this entity from further use, although any topic subscriptions are still active.