75class Mqtt :
public ProtocolLayer {
80 void onInit()
override;
81 bool onLoadConfig()
override;
82 bool verifyConfig()
override;
83 bool isEnabled()
override;
86 bool isNetworkRestartRequested()
override;
87 uint32_t getConnectionFailTime()
override;
88 bool isConnectionError()
override;
89 bool isConnecting()
override;
90 void publish(
const char *topic,
94 bool ignorePrefix =
false);
95 void publishInt(
const char *topic,
99 void publishBool(
const char *topic,
103 void publishOnOff(
const char *topic,
bool payload,
int qos,
int retain);
104 void publishOpenClosed(
const char *topic,
bool payload,
int qos,
int retain);
105 void publishDouble(
const char *topic,
110 void publishColor(
const char *topic,
116 void publishChannelState(
int channel);
117 void publishExtendedChannelState(
int channel);
118 void subscribeChannel(
int channel);
119 void subscribe(
const char *topic,
int qos = -1);
120 bool isUpdatePending()
override;
121 bool isRegisteredAndReady()
override;
122 void notifyConfigChange(
int channelNumber)
override;
124 void sendActionTrigger(uint8_t channelNumber, uint32_t actionId)
override;
125 void sendChannelValueChanged(uint8_t channelNumber, int8_t *value,
126 unsigned char offline, uint32_t validityTimeSec)
override;
127 void sendExtendedChannelValueChanged(uint8_t channelNumber,
130 bool processData(
const char *topic,
const char *payload);
131 void processRelayRequest(
const char *topic,
134 void processRGBWRequest(
const char *topic,
137 void processRGBRequest(
const char *topic,
140 void processDimmerRequest(
const char *topic,
143 void processHVACRequest(
const char *topic,
146 void processRollerShutterRequest(
const char *topic,
151 void generateClientId(
char result[MQTT_CLIENTID_MAX_SIZE]);
152 void generateObjectId(
char result[30],
int channelNumber,
int subId);
153 MqttTopic getHADiscoveryTopic(
const char *sensor,
char *objectId);
154 void publishDeviceStatus(
bool onRegistration =
false);
155 void publishHADiscovery(
int channel);
172 void publishHADiscoveryEMParameter(
173 Supla::Element *element,
int parameterId,
const char *parameterName,
174 const char *units, Supla::Protocol::HAStateClass stateClass,
175 Supla::Protocol::HADeviceClass deviceClass);
176 const char *getActionTriggerType(uint8_t actionIdx);
177 bool isActionTriggerEnabled(
Supla::Channel *ch, uint8_t actionIdx);
178 virtual void publishImp(
const char *topic,
182 virtual void subscribeImp(
const char *topic,
int qos) = 0;
183 const char *getStateClassStr(Supla::Protocol::HAStateClass stateClass);
184 const char *getDeviceClassStr(Supla::Protocol::HADeviceClass deviceClass);
186 const char *getRelayChannelName(
int channelFunction)
const;
187 const char *getBinarySensorChannelName(
int channelFunction)
const;
189 bool isPayloadOn(
const char *);
190 bool isOpenClosedBinarySensorFunction(
int channelFunction)
const;
192 char server[SUPLA_SERVER_NAME_MAXSIZE] = {};
194 char user[MQTT_USERNAME_MAX_SIZE] = {};
195 char password[MQTT_PASSWORD_MAX_SIZE] = {};
196 char hostname[32] = {};
200 bool retainCfg =
false;
202 bool connecting =
false;
203 bool connected =
false;
205 char *prefix =
nullptr;
208 int channelsCount = 0;
215 int buttonNumber = 0;
216 uint8_t configChangedBit[8] = {};