From 184601f0f9b9b4a9c2daa5003657d445f60f23d3 Mon Sep 17 00:00:00 2001 From: Paul C Diem Date: Thu, 1 Oct 2020 22:30:37 -0500 Subject: [PATCH] Fix PWM Dimmer to send DGR_ITEM_FLAGS after more-to-come msgs to finalize changes so remote devices send tele updates. --- tasmota/support_device_groups.ino | 1 + tasmota/xdrv_35_pwm_dimmer.ino | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tasmota/support_device_groups.ino b/tasmota/support_device_groups.ino index 552ecb44a..c75da06aa 100644 --- a/tasmota/support_device_groups.ino +++ b/tasmota/support_device_groups.ino @@ -312,6 +312,7 @@ void SendReceiveDeviceGroupMessage(struct device_group * device_group, struct de #ifdef DEVICE_GROUPS_DEBUG switch (item) { + case DGR_ITEM_FLAGS: case DGR_ITEM_LIGHT_FADE: case DGR_ITEM_LIGHT_SPEED: case DGR_ITEM_LIGHT_BRI: diff --git a/tasmota/xdrv_35_pwm_dimmer.ino b/tasmota/xdrv_35_pwm_dimmer.ino index 648df5ea3..0e7a7bea8 100644 --- a/tasmota/xdrv_35_pwm_dimmer.ino +++ b/tasmota/xdrv_35_pwm_dimmer.ino @@ -279,7 +279,7 @@ void PWMDimmerHandleButton(void) int32_t bri_offset = 0; uint8_t power_on_bri = 0; uint8_t dgr_item = 0; - uint8_t dgr_value; + uint8_t dgr_value = 0; uint8_t dgr_more_to_come = false; uint32_t button_index = XdrvMailbox.index; uint32_t now = millis(); @@ -475,7 +475,7 @@ void PWMDimmerHandleButton(void) #endif // USE_PWM_DIMMER_REMOTE power_button_increases_bri ^= 1; #ifdef USE_PWM_DIMMER_REMOTE - dgr_item = 255; + dgr_item = DGR_ITEM_FLAGS; state_updated = true; #endif // USE_PWM_DIMMER_REMOTE } @@ -510,7 +510,7 @@ void PWMDimmerHandleButton(void) // If the down button was tapped and held, we changed the fixed color. Send a final // update. else if (down_button_tapped) { - dgr_item = 255; + dgr_item = DGR_ITEM_FLAGS; } } } @@ -551,7 +551,7 @@ void PWMDimmerHandleButton(void) // button is pressed. The new brightness will be calculated below. if (button_hold_time[button_index] >= now) { bri_offset = (is_down_button ? -1 : 1); - dgr_item = 255; + dgr_item = DGR_ITEM_FLAGS; state_updated = true; } @@ -559,7 +559,7 @@ void PWMDimmerHandleButton(void) // brightness and sent updates with the more-to-come message type while the button was // held. Send a final update. else if (!button_hold_processed[button_index]) { - dgr_item = 255; + dgr_item = DGR_ITEM_FLAGS; state_updated = true; } } @@ -666,7 +666,7 @@ void PWMDimmerHandleButton(void) // update. if (dgr_item) { #ifdef USE_DEVICE_GROUPS - if (dgr_item == 255) dgr_item = 0; +AddLog_P2(LOG_LEVEL_ERROR, PSTR("PWMDimmer: sending DGR item %u"), dgr_item); SendDeviceGroupMessage(power_button_index, (dgr_more_to_come ? DGR_MSGTYP_UPDATE_MORE_TO_COME : DGR_MSGTYP_UPDATE_DIRECT), dgr_item, dgr_value); #endif // USE_DEVICE_GROUPS #ifdef USE_PWM_DIMMER_REMOTE