mirror of https://github.com/arendst/Tasmota.git
Add Domoticz safeguards
This commit is contained in:
parent
13cbf26b87
commit
9b5df76860
|
@ -110,10 +110,12 @@ int DomoticzRssiQuality(void) {
|
|||
}
|
||||
|
||||
uint32_t DomoticzRelayIdx(uint32_t relay) {
|
||||
if (relay >= MAX_RELAYS_SET) { return 0; }
|
||||
return (relay < MAX_DOMOTICZ_IDX) ? Settings->domoticz_relay_idx[relay] : Domoticz->relay_idx[relay -MAX_DOMOTICZ_IDX];
|
||||
}
|
||||
|
||||
void DomoticzSetRelayIdx(uint32_t relay, uint32_t idx) {
|
||||
if (relay >= MAX_RELAYS_SET) { return; }
|
||||
if (relay < MAX_DOMOTICZ_IDX) {
|
||||
Settings->domoticz_relay_idx[relay] = idx;
|
||||
} else {
|
||||
|
@ -121,6 +123,8 @@ void DomoticzSetRelayIdx(uint32_t relay, uint32_t idx) {
|
|||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************************/
|
||||
|
||||
#ifdef USE_SONOFF_IFAN
|
||||
void MqttPublishDomoticzFanState(void) {
|
||||
if (Settings->flag.mqtt_enabled && DomoticzRelayIdx(1)) { // SetOption3 - Enable MQTT
|
||||
|
@ -136,10 +140,12 @@ void MqttPublishDomoticzFanState(void) {
|
|||
}
|
||||
|
||||
void DomoticzUpdateFanState(void) {
|
||||
if (Domoticz->update_flag) {
|
||||
MqttPublishDomoticzFanState();
|
||||
if (Domoticz) {
|
||||
if (Domoticz->update_flag) {
|
||||
MqttPublishDomoticzFanState();
|
||||
}
|
||||
Domoticz->update_flag = true;
|
||||
}
|
||||
Domoticz->update_flag = true;
|
||||
}
|
||||
#endif // USE_SONOFF_IFAN
|
||||
|
||||
|
@ -174,12 +180,16 @@ void MqttPublishDomoticzPowerState(uint8_t device) {
|
|||
}
|
||||
|
||||
void DomoticzUpdatePowerState(uint8_t device) {
|
||||
if (Domoticz->update_flag) {
|
||||
MqttPublishDomoticzPowerState(device);
|
||||
if (Domoticz) {
|
||||
if (Domoticz->update_flag) {
|
||||
MqttPublishDomoticzPowerState(device);
|
||||
}
|
||||
Domoticz->update_flag = true;
|
||||
}
|
||||
Domoticz->update_flag = true;
|
||||
}
|
||||
|
||||
/*********************************************************************************************/
|
||||
|
||||
void DomoticzMqttUpdate(void) {
|
||||
if (Domoticz->subscribe && (Settings->domoticz_update_timer || Domoticz->update_timer)) {
|
||||
Domoticz->update_timer--;
|
||||
|
@ -515,7 +525,6 @@ void DomoticzSensorP1SmartMeter(char *usage1, char *usage2, char *return1, char
|
|||
DomoticzSensor(DZ_P1_SMART_METER, data);
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************************************/
|
||||
|
||||
void DomoticzInit(void) {
|
||||
|
|
Loading…
Reference in New Issue