79class Mqtt :
public ProtocolLayer {
84 void onInit()
override;
85 bool onLoadConfig()
override;
86 bool verifyConfig()
override;
87 bool isEnabled()
override;
90 bool isNetworkRestartRequested()
override;
91 uint32_t getConnectionFailTime()
override;
92 bool isConnectionError()
override;
93 bool isConnecting()
override;
94 bool isMqtt()
const override;
95 void publish(
const char *topic,
99 bool ignorePrefix =
false);
100 void publishInt(
const char *topic,
104 void publishBool(
const char *topic,
108 void publishOnOff(
const char *topic,
bool payload,
int qos,
int retain);
109 void publishOpenClosed(
const char *topic,
bool payload,
int qos,
int retain);
110 void publishDouble(
const char *topic,
115 void publishColor(
const char *topic,
121 void publishChannelState(
int channel);
122 void publishExtendedChannelState(
int channel);
123 void subscribeChannel(
int channel);
124 const char *getPrefix()
const;
125 const char *getHostname()
const;
126 void subscribe(
const char *topic,
int qos = -1);
127 bool isUpdatePending()
override;
128 bool isRegisteredAndReady()
override;
129 void notifyConfigChange(
int channelNumber)
override;
131 void sendActionTrigger(uint8_t channelNumber, uint32_t actionId)
override;
132 void sendChannelValueChanged(uint8_t channelNumber, int8_t *value,
133 unsigned char offline, uint32_t validityTimeSec)
override;
134 void sendExtendedChannelValueChanged(uint8_t channelNumber,
137 bool processData(
const char *topic,
const char *payload);
138 void processRelayRequest(
const char *topic,
142 void processRGBWRequest(
const char *topic,
146 void processRGBRequest(
const char *topic,
150 void processDimmerRequest(
const char *topic,
154 void processRollerShutterRequest(
const char *topic,
160 void generateClientId(
char result[MQTT_CLIENTID_MAX_SIZE]);
161 void generateObjectId(
char result[30],
int channelNumber,
int subId);
162 MqttTopic getHADiscoveryTopic(
const char *sensor,
char *objectId);
163 void publishDeviceStatus(
bool onRegistration =
false);
164 void publishHADiscovery(
int channel);
169 void clearHADiscoveryRelayAlternativeTypes(
Supla::Channel *channel,
170 const char *currentType);
173 bool currentIsRoller);
188 void publishHADiscoveryEMParameter(
189 Supla::Element *element,
int parameterId,
const char *parameterName,
190 const char *units, Supla::Protocol::HAStateClass stateClass,
191 Supla::Protocol::HADeviceClass deviceClass);
192 const char *getActionTriggerType(uint8_t actionIdx);
193 bool isActionTriggerEnabled(
Supla::Channel *ch, uint8_t actionIdx);
194 virtual void publishImp(
const char *topic,
198 virtual void subscribeImp(
const char *topic,
int qos) = 0;
199 const char *getStateClassStr(Supla::Protocol::HAStateClass stateClass);
200 const char *getDeviceClassStr(Supla::Protocol::HADeviceClass deviceClass);
202 const char *getRelayChannelName(
int channelFunction)
const;
203 const char *getBinarySensorChannelName(
int channelFunction)
const;
205 bool isPayloadOn(
const char *);
206 bool isOpenClosedBinarySensorFunction(
int channelFunction)
const;
208 MqttChannelHandler *findChannelHandler(
int channelType)
const;
210 friend class HvacMqttHandler;
212 char server[SUPLA_SERVER_NAME_MAXSIZE] = {};
214 char user[MQTT_USERNAME_MAX_SIZE] = {};
215 char password[MQTT_PASSWORD_MAX_SIZE] = {};
216 char hostname[32] = {};
220 bool retainCfg =
false;
222 bool connecting =
false;
223 bool connected =
false;
225 uint16_t prefixLen = 0;
226 uint16_t channelsCount = 0;
227 uint16_t buttonNumber = 0;
228 char *prefix =
nullptr;
235 uint8_t configChangedBit[8] = {};