HAScene class

class HAScene : public HABaseDeviceType

HAScene adds a new scene to the Home Assistant that triggers your callback once activated.

Note

You can find more information about this entity in the Home Assistant documentation: https://www.home-assistant.io/integrations/scene.mqtt/

Public Functions

HAScene(const char *uniqueId)
Parameters

uniqueId – The unique ID of the scene. It needs to be unique in a scope of your device.

inline void setIcon(const char *icon)

Sets icon of the scene. Any icon from MaterialDesignIcons.com (for example: mdi:home).

Parameters

icon – The icon name.

inline void setRetain(const bool retain)

Sets retain flag for the scene’s command. If set to true the command produced by Home Assistant will be retained.

Parameters

retain

inline void onCommand(void (*callback)(HAScene *sender))

Registers callback that will be called when the scene is activated in the HA panel. Please note that it’s not possible to register multiple callbacks for the same scene.

Parameters

callback

Protected Functions

virtual void buildSerializer() override
virtual void onMqttConnected() override
virtual void onMqttMessage(const char *topic, const uint8_t *payload, const uint16_t length) override

Private Members

const char *_icon

The icon of the scene. It can be nullptr.

bool _retain

The retain flag for the HA commands.

void (*_commandCallback)(HAScene *sender)

The command callback that will be called when scene is activated from the HA panel.