mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-28 05:06:32 +00:00
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) {
|
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];
|
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) {
|
void DomoticzSetRelayIdx(uint32_t relay, uint32_t idx) {
|
||||||
|
if (relay >= MAX_RELAYS_SET) { return; }
|
||||||
if (relay < MAX_DOMOTICZ_IDX) {
|
if (relay < MAX_DOMOTICZ_IDX) {
|
||||||
Settings->domoticz_relay_idx[relay] = idx;
|
Settings->domoticz_relay_idx[relay] = idx;
|
||||||
} else {
|
} else {
|
||||||
@ -121,6 +123,8 @@ void DomoticzSetRelayIdx(uint32_t relay, uint32_t idx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*********************************************************************************************/
|
||||||
|
|
||||||
#ifdef USE_SONOFF_IFAN
|
#ifdef USE_SONOFF_IFAN
|
||||||
void MqttPublishDomoticzFanState(void) {
|
void MqttPublishDomoticzFanState(void) {
|
||||||
if (Settings->flag.mqtt_enabled && DomoticzRelayIdx(1)) { // SetOption3 - Enable MQTT
|
if (Settings->flag.mqtt_enabled && DomoticzRelayIdx(1)) { // SetOption3 - Enable MQTT
|
||||||
@ -136,10 +140,12 @@ void MqttPublishDomoticzFanState(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DomoticzUpdateFanState(void) {
|
void DomoticzUpdateFanState(void) {
|
||||||
|
if (Domoticz) {
|
||||||
if (Domoticz->update_flag) {
|
if (Domoticz->update_flag) {
|
||||||
MqttPublishDomoticzFanState();
|
MqttPublishDomoticzFanState();
|
||||||
}
|
}
|
||||||
Domoticz->update_flag = true;
|
Domoticz->update_flag = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif // USE_SONOFF_IFAN
|
#endif // USE_SONOFF_IFAN
|
||||||
|
|
||||||
@ -174,12 +180,16 @@ void MqttPublishDomoticzPowerState(uint8_t device) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DomoticzUpdatePowerState(uint8_t device) {
|
void DomoticzUpdatePowerState(uint8_t device) {
|
||||||
|
if (Domoticz) {
|
||||||
if (Domoticz->update_flag) {
|
if (Domoticz->update_flag) {
|
||||||
MqttPublishDomoticzPowerState(device);
|
MqttPublishDomoticzPowerState(device);
|
||||||
}
|
}
|
||||||
Domoticz->update_flag = true;
|
Domoticz->update_flag = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*********************************************************************************************/
|
||||||
|
|
||||||
void DomoticzMqttUpdate(void) {
|
void DomoticzMqttUpdate(void) {
|
||||||
if (Domoticz->subscribe && (Settings->domoticz_update_timer || Domoticz->update_timer)) {
|
if (Domoticz->subscribe && (Settings->domoticz_update_timer || 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);
|
DomoticzSensor(DZ_P1_SMART_METER, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************************/
|
/*********************************************************************************************/
|
||||||
|
|
||||||
void DomoticzInit(void) {
|
void DomoticzInit(void) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user