mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-29 13:46:37 +00:00
Use global struct
This commit is contained in:
parent
1791a54470
commit
f1ac7b2d67
@ -321,7 +321,7 @@ uint32_t GetSettingsCrc32(void)
|
||||
void SettingsSaveAll(void)
|
||||
{
|
||||
if (Settings.flag.save_state) {
|
||||
Settings.power = power;
|
||||
Settings.power = TasmotaGlobal.power;
|
||||
} else {
|
||||
Settings.power = 0;
|
||||
}
|
||||
|
@ -658,7 +658,7 @@ float ConvertTemp(float c)
|
||||
float result = c;
|
||||
|
||||
TasmotaGlobal.global_update = TasmotaGlobal.uptime;
|
||||
global_temperature_celsius = c;
|
||||
TasmotaGlobal.temperature_celsius = c;
|
||||
|
||||
if (!isnan(c) && Settings.flag.temperature_conversion) { // SetOption8 - Switch between Celsius or Fahrenheit
|
||||
result = c * 1.8 + 32; // Fahrenheit
|
||||
@ -689,7 +689,7 @@ float ConvertHumidity(float h)
|
||||
float result = h;
|
||||
|
||||
TasmotaGlobal.global_update = TasmotaGlobal.uptime;
|
||||
global_humidity = h;
|
||||
TasmotaGlobal.humidity = h;
|
||||
|
||||
result = result + (0.1 * Settings.hum_comp);
|
||||
|
||||
@ -718,7 +718,7 @@ float ConvertPressure(float p)
|
||||
float result = p;
|
||||
|
||||
TasmotaGlobal.global_update = TasmotaGlobal.uptime;
|
||||
global_pressure_hpa = p;
|
||||
TasmotaGlobal.pressure_hpa = p;
|
||||
|
||||
if (!isnan(p) && Settings.flag.pressure_conversion) { // SetOption24 - Switch between hPa or mmHg pressure unit
|
||||
result = p * 0.75006375541921; // mmHg
|
||||
@ -747,9 +747,9 @@ void ResetGlobalValues(void)
|
||||
{
|
||||
if ((TasmotaGlobal.uptime - TasmotaGlobal.global_update) > GLOBAL_VALUES_VALID) { // Reset after 5 minutes
|
||||
TasmotaGlobal.global_update = 0;
|
||||
global_temperature_celsius = NAN;
|
||||
global_humidity = 0.0f;
|
||||
global_pressure_hpa = 0.0f;
|
||||
TasmotaGlobal.temperature_celsius = NAN;
|
||||
TasmotaGlobal.humidity = 0.0f;
|
||||
TasmotaGlobal.pressure_hpa = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -420,7 +420,7 @@ void CmndStatus(void)
|
||||
D_CMND_LEDMASK "\":\"%04X\",\"" D_CMND_SAVEDATA "\":%d,\"" D_JSON_SAVESTATE "\":%d,\"" D_CMND_SWITCHTOPIC "\":\"%s\",\""
|
||||
D_CMND_SWITCHMODE "\":[%s],\"" D_CMND_BUTTONRETAIN "\":%d,\"" D_CMND_SWITCHRETAIN "\":%d,\"" D_CMND_SENSORRETAIN "\":%d,\"" D_CMND_POWERRETAIN "\":%d}}"),
|
||||
ModuleNr(), EscapeJSONString(SettingsText(SET_DEVICENAME)).c_str(), stemp, mqtt_topic,
|
||||
SettingsText(SET_MQTT_BUTTON_TOPIC), power, Settings.poweronstate, Settings.ledstate,
|
||||
SettingsText(SET_MQTT_BUTTON_TOPIC), TasmotaGlobal.power, Settings.poweronstate, Settings.ledstate,
|
||||
Settings.ledmask, Settings.save_data,
|
||||
Settings.flag.save_state, // SetOption0 - Save power state and use after restart
|
||||
SettingsText(SET_MQTT_SWITCH_TOPIC),
|
||||
@ -664,7 +664,7 @@ void CmndGlobalTemp(void)
|
||||
TasmotaGlobal.global_update = 1; // Keep global values just entered valid
|
||||
}
|
||||
}
|
||||
ResponseCmndFloat(global_temperature_celsius, 1);
|
||||
ResponseCmndFloat(TasmotaGlobal.temperature_celsius, 1);
|
||||
}
|
||||
|
||||
void CmndGlobalHum(void)
|
||||
@ -676,7 +676,7 @@ void CmndGlobalHum(void)
|
||||
TasmotaGlobal.global_update = 1; // Keep global values just entered valid
|
||||
}
|
||||
}
|
||||
ResponseCmndFloat(global_humidity, 1);
|
||||
ResponseCmndFloat(TasmotaGlobal.humidity, 1);
|
||||
}
|
||||
|
||||
void CmndSleep(void)
|
||||
@ -1654,7 +1654,7 @@ void CmndInterlock(void)
|
||||
} else {
|
||||
Settings.flag.interlock = XdrvMailbox.payload &1; // CMND_INTERLOCK - Enable/disable interlock
|
||||
if (Settings.flag.interlock) {
|
||||
SetDevicePower(power, SRC_IGNORE); // Remove multiple relays if set
|
||||
SetDevicePower(TasmotaGlobal.power, SRC_IGNORE); // Remove multiple relays if set
|
||||
}
|
||||
}
|
||||
#ifdef USE_SHUTTER
|
||||
|
@ -388,7 +388,7 @@ void SendReceiveDeviceGroupMessage(struct device_group * device_group, struct de
|
||||
if (Settings.flag4.multiple_device_groups) { // SetOption88 - Enable relays in separate device groups
|
||||
if (device_group_index < devices_present) {
|
||||
bool on = (value & 1);
|
||||
if (on != (power & (1 << device_group_index))) ExecuteCommandPower(device_group_index + 1, (on ? POWER_ON : POWER_OFF), SRC_REMOTE);
|
||||
if (on != (TasmotaGlobal.power & (1 << device_group_index))) ExecuteCommandPower(device_group_index + 1, (on ? POWER_ON : POWER_OFF), SRC_REMOTE);
|
||||
}
|
||||
}
|
||||
else if (XdrvMailbox.index & DGR_FLAG_LOCAL) {
|
||||
@ -397,7 +397,7 @@ void SendReceiveDeviceGroupMessage(struct device_group * device_group, struct de
|
||||
for (uint32_t i = 0; i < mask_devices; i++) {
|
||||
uint32_t mask = 1 << i;
|
||||
bool on = (value & mask);
|
||||
if (on != (power & mask)) ExecuteCommandPower(i + 1, (on ? POWER_ON : POWER_OFF), SRC_REMOTE);
|
||||
if (on != (TasmotaGlobal.power & mask)) ExecuteCommandPower(i + 1, (on ? POWER_ON : POWER_OFF), SRC_REMOTE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -505,7 +505,7 @@ bool _SendDeviceGroupMessage(uint8_t device_group_index, DevGroupMessageType mes
|
||||
building_status_message = true;
|
||||
|
||||
// Call the drivers to build the status update.
|
||||
SendDeviceGroupMessage(device_group_index, DGR_MSGTYP_PARTIAL_UPDATE, DGR_ITEM_POWER, power);
|
||||
SendDeviceGroupMessage(device_group_index, DGR_MSGTYP_PARTIAL_UPDATE, DGR_ITEM_POWER, TasmotaGlobal.power);
|
||||
XdrvMailbox.index = 0;
|
||||
if (device_group_index == 0 && first_device_group_is_local) XdrvMailbox.index = DGR_FLAG_LOCAL;
|
||||
XdrvMailbox.command_code = DGR_ITEM_STATUS;
|
||||
|
@ -81,7 +81,7 @@ bool RotaryButtonPressed(uint32_t button_index) {
|
||||
if (-1 == Encoder[index].pinb) { continue; }
|
||||
if (index != button_index) { continue; }
|
||||
|
||||
bool powered_on = (power);
|
||||
bool powered_on = (TasmotaGlobal.power);
|
||||
#ifdef USE_LIGHT
|
||||
if (!Settings.flag4.rotary_uses_rules) { // SetOption98 - Use rules instead of light control
|
||||
powered_on = LightPower();
|
||||
@ -202,7 +202,7 @@ void RotaryHandler(void) {
|
||||
}
|
||||
} else { // Dimmer RGBCW or RGB only if second rotary
|
||||
uint32_t dimmer_index = second_rotary ? 1 : 0;
|
||||
if (!Settings.flag4.rotary_poweron_dimlow || power) { // SetOption113 - On rotary dial after power off set dimmer low
|
||||
if (!Settings.flag4.rotary_poweron_dimlow || TasmotaGlobal.power) { // SetOption113 - On rotary dial after power off set dimmer low
|
||||
LightDimmerOffset(dimmer_index, rotary_position * rotary_dimmer_increment[Rotary.model]);
|
||||
} else {
|
||||
if (rotary_position > 0) { // Only power on if rotary increase
|
||||
|
@ -157,10 +157,10 @@ char* GetStateText(uint32_t state)
|
||||
|
||||
void SetLatchingRelay(power_t lpower, uint32_t state)
|
||||
{
|
||||
// power xx00 - toggle REL1 (Off) and REL3 (Off) - device 1 Off, device 2 Off
|
||||
// power xx01 - toggle REL2 (On) and REL3 (Off) - device 1 On, device 2 Off
|
||||
// power xx10 - toggle REL1 (Off) and REL4 (On) - device 1 Off, device 2 On
|
||||
// power xx11 - toggle REL2 (On) and REL4 (On) - device 1 On, device 2 On
|
||||
// TasmotaGlobal.power xx00 - toggle REL1 (Off) and REL3 (Off) - device 1 Off, device 2 Off
|
||||
// TasmotaGlobal.power xx01 - toggle REL2 (On) and REL3 (Off) - device 1 On, device 2 Off
|
||||
// TasmotaGlobal.power xx10 - toggle REL1 (Off) and REL4 (On) - device 1 Off, device 2 On
|
||||
// TasmotaGlobal.power xx11 - toggle REL2 (On) and REL4 (On) - device 1 On, device 2 On
|
||||
static power_t latching_power = 0; // Power state at latching start
|
||||
|
||||
if (state && !latching_relay_pulse) { // Set latching relay to power if previous pulse has finished
|
||||
@ -170,7 +170,7 @@ void SetLatchingRelay(power_t lpower, uint32_t state)
|
||||
|
||||
for (uint32_t i = 0; i < devices_present; i++) {
|
||||
uint32_t port = (i << 1) + ((latching_power >> i) &1);
|
||||
DigitalWrite(GPIO_REL1, port, bitRead(rel_inverted, port) ? !state : state);
|
||||
DigitalWrite(GPIO_REL1, port, bitRead(TasmotaGlobal.rel_inverted, port) ? !state : state);
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,8 +180,8 @@ void SetDevicePower(power_t rpower, uint32_t source)
|
||||
last_source = source;
|
||||
|
||||
if (POWER_ALL_ALWAYS_ON == Settings.poweronstate) { // All on and stay on
|
||||
power = (1 << devices_present) -1;
|
||||
rpower = power;
|
||||
TasmotaGlobal.power = (1 << devices_present) -1;
|
||||
rpower = TasmotaGlobal.power;
|
||||
}
|
||||
|
||||
if (Settings.flag.interlock) { // Allow only one or no relay set - CMND_INTERLOCK - Enable/disable interlock
|
||||
@ -196,14 +196,14 @@ void SetDevicePower(power_t rpower, uint32_t source)
|
||||
}
|
||||
if (count > 1) {
|
||||
mask = ~Settings.interlock[i]; // Turn interlocked group off as there would be multiple relays on
|
||||
power &= mask;
|
||||
TasmotaGlobal.power &= mask;
|
||||
rpower &= mask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rpower) { // Any power set
|
||||
last_power = rpower;
|
||||
TasmotaGlobal.last_power = rpower;
|
||||
}
|
||||
|
||||
XdrvMailbox.index = rpower;
|
||||
@ -233,7 +233,7 @@ void SetDevicePower(power_t rpower, uint32_t source)
|
||||
for (uint32_t i = 0; i < devices_present; i++) {
|
||||
power_t state = rpower &1;
|
||||
if (i < MAX_RELAYS) {
|
||||
DigitalWrite(GPIO_REL1, i, bitRead(rel_inverted, i) ? !state : state);
|
||||
DigitalWrite(GPIO_REL1, i, bitRead(TasmotaGlobal.rel_inverted, i) ? !state : state);
|
||||
}
|
||||
rpower >>= 1;
|
||||
}
|
||||
@ -242,9 +242,9 @@ void SetDevicePower(power_t rpower, uint32_t source)
|
||||
|
||||
void RestorePower(bool publish_power, uint32_t source)
|
||||
{
|
||||
if (power != last_power) {
|
||||
power = last_power;
|
||||
SetDevicePower(power, source);
|
||||
if (TasmotaGlobal.power != TasmotaGlobal.last_power) {
|
||||
TasmotaGlobal.power = TasmotaGlobal.last_power;
|
||||
SetDevicePower(TasmotaGlobal.power, source);
|
||||
if (publish_power) {
|
||||
MqttPublishAllPowerState();
|
||||
}
|
||||
@ -270,15 +270,15 @@ void SetAllPower(uint32_t state, uint32_t source)
|
||||
power_t all_on = (1 << devices_present) -1;
|
||||
switch (state) {
|
||||
case POWER_OFF:
|
||||
power = 0;
|
||||
TasmotaGlobal.power = 0;
|
||||
break;
|
||||
case POWER_ON:
|
||||
power = all_on;
|
||||
TasmotaGlobal.power = all_on;
|
||||
break;
|
||||
case POWER_TOGGLE:
|
||||
power ^= all_on; // Complement current state
|
||||
TasmotaGlobal.power ^= all_on; // Complement current state
|
||||
}
|
||||
SetDevicePower(power, source);
|
||||
SetDevicePower(TasmotaGlobal.power, source);
|
||||
}
|
||||
if (publish_power) {
|
||||
MqttPublishAllPowerState();
|
||||
@ -299,30 +299,30 @@ void SetPowerOnState(void)
|
||||
switch (Settings.poweronstate) {
|
||||
case POWER_ALL_OFF:
|
||||
case POWER_ALL_OFF_PULSETIME_ON:
|
||||
power = 0;
|
||||
SetDevicePower(power, SRC_RESTART);
|
||||
TasmotaGlobal.power = 0;
|
||||
SetDevicePower(TasmotaGlobal.power, SRC_RESTART);
|
||||
break;
|
||||
case POWER_ALL_ON: // All on
|
||||
power = (1 << devices_present) -1;
|
||||
SetDevicePower(power, SRC_RESTART);
|
||||
TasmotaGlobal.power = (1 << devices_present) -1;
|
||||
SetDevicePower(TasmotaGlobal.power, SRC_RESTART);
|
||||
break;
|
||||
case POWER_ALL_SAVED_TOGGLE:
|
||||
power = (Settings.power & ((1 << devices_present) -1)) ^ POWER_MASK;
|
||||
TasmotaGlobal.power = (Settings.power & ((1 << devices_present) -1)) ^ POWER_MASK;
|
||||
if (Settings.flag.save_state) { // SetOption0 - Save power state and use after restart
|
||||
SetDevicePower(power, SRC_RESTART);
|
||||
SetDevicePower(TasmotaGlobal.power, SRC_RESTART);
|
||||
}
|
||||
break;
|
||||
case POWER_ALL_SAVED:
|
||||
power = Settings.power & ((1 << devices_present) -1);
|
||||
TasmotaGlobal.power = Settings.power & ((1 << devices_present) -1);
|
||||
if (Settings.flag.save_state) { // SetOption0 - Save power state and use after restart
|
||||
SetDevicePower(power, SRC_RESTART);
|
||||
SetDevicePower(TasmotaGlobal.power, SRC_RESTART);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
power = Settings.power & ((1 << devices_present) -1);
|
||||
TasmotaGlobal.power = Settings.power & ((1 << devices_present) -1);
|
||||
if (Settings.flag.save_state) { // SetOption0 - Save power state and use after restart
|
||||
SetDevicePower(power, SRC_RESTART);
|
||||
SetDevicePower(TasmotaGlobal.power, SRC_RESTART);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -331,14 +331,14 @@ void SetPowerOnState(void)
|
||||
for (uint32_t i = 0; i < devices_present; i++) {
|
||||
if (!Settings.flag3.no_power_feedback) { // SetOption63 - Don't scan relay power state at restart - #5594 and #5663
|
||||
if ((i < MAX_RELAYS) && PinUsed(GPIO_REL1, i)) {
|
||||
bitWrite(power, i, digitalRead(Pin(GPIO_REL1, i)) ^ bitRead(rel_inverted, i));
|
||||
bitWrite(TasmotaGlobal.power, i, digitalRead(Pin(GPIO_REL1, i)) ^ bitRead(TasmotaGlobal.rel_inverted, i));
|
||||
}
|
||||
}
|
||||
if (bitRead(power, i) || (POWER_ALL_OFF_PULSETIME_ON == Settings.poweronstate)) {
|
||||
if (bitRead(TasmotaGlobal.power, i) || (POWER_ALL_OFF_PULSETIME_ON == Settings.poweronstate)) {
|
||||
SetPulseTimer(i % MAX_PULSETIMERS, Settings.pulse_timer[i % MAX_PULSETIMERS]);
|
||||
}
|
||||
}
|
||||
blink_powersave = power;
|
||||
TasmotaGlobal.blink_powersave = TasmotaGlobal.power;
|
||||
}
|
||||
|
||||
void UpdateLedPowerAll()
|
||||
@ -389,7 +389,7 @@ void SetLedPower(uint32_t state)
|
||||
} else {
|
||||
power_t mask = 1;
|
||||
for (uint32_t i = 0; i < leds_present; i++) { // Map leds to power
|
||||
bool tstate = (power & mask);
|
||||
bool tstate = (TasmotaGlobal.power & mask);
|
||||
SetLedPowerIdx(i, tstate);
|
||||
mask <<= 1;
|
||||
}
|
||||
@ -471,7 +471,7 @@ bool SendKey(uint32_t key, uint32_t device, uint32_t state)
|
||||
!strcmp(mqtt_topic, key_topic) ||
|
||||
!strcmp(SettingsText(SET_MQTT_GRP_TOPIC), key_topic)) &&
|
||||
(POWER_TOGGLE == state)) {
|
||||
state = ~(power >> (device -1)) &1; // POWER_OFF or POWER_ON
|
||||
state = ~(TasmotaGlobal.power >> (device -1)) &1; // POWER_OFF or POWER_ON
|
||||
}
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), GetStateText(state));
|
||||
}
|
||||
@ -520,7 +520,7 @@ void ExecuteCommandPower(uint32_t device, uint32_t state, uint32_t source)
|
||||
|
||||
#ifdef USE_SONOFF_IFAN
|
||||
if (IsModuleIfan()) {
|
||||
blink_mask &= 1; // No blinking on the fan relays
|
||||
TasmotaGlobal.blink_mask &= 1; // No blinking on the fan relays
|
||||
Settings.flag.interlock = 0; // No interlock mode as it is already done by the microcontroller - CMND_INTERLOCK - Enable/disable interlock
|
||||
Settings.pulse_timer[1] = 0; // No pulsetimers on the fan relays
|
||||
Settings.pulse_timer[2] = 0;
|
||||
@ -544,21 +544,21 @@ void ExecuteCommandPower(uint32_t device, uint32_t state, uint32_t source)
|
||||
static bool interlock_mutex = false; // Interlock power command pending
|
||||
power_t mask = 1 << (device -1); // Device to control
|
||||
if (state <= POWER_TOGGLE) {
|
||||
if ((blink_mask & mask)) {
|
||||
blink_mask &= (POWER_MASK ^ mask); // Clear device mask
|
||||
if ((TasmotaGlobal.blink_mask & mask)) {
|
||||
TasmotaGlobal.blink_mask &= (POWER_MASK ^ mask); // Clear device mask
|
||||
MqttPublishPowerBlinkState(device);
|
||||
}
|
||||
|
||||
if (Settings.flag.interlock && // CMND_INTERLOCK - Enable/disable interlock
|
||||
!interlock_mutex &&
|
||||
((POWER_ON == state) || ((POWER_TOGGLE == state) && !(power & mask)))
|
||||
((POWER_ON == state) || ((POWER_TOGGLE == state) && !(TasmotaGlobal.power & mask)))
|
||||
) {
|
||||
interlock_mutex = true; // Clear all but masked relay in interlock group if new set requested
|
||||
for (uint32_t i = 0; i < MAX_INTERLOCKS; i++) {
|
||||
if (Settings.interlock[i] & mask) { // Find interlock group
|
||||
for (uint32_t j = 0; j < devices_present; j++) {
|
||||
power_t imask = 1 << j;
|
||||
if ((Settings.interlock[i] & imask) && (power & imask) && (mask != imask)) {
|
||||
if ((Settings.interlock[i] & imask) && (TasmotaGlobal.power & imask) && (mask != imask)) {
|
||||
ExecuteCommandPower(j +1, POWER_OFF, SRC_IGNORE);
|
||||
delay(50); // Add some delay to make sure never have more than one relay on
|
||||
}
|
||||
@ -571,53 +571,53 @@ void ExecuteCommandPower(uint32_t device, uint32_t state, uint32_t source)
|
||||
|
||||
switch (state) {
|
||||
case POWER_OFF: {
|
||||
power &= (POWER_MASK ^ mask);
|
||||
TasmotaGlobal.power &= (POWER_MASK ^ mask);
|
||||
break; }
|
||||
case POWER_ON:
|
||||
power |= mask;
|
||||
TasmotaGlobal.power |= mask;
|
||||
break;
|
||||
case POWER_TOGGLE:
|
||||
power ^= mask;
|
||||
TasmotaGlobal.power ^= mask;
|
||||
}
|
||||
#ifdef USE_DEVICE_GROUPS
|
||||
if (SRC_REMOTE != source && SRC_RETRY != source) {
|
||||
if (Settings.flag4.multiple_device_groups) // SetOption88 - Enable relays in separate device groups
|
||||
SendDeviceGroupMessage(device - 1, DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, (power >> (device - 1)) & 1 | 0x01000000); // Explicitly set number of relays to one
|
||||
SendDeviceGroupMessage(device - 1, DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, (TasmotaGlobal.power >> (device - 1)) & 1 | 0x01000000); // Explicitly set number of relays to one
|
||||
else
|
||||
SendLocalDeviceGroupMessage(DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, power);
|
||||
SendLocalDeviceGroupMessage(DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, TasmotaGlobal.power);
|
||||
}
|
||||
#endif // USE_DEVICE_GROUPS
|
||||
SetDevicePower(power, source);
|
||||
SetDevicePower(TasmotaGlobal.power, source);
|
||||
#ifdef USE_DOMOTICZ
|
||||
DomoticzUpdatePowerState(device);
|
||||
#endif // USE_DOMOTICZ
|
||||
#ifdef USE_KNX
|
||||
KnxUpdatePowerState(device, power);
|
||||
KnxUpdatePowerState(device, TasmotaGlobal.power);
|
||||
#endif // USE_KNX
|
||||
if (publish_power && Settings.flag3.hass_tele_on_power) { // SetOption59 - Send tele/%topic%/STATE in addition to stat/%topic%/RESULT
|
||||
MqttPublishTeleState();
|
||||
}
|
||||
|
||||
// Restart PulseTime if powered On
|
||||
SetPulseTimer((device -1) % MAX_PULSETIMERS, (((POWER_ALL_OFF_PULSETIME_ON == Settings.poweronstate) ? ~power : power) & mask) ? Settings.pulse_timer[(device -1) % MAX_PULSETIMERS] : 0);
|
||||
SetPulseTimer((device -1) % MAX_PULSETIMERS, (((POWER_ALL_OFF_PULSETIME_ON == Settings.poweronstate) ? ~TasmotaGlobal.power : TasmotaGlobal.power) & mask) ? Settings.pulse_timer[(device -1) % MAX_PULSETIMERS] : 0);
|
||||
}
|
||||
else if (POWER_BLINK == state) {
|
||||
if (!(blink_mask & mask)) {
|
||||
blink_powersave = (blink_powersave & (POWER_MASK ^ mask)) | (power & mask); // Save state
|
||||
blink_power = (power >> (device -1))&1; // Prep to Toggle
|
||||
if (!(TasmotaGlobal.blink_mask & mask)) {
|
||||
TasmotaGlobal.blink_powersave = (TasmotaGlobal.blink_powersave & (POWER_MASK ^ mask)) | (TasmotaGlobal.power & mask); // Save state
|
||||
TasmotaGlobal.blink_power = (TasmotaGlobal.power >> (device -1))&1; // Prep to Toggle
|
||||
}
|
||||
TasmotaGlobal.blink_timer = millis() + 100;
|
||||
blink_counter = ((!Settings.blinkcount) ? 64000 : (Settings.blinkcount *2)) +1;
|
||||
blink_mask |= mask; // Set device mask
|
||||
TasmotaGlobal.blink_mask |= mask; // Set device mask
|
||||
MqttPublishPowerBlinkState(device);
|
||||
return;
|
||||
}
|
||||
else if (POWER_BLINK_STOP == state) {
|
||||
bool flag = (blink_mask & mask);
|
||||
blink_mask &= (POWER_MASK ^ mask); // Clear device mask
|
||||
bool flag = (TasmotaGlobal.blink_mask & mask);
|
||||
TasmotaGlobal.blink_mask &= (POWER_MASK ^ mask); // Clear device mask
|
||||
MqttPublishPowerBlinkState(device);
|
||||
if (flag) {
|
||||
ExecuteCommandPower(device, (blink_powersave >> (device -1))&1, SRC_IGNORE); // Restore state
|
||||
ExecuteCommandPower(device, (TasmotaGlobal.blink_powersave >> (device -1))&1, SRC_IGNORE); // Restore state
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -632,10 +632,10 @@ void StopAllPowerBlink(void)
|
||||
|
||||
for (uint32_t i = 1; i <= devices_present; i++) {
|
||||
mask = 1 << (i -1);
|
||||
if (blink_mask & mask) {
|
||||
blink_mask &= (POWER_MASK ^ mask); // Clear device mask
|
||||
if (TasmotaGlobal.blink_mask & mask) {
|
||||
TasmotaGlobal.blink_mask &= (POWER_MASK ^ mask); // Clear device mask
|
||||
MqttPublishPowerBlinkState(i);
|
||||
ExecuteCommandPower(i, (blink_powersave >> (i -1))&1, SRC_IGNORE); // Restore state
|
||||
ExecuteCommandPower(i, (TasmotaGlobal.blink_powersave >> (i -1))&1, SRC_IGNORE); // Restore state
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -678,7 +678,7 @@ void MqttShowState(void)
|
||||
} else {
|
||||
#endif
|
||||
ResponseAppend_P(PSTR(",\"%s\":\"%s\""), GetPowerDevice(stemp1, i, sizeof(stemp1), Settings.flag.device_index_enable), // SetOption26 - Switch between POWER or POWER1
|
||||
GetStateText(bitRead(power, i-1)));
|
||||
GetStateText(bitRead(TasmotaGlobal.power, i-1)));
|
||||
#ifdef USE_SONOFF_IFAN
|
||||
if (IsModuleIfan()) {
|
||||
ResponseAppend_P(PSTR(",\"" D_CMND_FANSPEED "\":%d"), GetFanspeed());
|
||||
@ -902,15 +902,15 @@ void Every100mSeconds(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (blink_mask) {
|
||||
if (TasmotaGlobal.blink_mask) {
|
||||
if (TimeReached(TasmotaGlobal.blink_timer)) {
|
||||
SetNextTimeInterval(TasmotaGlobal.blink_timer, 100 * Settings.blinktime);
|
||||
blink_counter--;
|
||||
if (!blink_counter) {
|
||||
StopAllPowerBlink();
|
||||
} else {
|
||||
blink_power ^= 1;
|
||||
power_now = (power & (POWER_MASK ^ blink_mask)) | ((blink_power) ? blink_mask : 0);
|
||||
TasmotaGlobal.blink_power ^= 1;
|
||||
power_now = (TasmotaGlobal.power & (POWER_MASK ^ TasmotaGlobal.blink_mask)) | ((TasmotaGlobal.blink_power) ? TasmotaGlobal.blink_mask : 0);
|
||||
SetDevicePower(power_now, SRC_IGNORE);
|
||||
}
|
||||
}
|
||||
@ -959,10 +959,10 @@ void Every250mSeconds(void)
|
||||
}
|
||||
}
|
||||
if (Settings.ledstate &1 && (PinUsed(GPIO_LEDLNK) || !(blinks || restart_flag || ota_state_flag)) ) {
|
||||
bool tstate = power & Settings.ledmask;
|
||||
bool tstate = TasmotaGlobal.power & Settings.ledmask;
|
||||
#ifdef ESP8266
|
||||
if ((SONOFF_TOUCH == my_module_type) || (SONOFF_T11 == my_module_type) || (SONOFF_T12 == my_module_type) || (SONOFF_T13 == my_module_type)) {
|
||||
tstate = (!power) ? 1 : 0; // As requested invert signal for Touch devices to find them in the dark
|
||||
tstate = (!TasmotaGlobal.power) ? 1 : 0; // As requested invert signal for Touch devices to find them in the dark
|
||||
}
|
||||
#endif // ESP8266
|
||||
SetLedPower(tstate);
|
||||
@ -1086,8 +1086,8 @@ void Every250mSeconds(void)
|
||||
mask &= ~(1 << i);
|
||||
}
|
||||
}
|
||||
if (!((Settings.power &mask) == (power &mask))) {
|
||||
Settings.power = power;
|
||||
if (!((Settings.power &mask) == (TasmotaGlobal.power &mask))) {
|
||||
Settings.power = TasmotaGlobal.power;
|
||||
}
|
||||
} else {
|
||||
Settings.power = 0;
|
||||
@ -1551,7 +1551,7 @@ void GpioInit(void)
|
||||
}
|
||||
#endif //ESP32
|
||||
else if ((mpin >= AGPIO(GPIO_REL1_INV)) && (mpin < (AGPIO(GPIO_REL1_INV) + MAX_RELAYS))) {
|
||||
bitSet(rel_inverted, mpin - AGPIO(GPIO_REL1_INV));
|
||||
bitSet(TasmotaGlobal.rel_inverted, mpin - AGPIO(GPIO_REL1_INV));
|
||||
mpin -= (AGPIO(GPIO_REL1_INV) - AGPIO(GPIO_REL1));
|
||||
}
|
||||
else if ((mpin >= AGPIO(GPIO_LED1_INV)) && (mpin < (AGPIO(GPIO_LED1_INV) + MAX_LEDS))) {
|
||||
@ -1729,7 +1729,7 @@ void GpioInit(void)
|
||||
devices_present++;
|
||||
#ifdef ESP8266
|
||||
if (EXS_RELAY == my_module_type) {
|
||||
digitalWrite(Pin(GPIO_REL1, i), bitRead(rel_inverted, i) ? 1 : 0);
|
||||
digitalWrite(Pin(GPIO_REL1, i), bitRead(TasmotaGlobal.rel_inverted, i) ? 1 : 0);
|
||||
if (i &1) { devices_present--; }
|
||||
}
|
||||
#endif // ESP8266
|
||||
|
@ -87,22 +87,24 @@ struct {
|
||||
uint32_t web_log_index; // Index in Web log buffer
|
||||
uint32_t uptime; // Counting every second until 4294967295 = 130 year
|
||||
|
||||
power_t power; // Current copy of Settings.power
|
||||
power_t rel_inverted; // Relay inverted flag (1 = (0 = On, 1 = Off))
|
||||
power_t last_power; // Last power set state
|
||||
power_t blink_power; // Blink power state
|
||||
power_t blink_powersave; // Blink start power save state
|
||||
power_t blink_mask; // Blink relay active mask
|
||||
|
||||
float temperature_celsius; // Provide a global temperature to be used by some sensors
|
||||
float humidity; // Provide a global humidity to be used by some sensors
|
||||
float pressure_hpa; // Provide a global pressure to be used by some sensors
|
||||
|
||||
} TasmotaGlobal;
|
||||
|
||||
power_t power = 0; // Current copy of Settings.power
|
||||
power_t last_power = 0; // Last power set state
|
||||
power_t blink_power; // Blink power state
|
||||
power_t blink_mask = 0; // Blink relay active mask
|
||||
power_t blink_powersave; // Blink start power save state
|
||||
power_t rel_inverted = 0; // Relay inverted flag (1 = (0 = On, 1 = Off))
|
||||
int serial_in_byte_counter = 0; // Index in receive buffer
|
||||
int ota_state_flag = 0; // OTA state flag
|
||||
int restart_flag = 0; // Tasmota restart flag
|
||||
int wifi_state_flag = WIFI_RESTART; // Wifi state flag
|
||||
int blinks = 201; // Number of LED blinks
|
||||
float global_temperature_celsius = NAN; // Provide a global temperature to be used by some sensors
|
||||
float global_humidity = 0.0f; // Provide a global humidity to be used by some sensors
|
||||
float global_pressure_hpa = 0.0f; // Provide a global pressure to be used by some sensors
|
||||
uint16_t tele_period = 9999; // Tele period timer
|
||||
uint16_t blink_counter = 0; // Number of blink cycles
|
||||
uint16_t seriallog_timer = 0; // Timer to disable Seriallog
|
||||
@ -183,6 +185,7 @@ void setup(void) {
|
||||
|
||||
memset(&TasmotaGlobal, 0, sizeof(TasmotaGlobal));
|
||||
TasmotaGlobal.baudrate = APP_BAUDRATE;
|
||||
TasmotaGlobal.temperature_celsius = NAN;
|
||||
|
||||
global_state.data = 0xF; // Init global state (wifi_down, mqtt_down) to solve possible network issues
|
||||
|
||||
|
@ -1686,15 +1686,15 @@ bool HandleRootStatusRefresh(void)
|
||||
uint32_t fsize = (devices_present < 5) ? 70 - (devices_present * 8) : 32;
|
||||
#ifdef USE_SONOFF_IFAN
|
||||
if (IsModuleIfan()) {
|
||||
WSContentSend_P(HTTP_DEVICE_STATE, 36, (bitRead(power, 0)) ? "bold" : "normal", 54, GetStateText(bitRead(power, 0)));
|
||||
WSContentSend_P(HTTP_DEVICE_STATE, 36, (bitRead(TasmotaGlobal.power, 0)) ? "bold" : "normal", 54, GetStateText(bitRead(TasmotaGlobal.power, 0)));
|
||||
uint32_t fanspeed = GetFanspeed();
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("%d"), fanspeed);
|
||||
WSContentSend_P(HTTP_DEVICE_STATE, 64, (fanspeed) ? "bold" : "normal", 54, (fanspeed) ? svalue : GetStateText(0));
|
||||
} else {
|
||||
#endif // USE_SONOFF_IFAN
|
||||
for (uint32_t idx = 1; idx <= devices_present; idx++) {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("%d"), bitRead(power, idx -1));
|
||||
WSContentSend_P(HTTP_DEVICE_STATE, 100 / devices_present, (bitRead(power, idx -1)) ? "bold" : "normal", fsize, (devices_present < 5) ? GetStateText(bitRead(power, idx -1)) : svalue);
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("%d"), bitRead(TasmotaGlobal.power, idx -1));
|
||||
WSContentSend_P(HTTP_DEVICE_STATE, 100 / devices_present, (bitRead(TasmotaGlobal.power, idx -1)) ? "bold" : "normal", fsize, (devices_present < 5) ? GetStateText(bitRead(TasmotaGlobal.power, idx -1)) : svalue);
|
||||
}
|
||||
#ifdef USE_SONOFF_IFAN
|
||||
}
|
||||
|
@ -436,12 +436,12 @@ void MqttPublishPowerState(uint32_t device)
|
||||
#endif // USE_SONOFF_IFAN
|
||||
GetPowerDevice(scommand, device, sizeof(scommand), Settings.flag.device_index_enable); // SetOption26 - Switch between POWER or POWER1
|
||||
GetTopic_P(stopic, STAT, mqtt_topic, (Settings.flag.mqtt_response) ? scommand : S_RSLT_RESULT); // SetOption4 - Switch between MQTT RESULT or COMMAND
|
||||
Response_P(S_JSON_COMMAND_SVALUE, scommand, GetStateText(bitRead(power, device -1)));
|
||||
Response_P(S_JSON_COMMAND_SVALUE, scommand, GetStateText(bitRead(TasmotaGlobal.power, device -1)));
|
||||
MqttPublish(stopic);
|
||||
|
||||
if (!Settings.flag4.only_json_message) { // SetOption90 - Disable non-json MQTT response
|
||||
GetTopic_P(stopic, STAT, mqtt_topic, scommand);
|
||||
Response_P(GetStateText(bitRead(power, device -1)));
|
||||
Response_P(GetStateText(bitRead(TasmotaGlobal.power, device -1)));
|
||||
MqttPublish(stopic, Settings.flag.mqtt_power_retain); // CMND_POWERRETAIN
|
||||
}
|
||||
#ifdef USE_SONOFF_IFAN
|
||||
@ -467,7 +467,7 @@ void MqttPublishPowerBlinkState(uint32_t device)
|
||||
device = 1;
|
||||
}
|
||||
Response_P(PSTR("{\"%s\":\"" D_JSON_BLINK " %s\"}"),
|
||||
GetPowerDevice(scommand, device, sizeof(scommand), Settings.flag.device_index_enable), GetStateText(bitRead(blink_mask, device -1))); // SetOption26 - Switch between POWER or POWER1
|
||||
GetPowerDevice(scommand, device, sizeof(scommand), Settings.flag.device_index_enable), GetStateText(bitRead(TasmotaGlobal.blink_mask, device -1))); // SetOption26 - Switch between POWER or POWER1
|
||||
|
||||
MqttPublishPrefixTopic_P(RESULT_OR_STAT, S_RSLT_POWER);
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ void EnergyUpdateTotal(float value, bool kwh)
|
||||
|
||||
void Energy200ms(void)
|
||||
{
|
||||
Energy.power_on = (power != 0) | Settings.flag.no_power_on_check; // SetOption21 - Show voltage even if powered off
|
||||
Energy.power_on = (TasmotaGlobal.power != 0) | Settings.flag.no_power_on_check; // SetOption21 - Show voltage even if powered off
|
||||
|
||||
Energy.fifth_second++;
|
||||
if (5 == Energy.fifth_second) {
|
||||
@ -439,12 +439,12 @@ void EnergyMarginCheck(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (power && (energy_power_u <= Settings.energy_max_power_limit)) {
|
||||
else if (TasmotaGlobal.power && (energy_power_u <= Settings.energy_max_power_limit)) {
|
||||
Energy.mplh_counter = 0;
|
||||
Energy.mplr_counter = 0;
|
||||
Energy.mplw_counter = 0;
|
||||
}
|
||||
if (!power) {
|
||||
if (!TasmotaGlobal.power) {
|
||||
if (Energy.mplw_counter) {
|
||||
Energy.mplw_counter--;
|
||||
} else {
|
||||
@ -505,10 +505,10 @@ void EnergyEverySecond(void)
|
||||
{
|
||||
// Overtemp check
|
||||
if (TasmotaGlobal.global_update) {
|
||||
if (power && !isnan(global_temperature_celsius) && (global_temperature_celsius > (float)Settings.param[P_OVER_TEMP])) { // Device overtemp, turn off relays
|
||||
if (TasmotaGlobal.power && !isnan(TasmotaGlobal.temperature_celsius) && (TasmotaGlobal.temperature_celsius > (float)Settings.param[P_OVER_TEMP])) { // Device overtemp, turn off relays
|
||||
|
||||
char temperature[33];
|
||||
dtostrfd(global_temperature_celsius, 1, temperature);
|
||||
dtostrfd(TasmotaGlobal.temperature_celsius, 1, temperature);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("NRG: GlobTemp %s"), temperature);
|
||||
|
||||
SetAllPower(POWER_ALL_OFF, SRC_OVERTEMP);
|
||||
|
@ -1668,7 +1668,7 @@ void ResponseLightState(uint8_t append)
|
||||
|
||||
void LightPreparePower(power_t channels = 0xFFFFFFFF) { // 1 = only RGB, 2 = only CT, 3 = both RGB and CT
|
||||
#ifdef DEBUG_LIGHT
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, "LightPreparePower power=%d Light.power=%d", power, Light.power);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, "LightPreparePower power=%d Light.power=%d", TasmotaGlobal.power, Light.power);
|
||||
#endif
|
||||
// If multi-channels, then we only switch off channels with a value of zero
|
||||
if (Light.pwm_multi_channels) {
|
||||
@ -1731,9 +1731,9 @@ void LightPreparePower(power_t channels = 0xFFFFFFFF) { // 1 = only RGB, 2 =
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LIGHT
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, "LightPreparePower End power=%d Light.power=%d", power, Light.power);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, "LightPreparePower End power=%d Light.power=%d", TasmotaGlobal.power, Light.power);
|
||||
#endif
|
||||
Light.power = power >> (Light.device - 1); // reset next state, works also with unlinked RGB/CT
|
||||
Light.power = TasmotaGlobal.power >> (Light.device - 1); // reset next state, works also with unlinked RGB/CT
|
||||
ResponseLightState(0);
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ void MqttPublishDomoticzPowerState(uint8_t device) {
|
||||
char svalue[8]; // Dimmer value
|
||||
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("%d"), Settings.light_dimmer);
|
||||
Response_P(DOMOTICZ_MESSAGE, (int)Settings.domoticz_relay_idx[device -1], (power & (1 << (device -1))) ? 1 : 0, (light_type) ? svalue : "", DomoticzBatteryQuality(), DomoticzRssiQuality());
|
||||
Response_P(DOMOTICZ_MESSAGE, (int)Settings.domoticz_relay_idx[device -1], (TasmotaGlobal.power & (1 << (device -1))) ? 1 : 0, (light_type) ? svalue : "", DomoticzBatteryQuality(), DomoticzRssiQuality());
|
||||
MqttPublish(domoticz_in_topic);
|
||||
#ifdef USE_SONOFF_IFAN
|
||||
}
|
||||
@ -293,7 +293,7 @@ bool DomoticzMqttData(void) {
|
||||
} else {
|
||||
return true; // Invalid data
|
||||
}
|
||||
if (light_type && (Settings.light_dimmer == nvalue) && ((power >> i) &1)) {
|
||||
if (light_type && (Settings.light_dimmer == nvalue) && ((TasmotaGlobal.power >> i) &1)) {
|
||||
return true; // State already set
|
||||
}
|
||||
snprintf_P(XdrvMailbox.topic, XdrvMailbox.index, PSTR("/" D_CMND_DIMMER));
|
||||
@ -302,7 +302,7 @@ bool DomoticzMqttData(void) {
|
||||
} else
|
||||
#endif // USE_LIGHT
|
||||
if (1 == nvalue || 0 == nvalue) {
|
||||
if (((power >> i) &1) == (power_t)nvalue) {
|
||||
if (((TasmotaGlobal.power >> i) &1) == (power_t)nvalue) {
|
||||
return true; // Stop loop
|
||||
}
|
||||
snprintf_P(XdrvMailbox.topic, XdrvMailbox.index, PSTR("/" D_CMND_POWER "%s"), (devices_present > 1) ? stemp1 : "");
|
||||
|
@ -830,7 +830,7 @@ void RulesEvery50ms(void)
|
||||
if (Settings.rule_enabled && !Rules.busy) { // Any rule enabled
|
||||
char json_event[120];
|
||||
|
||||
if (-1 == Rules.new_power) { Rules.new_power = power; }
|
||||
if (-1 == Rules.new_power) { Rules.new_power = TasmotaGlobal.power; }
|
||||
if (Rules.new_power != Rules.old_power) {
|
||||
if (Rules.old_power != -1) {
|
||||
for (uint32_t i = 0; i < devices_present; i++) {
|
||||
|
@ -2343,15 +2343,15 @@ chknext:
|
||||
break;
|
||||
case 'g':
|
||||
if (!strncmp(vname, "gtmp", 4)) {
|
||||
fvar = global_temperature_celsius;
|
||||
fvar = TasmotaGlobal.temperature_celsius;
|
||||
goto exit;
|
||||
}
|
||||
if (!strncmp(vname, "ghum", 4)) {
|
||||
fvar = global_humidity;
|
||||
fvar = TasmotaGlobal.humidity;
|
||||
goto exit;
|
||||
}
|
||||
if (!strncmp(vname, "gprs", 4)) {
|
||||
fvar = global_pressure_hpa;
|
||||
fvar = TasmotaGlobal.pressure_hpa;
|
||||
goto exit;
|
||||
}
|
||||
if (!strncmp(vname, "gtopic", 6)) {
|
||||
@ -2681,7 +2681,7 @@ chknext:
|
||||
GetNumericArgument(vname + 4, OPER_EQU, &fvar, 0);
|
||||
uint8_t index = fvar;
|
||||
if (index<=devices_present) {
|
||||
fvar = bitRead(power, index - 1);
|
||||
fvar = bitRead(TasmotaGlobal.power, index - 1);
|
||||
} else {
|
||||
fvar = -1;
|
||||
}
|
||||
|
@ -776,7 +776,7 @@ void DisplayText(void)
|
||||
buttons[num]->vpower.disable=dis;
|
||||
if (!dis) {
|
||||
if (buttons[num]->vpower.is_virtual) buttons[num]->xdrawButton(buttons[num]->vpower.on_off);
|
||||
else buttons[num]->xdrawButton(bitRead(power,num));
|
||||
else buttons[num]->xdrawButton(bitRead(TasmotaGlobal.power,num));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -828,7 +828,7 @@ void DisplayText(void)
|
||||
renderer->GetColorFromIndex(fill),renderer->GetColorFromIndex(textcolor),bbuff,textsize);
|
||||
if (!bflags) {
|
||||
// power button
|
||||
if (dflg) buttons[num]->xdrawButton(bitRead(power,num));
|
||||
if (dflg) buttons[num]->xdrawButton(bitRead(TasmotaGlobal.power,num));
|
||||
buttons[num]->vpower.is_virtual=0;
|
||||
} else {
|
||||
// virtual button
|
||||
@ -2124,7 +2124,7 @@ uint8_t vbutt=0;
|
||||
buttons[count]->press(true);
|
||||
if (buttons[count]->justPressed()) {
|
||||
if (!buttons[count]->vpower.is_virtual) {
|
||||
uint8_t pwr=bitRead(power, rbutt);
|
||||
uint8_t pwr=bitRead(TasmotaGlobal.power, rbutt);
|
||||
if (!SendKey(KEY_BUTTON, rbutt+1, POWER_TOGGLE)) {
|
||||
ExecuteCommandPower(rbutt+1, POWER_TOGGLE, SRC_BUTTON);
|
||||
Touch_RDW_BUTT(count, !pwr);
|
||||
@ -2171,7 +2171,7 @@ uint8_t vbutt=0;
|
||||
}
|
||||
if (!buttons[count]->vpower.is_virtual) {
|
||||
// check if power button stage changed
|
||||
uint8_t pwr = bitRead(power, rbutt);
|
||||
uint8_t pwr = bitRead(TasmotaGlobal.power, rbutt);
|
||||
uint8_t vpwr = buttons[count]->vpower.on_off;
|
||||
if (pwr != vpwr) {
|
||||
Touch_RDW_BUTT(count, pwr);
|
||||
|
@ -270,9 +270,9 @@ void UpdateDevices() {
|
||||
if (fnId > TUYA_MCU_FUNC_NONE && Settings.tuya_fnid_map[i].dpid > 0) {
|
||||
|
||||
if (fnId >= TUYA_MCU_FUNC_REL1 && fnId <= TUYA_MCU_FUNC_REL8) { //Relay
|
||||
bitClear(rel_inverted, fnId - TUYA_MCU_FUNC_REL1);
|
||||
bitClear(TasmotaGlobal.rel_inverted, fnId - TUYA_MCU_FUNC_REL1);
|
||||
} else if (fnId >= TUYA_MCU_FUNC_REL1_INV && fnId <= TUYA_MCU_FUNC_REL8_INV) { // Inverted Relay
|
||||
bitSet(rel_inverted, fnId - TUYA_MCU_FUNC_REL1_INV);
|
||||
bitSet(TasmotaGlobal.rel_inverted, fnId - TUYA_MCU_FUNC_REL1_INV);
|
||||
}
|
||||
|
||||
}
|
||||
@ -401,7 +401,7 @@ bool TuyaSetPower(void)
|
||||
if (dpid == 0) dpid = TuyaGetDpId(TUYA_MCU_FUNC_REL1_INV + active_device - 1);
|
||||
|
||||
if (source != SRC_SWITCH && TuyaSerial) { // ignore to prevent loop from pushing state from faceplate interaction
|
||||
TuyaSendBool(dpid, bitRead(rpower, active_device-1) ^ bitRead(rel_inverted, active_device-1));
|
||||
TuyaSendBool(dpid, bitRead(rpower, active_device-1) ^ bitRead(TasmotaGlobal.rel_inverted, active_device-1));
|
||||
delay(20); // Hack when power is off and dimmer is set then both commands go too soon to Serial out.
|
||||
status = true;
|
||||
}
|
||||
@ -568,13 +568,13 @@ void TuyaProcessStatePacket(void) {
|
||||
if (Tuya.buffer[dpidStart + 1] == 1) { // Data Type 1
|
||||
|
||||
if (fnId >= TUYA_MCU_FUNC_REL1 && fnId <= TUYA_MCU_FUNC_REL8) {
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: RX Relay-%d --> MCU State: %s Current State:%s"), fnId - TUYA_MCU_FUNC_REL1 + 1, Tuya.buffer[dpidStart + 4]?"On":"Off",bitRead(power, fnId - TUYA_MCU_FUNC_REL1)?"On":"Off");
|
||||
if ((power || Settings.light_dimmer > 0) && (Tuya.buffer[dpidStart + 4] != bitRead(power, fnId - TUYA_MCU_FUNC_REL1))) {
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: RX Relay-%d --> MCU State: %s Current State:%s"), fnId - TUYA_MCU_FUNC_REL1 + 1, Tuya.buffer[dpidStart + 4]?"On":"Off",bitRead(TasmotaGlobal.power, fnId - TUYA_MCU_FUNC_REL1)?"On":"Off");
|
||||
if ((TasmotaGlobal.power || Settings.light_dimmer > 0) && (Tuya.buffer[dpidStart + 4] != bitRead(TasmotaGlobal.power, fnId - TUYA_MCU_FUNC_REL1))) {
|
||||
ExecuteCommandPower(fnId - TUYA_MCU_FUNC_REL1 + 1, Tuya.buffer[dpidStart + 4], SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction
|
||||
}
|
||||
} else if (fnId >= TUYA_MCU_FUNC_REL1_INV && fnId <= TUYA_MCU_FUNC_REL8_INV) {
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: RX Relay-%d-Inverted --> MCU State: %s Current State:%s"), fnId - TUYA_MCU_FUNC_REL1_INV + 1, Tuya.buffer[dpidStart + 4]?"Off":"On",bitRead(power, fnId - TUYA_MCU_FUNC_REL1_INV) ^ 1?"Off":"On");
|
||||
if (Tuya.buffer[dpidStart + 4] != bitRead(power, fnId - TUYA_MCU_FUNC_REL1_INV) ^ 1) {
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: RX Relay-%d-Inverted --> MCU State: %s Current State:%s"), fnId - TUYA_MCU_FUNC_REL1_INV + 1, Tuya.buffer[dpidStart + 4]?"Off":"On",bitRead(TasmotaGlobal.power, fnId - TUYA_MCU_FUNC_REL1_INV) ^ 1?"Off":"On");
|
||||
if (Tuya.buffer[dpidStart + 4] != bitRead(TasmotaGlobal.power, fnId - TUYA_MCU_FUNC_REL1_INV) ^ 1) {
|
||||
ExecuteCommandPower(fnId - TUYA_MCU_FUNC_REL1_INV + 1, Tuya.buffer[dpidStart + 4] ^ 1, SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction
|
||||
}
|
||||
} else if (fnId >= TUYA_MCU_FUNC_SWT1 && fnId <= TUYA_MCU_FUNC_SWT4) {
|
||||
@ -613,7 +613,7 @@ void TuyaProcessStatePacket(void) {
|
||||
|
||||
if (Tuya.ignore_dimmer_cmd_timeout < millis()) {
|
||||
|
||||
if ((power || Settings.flag3.tuya_apply_o20) && ((Tuya.Levels[dimIndex] > 0) && (Tuya.Levels[dimIndex] != Tuya.Snapshot[dimIndex]))) { // SetOption54 - Apply SetOption20 settings to Tuya device
|
||||
if ((TasmotaGlobal.power || Settings.flag3.tuya_apply_o20) && ((Tuya.Levels[dimIndex] > 0) && (Tuya.Levels[dimIndex] != Tuya.Snapshot[dimIndex]))) { // SetOption54 - Apply SetOption20 settings to Tuya device
|
||||
|
||||
Tuya.ignore_dim = true;
|
||||
skip_light_fade = true;
|
||||
|
@ -69,7 +69,7 @@ void PS16DZSerialSendUpdateCommand(void)
|
||||
|
||||
char tx_buffer[80];
|
||||
snprintf_P(tx_buffer, sizeof(tx_buffer), PSTR("AT+UPDATE=\"sequence\":\"%d%03d\",\"switch\":\"%s\",\"bright\":%d"),
|
||||
LocalTime(), millis()%1000, power?"on":"off", light_state_dimmer);
|
||||
LocalTime(), millis()%1000, TasmotaGlobal.power?"on":"off", light_state_dimmer);
|
||||
|
||||
PS16DZSerialSend(tx_buffer);
|
||||
}
|
||||
@ -120,7 +120,7 @@ void PS16DZSerialInput(void)
|
||||
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PSZ: Switch %d"), switch_state);
|
||||
|
||||
is_switch_change = (switch_state != power);
|
||||
is_switch_change = (switch_state != TasmotaGlobal.power);
|
||||
if (is_switch_change) {
|
||||
ExecuteCommandPower(1, switch_state, SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction
|
||||
}
|
||||
@ -131,7 +131,7 @@ void PS16DZSerialInput(void)
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PSZ: Brightness %d"), Ps16dz.dimmer);
|
||||
|
||||
is_brightness_change = Ps16dz.dimmer != Settings.light_dimmer;
|
||||
if (power && (Ps16dz.dimmer > 0) && is_brightness_change) {
|
||||
if (TasmotaGlobal.power && (Ps16dz.dimmer > 0) && is_brightness_change) {
|
||||
snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_DIMMER " %d"), Ps16dz.dimmer);
|
||||
ExecuteCommand(scmnd, SRC_SWITCH);
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ void HueLightStatus1(uint8_t device, String *response)
|
||||
const size_t buf_size = 256;
|
||||
char * buf = (char*) malloc(buf_size); // temp buffer for strings, avoid stack
|
||||
|
||||
snprintf_P(buf, buf_size, PSTR("{\"on\":%s,"), (power & (1 << (device-1))) ? "true" : "false");
|
||||
snprintf_P(buf, buf_size, PSTR("{\"on\":%s,"), (TasmotaGlobal.power & (1 << (device-1))) ? "true" : "false");
|
||||
// Brightness for all devices with PWM
|
||||
if ((1 == echo_gen) || (LST_SINGLE <= local_light_subtype)) { // force dimmer for 1st gen Echo
|
||||
snprintf_P(buf, buf_size, PSTR("%s\"bri\":%d,"), buf, bri);
|
||||
|
@ -298,9 +298,9 @@ void HandleUpnpEvent(void)
|
||||
}
|
||||
|
||||
#ifdef USE_UNISHOX_COMPRESSION
|
||||
snprintf_P(event, sizeof(event), Decompress(WEMO_RESPONSE_STATE_SOAP, WEMO_RESPONSE_STATE_SOAP_SIZE).c_str(), state, bitRead(power, devices_present -1), state);
|
||||
snprintf_P(event, sizeof(event), Decompress(WEMO_RESPONSE_STATE_SOAP, WEMO_RESPONSE_STATE_SOAP_SIZE).c_str(), state, bitRead(TasmotaGlobal.power, devices_present -1), state);
|
||||
#else
|
||||
snprintf_P(event, sizeof(event), WEMO_RESPONSE_STATE_SOAP, state, bitRead(power, devices_present -1), state);
|
||||
snprintf_P(event, sizeof(event), WEMO_RESPONSE_STATE_SOAP, state, bitRead(TasmotaGlobal.power, devices_present -1), state);
|
||||
#endif
|
||||
WSSend(200, CT_XML, event);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ uint8_t GetFanspeed(void)
|
||||
011x = 2
|
||||
101x = 3 (ifan02) or 100x = 3 (ifan03)
|
||||
*/
|
||||
uint8_t fanspeed = (uint8_t)(power &0xF) >> 1;
|
||||
uint8_t fanspeed = (uint8_t)(TasmotaGlobal.power &0xF) >> 1;
|
||||
if (fanspeed) { fanspeed = (fanspeed >> 1) +1; } // 0, 1, 2, 3
|
||||
return fanspeed;
|
||||
}
|
||||
@ -236,7 +236,7 @@ void SonoffIfanUpdate(void)
|
||||
if (ifan_restart_flag && (4 == TasmotaGlobal.uptime) && (SONOFF_IFAN02 == my_module_type)) { // Microcontroller needs 3 seconds before accepting commands
|
||||
ifan_restart_flag = false;
|
||||
SetDevicePower(1, SRC_RETRY); // Sync with default power on state microcontroller being Light ON and Fan OFF
|
||||
SetDevicePower(power, SRC_RETRY); // Set required power on state
|
||||
SetDevicePower(TasmotaGlobal.power, SRC_RETRY); // Set required power on state
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ void ShutterInit(void)
|
||||
shutters_present = 0;
|
||||
ShutterGlobal.RelayShutterMask = 0;
|
||||
//Initialize to get relay that changed
|
||||
ShutterGlobal.RelayOldMask = power;
|
||||
ShutterGlobal.RelayOldMask = TasmotaGlobal.power;
|
||||
|
||||
|
||||
// if shutter 4 is unused
|
||||
@ -436,10 +436,10 @@ void ShutterPowerOff(uint8_t i) {
|
||||
}
|
||||
switch (Shutter[i].switch_mode) {
|
||||
case SHT_SWITCH:
|
||||
if ((1 << (Settings.shutter_startrelay[i]-1)) & power) {
|
||||
if ((1 << (Settings.shutter_startrelay[i]-1)) & TasmotaGlobal.power) {
|
||||
ExecuteCommandPowerShutter(Settings.shutter_startrelay[i], 0, SRC_SHUTTER);
|
||||
}
|
||||
if ((1 << (Settings.shutter_startrelay[i])) & power) {
|
||||
if ((1 << (Settings.shutter_startrelay[i])) & TasmotaGlobal.power) {
|
||||
ExecuteCommandPowerShutter(Settings.shutter_startrelay[i]+1, 0, SRC_SHUTTER);
|
||||
}
|
||||
break;
|
||||
@ -449,7 +449,7 @@ void ShutterPowerOff(uint8_t i) {
|
||||
if ((SRC_PULSETIMER == last_source || SRC_SHUTTER == last_source || SRC_WEBGUI == last_source)) {
|
||||
ExecuteCommandPowerShutter(cur_relay, 1, SRC_SHUTTER);
|
||||
// switch off direction relay to make it power less
|
||||
if ((1 << (Settings.shutter_startrelay[i])) & power) {
|
||||
if ((1 << (Settings.shutter_startrelay[i])) & TasmotaGlobal.power) {
|
||||
ExecuteCommandPowerShutter(Settings.shutter_startrelay[i]+1, 0, SRC_SHUTTER);
|
||||
}
|
||||
} else {
|
||||
@ -597,7 +597,7 @@ void ShutterRelayChanged(void)
|
||||
char stemp1[10];
|
||||
|
||||
for (uint32_t i = 0; i < shutters_present; i++) {
|
||||
power_t powerstate_local = (power >> (Settings.shutter_startrelay[i] -1)) & 3;
|
||||
power_t powerstate_local = (TasmotaGlobal.power >> (Settings.shutter_startrelay[i] -1)) & 3;
|
||||
// SRC_IGNORE added because INTERLOCK function bite causes this as last source for changing the relay.
|
||||
//uint8 manual_relays_changed = ((ShutterGlobal.RelayCurrentMask >> (Settings.shutter_startrelay[i] -1)) & 3) && SRC_IGNORE != last_source && SRC_SHUTTER != last_source && SRC_PULSETIMER != last_source ;
|
||||
uint8 manual_relays_changed = ((ShutterGlobal.RelayCurrentMask >> (Settings.shutter_startrelay[i] -1)) & 3) && SRC_SHUTTER != last_source && SRC_PULSETIMER != last_source ;
|
||||
@ -1081,7 +1081,7 @@ void CmndShutterPosition(void)
|
||||
break;
|
||||
case SHT_TIME:
|
||||
if (!ShutterGlobal.skip_relay_change) {
|
||||
if ( (power >> (Settings.shutter_startrelay[index] -1)) & 3 > 0 ) {
|
||||
if ( (TasmotaGlobal.power >> (Settings.shutter_startrelay[index] -1)) & 3 > 0 ) {
|
||||
ExecuteCommandPowerShutter(Settings.shutter_startrelay[index] + (new_shutterdirection == 1 ? 1 : 0), Shutter[index].switch_mode == SHT_SWITCH ? 0 : 1, SRC_SHUTTER);
|
||||
}
|
||||
ExecuteCommandPowerShutter(Settings.shutter_startrelay[index] + (new_shutterdirection == 1 ? 0 : 1), 1, SRC_SHUTTER);
|
||||
|
@ -53,7 +53,7 @@ void Pcf8574SwitchRelay(void)
|
||||
if (Pcf8574.max_devices > 0 && Pcf8574.pin[i] < 99) {
|
||||
uint8_t board = Pcf8574.pin[i]>>3;
|
||||
uint8_t oldpinmask = Pcf8574.pin_mask[board];
|
||||
uint8_t _val = bitRead(rel_inverted, i) ? !relay_state : relay_state;
|
||||
uint8_t _val = bitRead(TasmotaGlobal.rel_inverted, i) ? !relay_state : relay_state;
|
||||
|
||||
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PCF: Pcf8574SwitchRelay %d on pin %d"), i,state);
|
||||
|
||||
@ -67,7 +67,7 @@ void Pcf8574SwitchRelay(void)
|
||||
Wire.write(Pcf8574.pin_mask[board]);
|
||||
Pcf8574.error = Wire.endTransmission();
|
||||
}
|
||||
//pcf8574.write(Pcf8574.pin[i]&0x7, rel_inverted[i] ? !state : state);
|
||||
//pcf8574.write(Pcf8574.pin[i]&0x7, TasmotaGlobal.rel_inverted[i] ? !state : state);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -122,7 +122,7 @@ void Pcf8574Init(void)
|
||||
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PCF: I2C shift i %d: %d. Powerstate: %d, devices_present: %d"), i,_result, Settings.power>>i&1, devices_present);
|
||||
if (_result > 0) {
|
||||
Pcf8574.pin[devices_present] = i + 8 * idx;
|
||||
bitWrite(rel_inverted, devices_present, Settings.flag3.pcf8574_ports_inverted); // SetOption81 - Invert all ports on PCF8574 devices
|
||||
bitWrite(TasmotaGlobal.rel_inverted, devices_present, Settings.flag3.pcf8574_ports_inverted); // SetOption81 - Invert all ports on PCF8574 devices
|
||||
devices_present++;
|
||||
Pcf8574.max_connected_ports++;
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ void PWMModulePreInit(void)
|
||||
PWMDimmerSetPoweredOffLed();
|
||||
|
||||
// The relay initializes to on. If the power is supposed to be off, turn the relay off.
|
||||
// if (!power && PinUsed(GPIO_REL1)) digitalWrite(Pin(GPIO_REL1), bitRead(rel_inverted, 0) ? 1 : 0);
|
||||
// if (!TasmotaGlobal.power && PinUsed(GPIO_REL1)) digitalWrite(Pin(GPIO_REL1), bitRead(TasmotaGlobal.rel_inverted, 0) ? 1 : 0);
|
||||
|
||||
#ifdef USE_PWM_DIMMER_REMOTE
|
||||
// If remote device mode is enabled, set the device group count to the number of buttons
|
||||
@ -184,7 +184,7 @@ void PWMDimmerSetPoweredOffLed(void)
|
||||
{
|
||||
// Set the powered-off LED state.
|
||||
if (PinUsed(GPIO_LEDLNK)) {
|
||||
bool power_off_led_on = !power && Settings.flag4.powered_off_led;
|
||||
bool power_off_led_on = !TasmotaGlobal.power && Settings.flag4.powered_off_led;
|
||||
if (ledlnk_inverted) power_off_led_on ^= 1;
|
||||
digitalWrite(Pin(GPIO_LEDLNK), power_off_led_on);
|
||||
}
|
||||
@ -192,7 +192,7 @@ void PWMDimmerSetPoweredOffLed(void)
|
||||
|
||||
void PWMDimmerSetPower(void)
|
||||
{
|
||||
DigitalWrite(GPIO_REL1, 0, bitRead(rel_inverted, 0) ? !power : power);
|
||||
DigitalWrite(GPIO_REL1, 0, bitRead(TasmotaGlobal.rel_inverted, 0) ? !TasmotaGlobal.power : TasmotaGlobal.power);
|
||||
PWMDimmerSetBrightnessLeds(-1);
|
||||
PWMDimmerSetPoweredOffLed();
|
||||
}
|
||||
@ -272,11 +272,11 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
|
||||
|
||||
// Initialize some variables.
|
||||
#ifdef USE_PWM_DIMMER_REMOTE
|
||||
bool power_is_on = (active_remote_pwm_dimmer ? active_remote_pwm_dimmer->power_on : power);
|
||||
bool power_is_on = (active_remote_pwm_dimmer ? active_remote_pwm_dimmer->power_on : TasmotaGlobal.power);
|
||||
bool is_power_button = (button_index == power_button_index);
|
||||
bool is_down_button = (button_index == down_button_index);
|
||||
#else // USE_PWM_DIMMER_REMOTE
|
||||
bool power_is_on = power;
|
||||
bool power_is_on = TasmotaGlobal.power;
|
||||
bool is_power_button = !button_index;
|
||||
bool is_down_button = (button_index == (power_button_index ? 0 : 1));
|
||||
#endif // USE_PWM_DIMMER_REMOTE
|
||||
@ -537,7 +537,7 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
|
||||
}
|
||||
else {
|
||||
#endif // USE_PWM_DIMMER_REMOTE
|
||||
new_power = power ^ 1;
|
||||
new_power = TasmotaGlobal.power ^ 1;
|
||||
#ifdef USE_PWM_DIMMER_REMOTE
|
||||
}
|
||||
#endif // USE_PWM_DIMMER_REMOTE
|
||||
|
@ -323,7 +323,7 @@ uint8_t ThermostatInputStatus(uint8_t input_switch)
|
||||
|
||||
uint8_t ThermostatOutputStatus(uint8_t output_switch)
|
||||
{
|
||||
return (uint8_t)bitRead(power, (output_switch - 1));
|
||||
return (uint8_t)bitRead(TasmotaGlobal.power, (output_switch - 1));
|
||||
}
|
||||
|
||||
int16_t ThermostatCelsiusToFahrenheit(const int32_t deg, uint8_t conv_type) {
|
||||
@ -1320,7 +1320,7 @@ void ThermostatDebug(uint8_t ctr_output)
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_ctr_checkpoint: %s"), result_chr);
|
||||
dtostrfd(TasmotaGlobal.uptime, 0, result_chr);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("uptime: %s"), result_chr);
|
||||
dtostrfd(power, 0, result_chr);
|
||||
dtostrfd(TasmotaGlobal.power, 0, result_chr);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("power: %s"), result_chr);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("------ Thermostat End ------"));
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(""));
|
||||
|
@ -926,7 +926,7 @@ miel_hvac_input_settings(struct miel_hvac_softc *sc,
|
||||
return;
|
||||
}
|
||||
|
||||
if (bitRead(power, sc->sc_device) != !!state)
|
||||
if (bitRead(TasmotaGlobal.power, sc->sc_device) != !!state)
|
||||
ExecuteCommandPower(sc->sc_device, state, SRC_SWITCH);
|
||||
|
||||
publish = (sc->sc_settings_set == 0) ||
|
||||
|
@ -83,9 +83,9 @@ void Sgp30Update(void) // Perform every second to ensure proper operation of th
|
||||
if (!sgp.IAQmeasure()) {
|
||||
return; // Measurement failed
|
||||
}
|
||||
if (TasmotaGlobal.global_update && (global_humidity > 0) && !isnan(global_temperature_celsius)) {
|
||||
if (TasmotaGlobal.global_update && (TasmotaGlobal.humidity > 0) && !isnan(TasmotaGlobal.temperature_celsius)) {
|
||||
// abs hum in mg/m3
|
||||
sgp30_abshum = sgp30_AbsoluteHumidity(global_temperature_celsius, global_humidity);
|
||||
sgp30_abshum = sgp30_AbsoluteHumidity(TasmotaGlobal.temperature_celsius, TasmotaGlobal.humidity);
|
||||
sgp.setHumidity(sgp30_abshum*1000);
|
||||
}
|
||||
sgp30_ready = true;
|
||||
@ -115,13 +115,13 @@ void Sgp30Show(bool json)
|
||||
if (sgp30_ready) {
|
||||
char abs_hum[33];
|
||||
|
||||
if (TasmotaGlobal.global_update && (global_humidity > 0) && !isnan(global_temperature_celsius)) {
|
||||
if (TasmotaGlobal.global_update && (TasmotaGlobal.humidity > 0) && !isnan(TasmotaGlobal.temperature_celsius)) {
|
||||
// has humidity + temperature
|
||||
dtostrfd(sgp30_abshum,4,abs_hum);
|
||||
}
|
||||
if (json) {
|
||||
ResponseAppend_P(PSTR(",\"SGP30\":{\"" D_JSON_ECO2 "\":%d,\"" D_JSON_TVOC "\":%d"), sgp.eCO2, sgp.TVOC);
|
||||
if (TasmotaGlobal.global_update && global_humidity>0 && !isnan(global_temperature_celsius)) {
|
||||
if (TasmotaGlobal.global_update && TasmotaGlobal.humidity>0 && !isnan(TasmotaGlobal.temperature_celsius)) {
|
||||
ResponseAppend_P(PSTR(",\"" D_JSON_AHUM "\":%s"),abs_hum);
|
||||
}
|
||||
ResponseJsonEnd();
|
||||
|
@ -65,8 +65,8 @@ void CCS811Update(void) // Perform every n second
|
||||
TVOC = ccs.getTVOC();
|
||||
eCO2 = ccs.geteCO2();
|
||||
CCS811_ready = 1;
|
||||
if (TasmotaGlobal.global_update && (global_humidity > 0) && !isnan(global_temperature_celsius)) {
|
||||
ccs.setEnvironmentalData((uint8_t)global_humidity, global_temperature_celsius);
|
||||
if (TasmotaGlobal.global_update && (TasmotaGlobal.humidity > 0) && !isnan(TasmotaGlobal.temperature_celsius)) {
|
||||
ccs.setEnvironmentalData((uint8_t)TasmotaGlobal.humidity, TasmotaGlobal.temperature_celsius);
|
||||
}
|
||||
ecnt = 0;
|
||||
}
|
||||
|
@ -49,17 +49,17 @@ void HandleMetrics(void)
|
||||
// Wi-Fi Signal strength
|
||||
WSContentSend_P(PSTR("# TYPE tasmota_wifi_station_signal_dbm gauge\ntasmota_wifi_station_signal_dbm{mac_address=\"%s\"} %d\n"), WiFi.BSSIDstr().c_str(), WiFi.RSSI());
|
||||
|
||||
if (!isnan(global_temperature_celsius)) {
|
||||
dtostrfd(global_temperature_celsius, Settings.flag2.temperature_resolution, parameter);
|
||||
WSContentSend_P(PSTR("# TYPE global_temperature_celsius gauge\nglobal_temperature_celsius %s\n"), parameter);
|
||||
if (!isnan(TasmotaGlobal.temperature_celsius)) {
|
||||
dtostrfd(TasmotaGlobal.temperature_celsius, Settings.flag2.temperature_resolution, parameter);
|
||||
WSContentSend_P(PSTR("# TYPE tasmotaglobal_temperature_celsius gauge\ntasmotaglobal_temperature_celsius %s\n"), parameter);
|
||||
}
|
||||
if (global_humidity != 0) {
|
||||
dtostrfd(global_humidity, Settings.flag2.humidity_resolution, parameter);
|
||||
WSContentSend_P(PSTR("# TYPE global_humidity gauge\nglobal_humidity %s\n"), parameter);
|
||||
if (TasmotaGlobal.humidity != 0) {
|
||||
dtostrfd(TasmotaGlobal.humidity, Settings.flag2.humidity_resolution, parameter);
|
||||
WSContentSend_P(PSTR("# TYPE tasmotaglobal_humidity gauge\ntasmotaglobal_humidity %s\n"), parameter);
|
||||
}
|
||||
if (global_pressure_hpa != 0) {
|
||||
dtostrfd(global_pressure_hpa, Settings.flag2.pressure_resolution, parameter);
|
||||
WSContentSend_P(PSTR("# TYPE global_pressure_hpa gauge\nglobal_pressure_hpa %s\n"), parameter);
|
||||
if (TasmotaGlobal.pressure_hpa != 0) {
|
||||
dtostrfd(TasmotaGlobal.pressure_hpa, Settings.flag2.pressure_resolution, parameter);
|
||||
WSContentSend_P(PSTR("# TYPE tasmotaglobal_pressure_hpa gauge\ntasmotaglobal_pressure_hpa %s\n"), parameter);
|
||||
}
|
||||
|
||||
#ifdef USE_ENERGY_SENSOR
|
||||
|
Loading…
x
Reference in New Issue
Block a user