|
@ -80,6 +80,15 @@ void _domoticzMqtt(unsigned int type, const char * topic, const char * payload) |
|
|
|
|
|
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
#if BROKER_SUPPORT
|
|
|
|
|
|
void _domoticzBrokerCallback(const char * topic, unsigned char id, const char * payload) { |
|
|
|
|
|
if (strcmp(MQTT_TOPIC_RELAY, topic) == 0) { |
|
|
|
|
|
unsigned char value = atoi(payload); |
|
|
|
|
|
domoticzSendRelay(id, value == 1); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
#endif // BROKER_SUPPORT
|
|
|
|
|
|
|
|
|
#if WEB_SUPPORT
|
|
|
#if WEB_SUPPORT
|
|
|
|
|
|
|
|
|
bool _domoticzWebSocketOnReceive(const char * key, JsonVariant& value) { |
|
|
bool _domoticzWebSocketOnReceive(const char * key, JsonVariant& value) { |
|
@ -137,16 +146,16 @@ template<typename T> void domoticzSend(const char * key, T nvalue) { |
|
|
domoticzSend(key, nvalue, ""); |
|
|
domoticzSend(key, nvalue, ""); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void domoticzSendRelay(unsigned char relayID) { |
|
|
|
|
|
|
|
|
void domoticzSendRelay(unsigned char relayID, bool status) { |
|
|
if (!_dcz_enabled) return; |
|
|
if (!_dcz_enabled) return; |
|
|
char buffer[15]; |
|
|
char buffer[15]; |
|
|
snprintf_P(buffer, sizeof(buffer), PSTR("dczRelayIdx%u"), relayID); |
|
|
snprintf_P(buffer, sizeof(buffer), PSTR("dczRelayIdx%u"), relayID); |
|
|
domoticzSend(buffer, relayStatus(relayID) ? "1" : "0"); |
|
|
|
|
|
|
|
|
domoticzSend(buffer, status ? "1" : "0"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void domoticzSendRelays() { |
|
|
void domoticzSendRelays() { |
|
|
for (uint8_t relayID=0; relayID < relayCount(); relayID++) { |
|
|
for (uint8_t relayID=0; relayID < relayCount(); relayID++) { |
|
|
domoticzSendRelay(relayID); |
|
|
|
|
|
|
|
|
domoticzSendRelay(relayID, relayStatus(relayID)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -165,6 +174,10 @@ void domoticzSetup() { |
|
|
wsOnReceiveRegister(_domoticzWebSocketOnReceive); |
|
|
wsOnReceiveRegister(_domoticzWebSocketOnReceive); |
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if BROKER_SUPPORT
|
|
|
|
|
|
brokerRegister(_domoticzBrokerCallback); |
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
// Callbacks
|
|
|
// Callbacks
|
|
|
mqttRegister(_domoticzMqtt); |
|
|
mqttRegister(_domoticzMqtt); |
|
|
espurnaRegisterReload(_domoticzConfigure); |
|
|
espurnaRegisterReload(_domoticzConfigure); |
|
|