Merge pull request #7928 from pcdiem/pwm-dimmer3

Use Light module for PWM Dimmer
This commit is contained in:
Theo Arends 2020-03-16 10:08:56 +01:00 committed by GitHub
commit fe4614581c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 423 additions and 763 deletions

View File

@ -6,7 +6,7 @@ UDP multicasts, followed by UDP unicasts if necessary, are used to send updates
To include device groups support in the build, define USE_DEVICE_GROUPS in your user_config_override. This adds 3.5K to the code size. All devices in a group must be running firmware with device group support and have device groups enabled.
To enable device groups, set Option85 to 1.
To enable device groups, execute the command SetOption85 1.
## Device Groups Operation
@ -29,17 +29,15 @@ The items that are sent to the group and the items that are received from the gr
<tr>
<td>DevGroupShare
</td>
<td><in>,&lt;out> = set incoming and outgoing shared item mask (default = 0xffffffff,0xffffffff)
<p>
1 = Power, 2 = Light brightness, 4 = Light fade/speed, 8 = Light scheme, 16 = Light color, 32 = Minimum brightness
<td>&lt;in>,&lt;out> = set incoming and outgoing shared item mask (default = 0xffffffff,0xffffffff)<br>
1 = Power, 2 = Light brightness, 4 = Light fade/speed, 8 = Light scheme, 16 = Light color, 32 = Dimmer settings (presets)
</td>
</tr>
<tr>
<td>GroupTopic&lt;x>
</td>
<td>1 = reset device group &lt;x> MQTT group topic to firmware default (MQTT_GRPTOPIC) and restart
<p>
<value> = set device group &lt;x> MQTT group topic (32 chars max) and restart
<td>1 = reset device group &lt;x> MQTT group topic to firmware default (MQTT_GRPTOPIC) and restart<br>
&lt;value> = set device group &lt;x> MQTT group topic (32 chars max) and restart
</td>
</tr>
</table>

View File

@ -11,100 +11,28 @@ To enable PWM dimmer operation, select the PWM Dimmer module.
Pressing and releasing the power button toggles the power on/off. If the toggle turns the power on, the load is returned to the last brightness it was adjusted to. If Fade is enabled, the load is faded on/off at the rate defined by the Speed setting.
When the power is on, holding the down or up button decreases/increases the brightness (PWM value). The brightness is changed faster at higher brightnesses. The DimmerRange command sets the minimum and maximum PWM values. Brightness values (0 through 255) are scaled to dimmerMin through dimmerMax. Typically, dimmerMin would be set to the lowest value at which the lights show visible light and dimmerMax would be set 1023. If you want to increase the lowest brightness level and/or decrease the highest brightness level, set higher dimmerMin and/or lower dimmerMax values.
When the power is on, holding the down or up button decreases/increases the brightness. The brightness can also be changed using just the power button. When the power is on, holding the power button alternately increases or decreases the brightness. Initially, holding the power button increases the brightness. Releasing and then holding the power button again decreases the brightness.
The brightness can also be changed using just the power button. When the power is on, holding the power button alternately increases or decreases the brightness. Initially, holding the power button increases the brightness. Releasing and then holding the power button again decreases the brightness.
When the power is off, pressing and releasing the down or up button turns the power on at a temporary brightness of the low/high levels set by the DimmerPreset command. Turning the power on at the low preset can also be accomplished by holding the power button while the power is off. The dimmer presets are intended to enable quickly turning on a light to a dim or bright level without changing the normal desired brightness. Turning the power on to a preset does not change the brightness the load will be set to when the switch is turned on the next time. For example, if the light is on and you adjust the brightness to 80 and then turn the light off, when you turn it back on, the brightness will return to 80. If you turn the power off again and then press the down button, the light will be turned on with a brightness of the low preset. If you then turn the light off and on again, the brightness will return to 80.
When the power is off, pressing the down or up button turns the power on at a temporary brightness of the low/high levels set by the BriPreset command (default =10,255). Turning the power on at the low preset can also be accomplished by holding the power button while the power is off. The brightness presets are intended to enable quickly turning on a light to a dim or bright level without changing the normal desired brightness. Turning the power on to a preset does not change the brightness the load will be set to when the switch is turned on the next time. For example, if the light is on and you adjust the brightness to 80 and then turn the light off, when you turn it back on, the brightness will return to 80. If you turn the power off again and then press the down button, the light will be turned on with a brightness of the low preset. If you then turn the light off and on again, the brightness will return to 80.
When the power is off, holding the down or up button publishes an MQTT EVENT command. The topic follows the format of the Full Topic with a prefix of Event (ex. cmnd/LightSwitch1/EVENT). The MQTT payload is Trigger#, where # is 1 if the down button is held or 2 if the up button is held. These triggers can be used in rules on remote devices (ON Event#Trigger1) or by automation software to trigger automations such as scene changes. For example, the Event topic Trigger1 payload could trigger the automation software to turn on the previous scene in a list and the Trigger2 payload could trigger the automation software to turn on the next scene in a list.
If there are LEDs defined in the template, they are turned on to indicate the current brightness. More LEDs are turned on at higher brightnesses. The LedTimeout command enables/disables an LED timeout. If LED timeout is enabled, the LEDs turn off five seconds after the last change in brightness. Note that the lowest LED and the blue power LED are always on when the power is on.
If there are LEDs defined in the template, they are turned on to indicate the current brightness. More LEDs are turned on at higher brightnesses. The LedTimeout command enables/disables an LED timeout. If LED timeout is enabled, the LEDs turn off five seconds after the last change in brightness. Note that the lowest LED and the blue power LED are always on when the power is on. The LED timeout can also be enabled/disabled by holding the power button while tapping (pressing and releasing quickly) the down button.
The LEDLink LED can be used as a nightlight/powered-off indicator. The PoweredOffLed command enables/disables turning the LEDLink LED on when the power is off.
The LEDLink LED can be used as a nightlight/powered-off indicator. The PoweredOffLed command enables/disables turning the LEDLink LED on when the power is off. The powered-off indicator can also be enabled/disabled by holding the power button and tapping the up button.
When the power is on, tapping (pressing and releasing quickly) the down or up buttons a given number of times and then holding the down or up button decreases or increases settings according to the table below. For example, tapping the down button once and then holding the up button sets all RGB lights in the device group to the next fixed color. Tapping the up button three times and then holding the down button decreases the high brightness preset.
Holding the power button, tapping the down button and then tapping or holding the down or up button sends a device group message to set RGB lights in the device group to the previous/next fixed color. The command is sent/value is adjusted once every .5 seconds for as long as the button is held. The color sequence as defined by the Light module is red, green, blue, orange, light green, light blue, amber, cyan, purple, yellow, pink, white using RGB channels, white using CT channels.
Holding the power button, tapping the up button and then tapping or holding the down or up button publishes an MQTT Event command. The command is sent/value is adjusted once every .5 seconds for as long as the button is held. The MQTT topic is as described above. The MQTT payload is Trigger#, where # is 3 if the down button is held or 4 if the up button is held.
<table>
<tr>
<td>Taps
</td>
<td>Down Button
</td>
<td>Up Button
</td>
</tr>
<tr>
<td>1
</td>
<td>Set fixed color<sup>1</sup>
</td>
<td>Publish MQTT event<sup>2</sup>
</td>
</tr>
<tr>
<td>2
</td>
<td>Adjust minimum brightness
</td>
<td>Adjust fade speed
</td>
</tr>
<tr>
<td>3
</td>
<td>Adjust low brightness preset
</td>
<td>Adjust high brightness preset
</td>
</tr>
</table>
Holding the down or up button alone for over 10 seconds executes the WiFiConfig 2 command.
Pressing and releasing any button publishes an MQTT TOGGLE command for the button. Holding a button publishes an MQTT HOLD command followed by an MQTT OFF command when the button is released.
1. Setting the previous/next color only functions when remote device mode is enabled (see below) and only when the switch is in a device group with an RGB light. The color sequence as defined by the Light module is red, green, blue, orange, light green, light blue, amber, cyan, purple, yellow, pink, white using RGB channels, white using CT channels.
2. The MQTT topic has the format %group-topic%/cmnd/Event, where %group-topic% is the group topic set by the GroupTopic command. The MQTT payload is SwitchTrigger#, where # is 1 if the down button is held or 2 if the up button is held. These triggers can be used in rules on remote devices (ON Event#SwitchTrigger1) or by automation software to trigger automations such as scene changes. For example, the Event topic SwitchTrigger1 payload could trigger the automation software to turn on the previous scene in a list and the SwitchTrigger2 payload could trigger the automation software to turn on the next scene in a list.
Holding the power button, pressing the down/up buttons a given number of times and then releasing the power button toggles options according to the table below. Note that you must press a down or up button within 0.5 seconds to prevent the power button hold action from taking place.
<table>
<tr>
<td>Presses
</td>
<td>Down Button
</td>
<td>Up Button
</td>
</tr>
<tr>
<td>1
</td>
<td>Toggle powered-off LED
</td>
<td>Toggle brightness LED timeout
</td>
</tr>
<tr>
<td>2
</td>
<td>Toggle fading
</td>
<td>
</td>
</tr>
</table>
Holding any button for over 10 seconds executes the WiFiConfig 2 command.
Pressing and releasing a button publishes an MQTT TOGGLE command. Holding a button publishes an MQTT HOLD command followed by an MQTT OFF command when the button is released.
When Device Groups are enabled, the PWM Dimmer brightness presets, dimmer minimum and maximum values, fade and speed settings are kept in sync across all switches in the group. The powered-off LED and LED timeout settings are specific to each switch. Changing them does not replicate the change to the other switches in the group.
When Device Groups are enabled, the PWM Dimmer brightness presets are kept in sync across all switches in the group. The powered-off LED and LED timeout settings are specific to each switch. Changing them does not replicate the change to the other switches in the group.
### Commands
<table>
<tr>
<td><strong>Command</strong>
@ -121,13 +49,6 @@ When Device Groups are enabled, the PWM Dimmer brightness presets, dimmer minimu
- = decrease brightness preset
</td>
</tr>
<tr>
<td>DimmerRange
</td>
<td>Change dimming range<br>
<dimmerMin>,<DimmerMax> = set minimum and maximum PWM values. Dimmer/brightness is scaled to this range.<br>
</td>
</tr>
<tr>
<td>SetOption86
</td>
@ -162,12 +83,12 @@ Remote device mode allows PWM Dimmer switches to control remote devices. With re
To include remote device mode support in the build, define USE_PWM_DIMMER_REMOTE in your user_config_override. Remote device mode support requires device group support so USE_DEVICE_GROUPS is automatically defined if USE_PWM_DIMMER_REMOTE is defined. Remote device mode support adds 0.7K to the code size in addition to the code size required for device groups support.
To enable remote device mode, set Option88 to 1. Each remote device must be running firmware with device group support and have remote device support enabled. The remote devices do not need to be built with PWM dimmer support nor do they need to be switches.
To enable remote device mode, execute the command SetOption88 1 (the device will restart). Each remote device must be running firmware with device group support and have remote device support enabled. The remote devices do not need to be built with PWM dimmer support nor do they need to be switches.
If a remote device is a PWM dimmer, the device acts like a 3-way dimmer switch would and may or may not have a load connected to it. Its also possible to use a PWM dimmer switch without a load to act as a wall switch to control the power, brightness and color of one or more smart lights with Tasmota with device group support loaded on them.
With remote device mode enabled, button 1 is the power button for the local device while buttons 2 and 3 are the power buttons for remote devices. Group names for buttons 2 and 3 are set by the GroupTopic2 and GroupTopic3 commands respectively. Note that the button numbers are defined by the module template and can be in any physical order on the switch (button 1 can be defined as the top button, the middle button or the bottom button).
With remote device mode is enabled, button 1 is the power button for the local device while buttons 2 and 3 are the power buttons for remote devices. Group names for buttons 2 and 3 are set by the GroupTopic2 and GroupTopic3 commands respectively. Note that the button numbers are defined by the module template and can be in any physical order on the switch (button 1 can be defined as the top button, the middle button or the bottom button). Button combinations that publish MQTT Event commands use a topic in the format cmnd/%group-topic%/EVENT.
Pressing and releasing a power button toggles the power on all devices in the group assigned to the button. When the power is on, holding the button alternately increases or decreases the brightness. When the power is off, holding the button turns the power on at a temporary brightness of the low level set by the BriPreset command (default =10).
Pressing and releasing a power button toggles the power on all devices in the group assigned to the button. When the power is on, holding the button alternately increases or decreases the brightness. When the power is off, holding the button turns the power on at a temporary brightness of the low level set by the BriPreset command.
While holding a power button, the other two buttons act like the down and up buttons for the remote device. All the functions performed by the down and up buttons in non-remote device mode are available in remote device mode. While holding button 1, button 2 performs the functions of the down button and button 3 performs the functions of the up button. While holding button 2, button 1 performs the functions of the down button and button 3 performs the functions of the up button. While holding button 3, button 1 performs the functions of the down button and button 2 performs the functions of the up button.

View File

@ -551,7 +551,6 @@
// Commands xdrv_34_pwm_dimmer.ino
#ifdef USE_PWM_DIMMER
#define D_CMND_BRI_MIN "BriMin"
#define D_CMND_BRI_PRESET "BriPreset"
#endif

View File

@ -417,8 +417,8 @@
// #define EXS_MCU_CMNDS // Add command to send MCU commands (+0k8 code)
//#define USE_HOTPLUG // Add support for sensor HotPlug
#define USE_DEVICE_GROUPS // Add support for device groups (+5k6 code)
#define USE_PWM_DIMMER // Add support for MJ-SD01/acenx/NTONPOWER PWM dimmers (+4k5 code)
#define USE_PWM_DIMMER_REMOTE // Add support for remote switches to PWM Dimmer, also adds device groups support (+0k7 code, also includes device groups)
#define USE_PWM_DIMMER // Add support for MJ-SD01/acenx/NTONPOWER PWM dimmers (+2k5 code)
#define USE_PWM_DIMMER_REMOTE // Add support for remote switches to PWM Dimmer, also adds device groups support (+1k1 code plus device groups size)
//#define USE_KEELOQ // Add support for Jarolift rollers by Keeloq algorithm (+4k5 code)
#define USE_SONOFF_D1 // Add support for Sonoff D1 Dimmer (+0k7 code)

View File

@ -783,6 +783,11 @@ void CmndSetoption(void)
}
else if (4 == ptype) { // SetOption82 .. 113
bitWrite(Settings.flag4.data, pindex, XdrvMailbox.payload);
switch (pindex) {
case 6: // SetOption88 - PWM Dimmer Buttons control remote devices
restart_flag = 2;
break;
}
}
} else {
ptype = 99; // Command Error

View File

@ -111,6 +111,7 @@ bool DeviceGroupItemShared(bool incoming, uint8_t item)
uint8_t mask = 0;
switch (item) {
case DGR_ITEM_LIGHT_BRI:
case DGR_ITEM_BRI_POWER_ON:
mask = DGR_SHARE_LIGHT_BRI;
break;
case DGR_ITEM_POWER:
@ -127,8 +128,9 @@ bool DeviceGroupItemShared(bool incoming, uint8_t item)
case DGR_ITEM_LIGHT_SPEED:
mask = DGR_SHARE_LIGHT_FADE;
break;
case DGR_ITEM_DIMMER_RANGE:
mask = DGR_SHARE_DIMMER_RANGE;
case DGR_ITEM_BRI_PRESET_LOW:
case DGR_ITEM_BRI_PRESET_HIGH:
mask = DGR_SHARE_DIMMER_SETTINGS;
break;
}
return (!mask || ((incoming ? Settings.device_group_share_in : Settings.device_group_share_out) & mask));
@ -544,7 +546,6 @@ void ProcessDeviceGroupMessage(char * packet, int packet_length)
case DGR_ITEM_BRI_POWER_ON:
case DGR_ITEM_POWER:
case DGR_ITEM_LIGHT_CHANNELS:
case DGR_ITEM_DIMMER_RANGE:
break;
default:
AddLog_P2(LOG_LEVEL_ERROR, PSTR("DGR: ********** invalid item=%u received from device group %s member %s"), item, device_group->group_name, IPAddressToString(remote_ip));

View File

@ -641,12 +641,6 @@ void MqttShowState(void)
break;
}
#endif // USE_SONOFF_IFAN
#ifdef USE_PWM_DIMMER
if (PWM_DIMMER == my_module_type) {
ResponseAppend_P(PSTR(",\"" D_CMND_DIMMER "\":%d,\"" D_CMND_FADE "\":\"%s\",\"" D_CMND_SPEED "\":%d"),
Settings.light_dimmer, GetStateText(Settings.light_fade), Settings.light_speed);
}
#endif // USE_PWM_DIMMER
#ifdef USE_LIGHT
}
#endif
@ -1478,6 +1472,10 @@ void GpioInit(void)
digitalWrite(pin[GPIO_LEDLNK], ledlnk_inverted);
}
#ifdef USE_PWM_DIMMER
if (PWM_DIMMER == my_module_type && pin[GPIO_REL1] < 99) devices_present--;
#endif // USE_PWM_DIMMER
ButtonInit();
SwitchInit();
#ifdef ROTARY_V1

View File

@ -323,7 +323,7 @@ enum DeviceGroupItem { DGR_ITEM_EOL, DGR_ITEM_STATUS,
DGR_ITEM_LIGHT_CHANNELS };
enum DeviceGroupShareItem { DGR_SHARE_POWER = 1, DGR_SHARE_LIGHT_BRI = 2, DGR_SHARE_LIGHT_FADE = 4, DGR_SHARE_LIGHT_SCHEME = 8,
DGR_SHARE_LIGHT_COLOR = 16, DGR_SHARE_DIMMER_RANGE = 32 };
DGR_SHARE_LIGHT_COLOR = 16, DGR_SHARE_DIMMER_SETTINGS = 32 };
enum CommandSource { SRC_IGNORE, SRC_MQTT, SRC_RESTART, SRC_BUTTON, SRC_SWITCH, SRC_BACKLOG, SRC_SERIAL, SRC_WEBGUI, SRC_WEBCOMMAND, SRC_WEBCONSOLE, SRC_PULSETIMER,
SRC_TIMER, SRC_RULE, SRC_MAXPOWER, SRC_MAXENERGY, SRC_OVERTEMP, SRC_LIGHT, SRC_KNX, SRC_DISPLAY, SRC_WEMO, SRC_HUE, SRC_RETRY, SRC_REMOTE, SRC_SHUTTER,

View File

@ -1125,17 +1125,6 @@ void HandleRoot(void)
} // Settings.flag3.pwm_multi_channels
}
#endif // USE_LIGHT
#ifdef USE_PWM_DIMMER
if (PWM_DIMMER == my_module_type) {
WSContentSend_P(HTTP_MSG_SLIDER_GRADIENT, // Brightness - Black to White
"c", // c - Unique HTML id
"#000", "#fff", // Black to White
4, // sl4 - Unique range HTML id - Used as source for Saturation begin color
Settings.flag3.slider_dimmer_stay_on, 100, // Range 0/1 to 100%
Settings.light_dimmer,
'd', 0); // d0 - Value id is related to lc("d0", value) and WebGetArg("d0", tmp, sizeof(tmp));
}
#endif // USE_PWM_DIMMER
#ifdef USE_SHUTTER
if (Settings.flag3.shutter_mode) { // SetOption80 - Enable shutter support
for (uint32_t i = 0; i < shutters_present; i++) {

View File

@ -545,6 +545,9 @@ class LightStateClass {
#ifdef DEBUG_LIGHT
AddLog_P2(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setBri RGB raw (%d %d %d) HS (%d %d) bri (%d)", _r, _g, _b, _hue, _sat, _briRGB);
#endif
#ifdef USE_PWM_DIMMER
if (PWM_DIMMER == my_module_type) PWMDimmerSetBrightnessLeds(0);
#endif // USE_PWM_DIMMER
}
// changes the RGB brightness alone
@ -1820,9 +1823,13 @@ void LightAnimate(void)
}
// final adjusments for PMW, post-gamma correction
uint16_t min = 1;
#ifdef USE_PWM_DIMMER
if (PWM_DIMMER == my_module_type) min = Settings.dimmer_hw_min;
#endif // USE_PWM_DIMMER
for (uint32_t i = 0; i < LST_MAX; i++) {
// scale from 0..1023 to 0..pwm_range, but keep any non-zero value to at least 1
cur_col_10[i] = (cur_col_10[i] > 0) ? changeUIntScale(cur_col_10[i], 1, 1023, 1, Settings.pwm_range) : 0;
cur_col_10[i] = (cur_col_10[i] > 0) ? changeUIntScale(cur_col_10[i], 1, 1023, min, Settings.pwm_range) : 0;
}
// apply port remapping on both 8 bits and 10 bits versions
@ -1858,6 +1865,10 @@ void LightAnimate(void)
LightSetOutputs(Light.fade_cur_10);
}
}
#ifdef USE_PWM_DIMMER
// If the power is off and the fade is done, turn the relay off.
if (PWM_DIMMER == my_module_type && !Light.power && !Light.fade_running) PWMDimmerSetPower();
#endif // USE_PWM_DIMMER
}
}
@ -2084,20 +2095,35 @@ void calcGammaBulbs(uint16_t cur_col_10[5]) {
#ifdef USE_DEVICE_GROUPS
void LightSendDeviceGroupStatus()
{
uint8_t channels[LST_MAX];
light_state.getChannels(channels);
SendLocalDeviceGroupMessage(DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_SCHEME, Settings.light_scheme, DGR_ITEM_LIGHT_CHANNELS, channels,
DGR_ITEM_LIGHT_BRI, (power ? light_state.getBri() : 0));
if (Light.subtype > LST_SINGLE) {
uint8_t channels[LST_MAX];
light_state.getChannels(channels);
SendLocalDeviceGroupMessage(DGR_MSGTYP_PARTIAL_UPDATE, DGR_ITEM_LIGHT_CHANNELS, channels);
}
SendLocalDeviceGroupMessage(DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_SCHEME, Settings.light_scheme,
DGR_ITEM_LIGHT_BRI, light_state.getBri());
}
void LightHandleDeviceGroupItem()
{
static bool send_state = false;
static bool restore_power = false;
bool more_to_come;
uint32_t value = XdrvMailbox.payload;
#ifdef USE_PWM_DIMMER_REMOTE
if (XdrvMailbox.index & 0xff00) return; // Ignore updates from other device groups
#endif // USE_PWM_DIMMER_REMOTE
switch (XdrvMailbox.command_code) {
case DGR_ITEM_EOL:
more_to_come = (XdrvMailbox.index & DGR_FLAG_MORE_TO_COME);
if (restore_power && !more_to_come) {
restore_power = false;
Light.power = Light.old_power;
}
LightAnimate();
if (send_state && !(XdrvMailbox.index & DGR_FLAG_MORE_TO_COME)) {
if (send_state && !more_to_come) {
light_controller.saveSettings();
if (Settings.flag3.hass_tele_on_power) { // SetOption59 - Send tele/%topic%/STATE in addition to stat/%topic%/RESULT
MqttPublishTeleState();
@ -2107,7 +2133,7 @@ void LightHandleDeviceGroupItem()
break;
case DGR_ITEM_LIGHT_BRI:
if (light_state.getBri() != value) {
light_controller.changeBri(value);
light_state.setBri(value);
send_state = true;
}
break;
@ -2122,30 +2148,25 @@ void LightHandleDeviceGroupItem()
send_state = true;
break;
case DGR_ITEM_LIGHT_FIXED_COLOR:
{
struct XDRVMAILBOX save_XdrvMailbox;
power_t save_power = Light.power;
if (Light.subtype >= LST_RGBW) {
if (value) {
bool save_decimal_text = Settings.flag.decimal_text;
char str[16];
XdrvMailbox.index = 2;
XdrvMailbox.data_len = sprintf_P(str, PSTR("%u"), value);
XdrvMailbox.data = str;
CmndSupportColor();
LightColorEntry(str, sprintf_P(str, PSTR("%u"), value));
Settings.flag.decimal_text = save_decimal_text;
uint32_t old_bri = light_state.getBri();
light_controller.changeChannels(Light.entry_color);
light_controller.changeBri(old_bri);
Settings.light_scheme = 0;
}
else {
Light.fixed_color_index = 0;
XdrvMailbox.index = 1;
XdrvMailbox.payload = light_state.BriToDimmer(light_state.getBri());
CmndWhite();
light_state.setColorMode(LCM_CT);
}
if (Light.power != save_power) {
XdrvMailbox.index = save_power;
LightSetPower();
if (!restore_power && !Light.power) {
Light.old_power = Light.power;
Light.power = 0xff;
restore_power = true;
}
XdrvMailbox = save_XdrvMailbox;
send_state = true;
}
break;
@ -2536,6 +2557,10 @@ void CmndDimmer(void)
LightPreparePower();
}
}
#if defined(USE_PWM_DIMMER) && defined(USE_DEVICE_GROUPS)
Settings.bri_power_on = light_state.getBri();;
SendLocalDeviceGroupMessage(DGR_MSGTYP_UPDATE, DGR_ITEM_BRI_POWER_ON, Settings.bri_power_on);
#endif // USE_PWM_DIMMER && USE_DEVICE_GROUPS
Light.update = true;
if (skip_light_fade) LightAnimate();
} else {
@ -2544,8 +2569,6 @@ void CmndDimmer(void)
skip_light_fade = false;
}
#endif // USE_LIGHT
#if defined(USE_LIGHT) || defined(USE_PWM_DIMMER)
void CmndDimmerRange(void)
{
// DimmerRange - Show current dimmer range as used by Tuya and PS16DZ Dimmers
@ -2562,15 +2585,10 @@ void CmndDimmerRange(void)
Settings.dimmer_hw_min = parm[1];
Settings.dimmer_hw_max = parm[0];
}
#ifdef USE_DEVICE_GROUPS
SendLocalDeviceGroupMessage(DGR_MSGTYP_UPDATE, DGR_ITEM_DIMMER_RANGE, Settings.dimmer_hw_min | Settings.dimmer_hw_max << 16);
#endif // USE_DEVICE_GROUPS
if (PWM_DIMMER != my_module_type) restart_flag = 2;
}
Response_P(PSTR("{\"" D_CMND_DIMMER_RANGE "\":{\"Min\":%d,\"Max\":%d}}"), Settings.dimmer_hw_min, Settings.dimmer_hw_max);
}
#endif // #if defined(USE_LIGHT) || defined(USE_PWM_DIMMER)
#ifdef USE_LIGHT
void CmndLedTable(void)
{
@ -2613,8 +2631,6 @@ void CmndRgbwwTable(void)
ResponseCmndChar(scolor);
}
#endif // USE_LIGHT
#if defined(USE_LIGHT) || defined(USE_PWM_DIMMER)
void CmndFade(void)
{
// Fade - Show current Fade state
@ -2661,8 +2677,6 @@ void CmndSpeed(void)
}
ResponseCmndNumber(Settings.light_speed);
}
#endif // #if defined(USE_LIGHT) || defined(USE_PWM_DIMMER)
#ifdef USE_LIGHT
void CmndWakeupDuration(void)
{
@ -2695,9 +2709,6 @@ bool Xdrv04(uint8_t function)
bool result = false;
if (FUNC_MODULE_INIT == function) {
#ifdef USE_PWM_DIMMER
if (PWM_DIMMER != my_module_type)
#endif // USE_PWM_DIMMER
return LightModuleInit();
}
else if (light_type) {

View File

@ -211,7 +211,7 @@ void HAssAnnounceRelayLight(void)
TryResponseAppend_P(HASS_DISCOVER_RELAY, command_topic, value_template, SettingsText(SET_STATE_TXT1), SettingsText(SET_STATE_TXT2));
TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO_SHORT, unique_id, ESP.getChipId());
#if defined(USE_LIGHT) || defined(USE_PWM_DIMMER)
#ifdef USE_LIGHT
if (is_light || PWM_DIMMER == my_module_type)
{
char *brightness_command_topic = stemp1;
@ -220,7 +220,6 @@ void HAssAnnounceRelayLight(void)
strncpy_P(stemp3, Settings.flag.not_power_linked ? PSTR("last") : PSTR("brightness"), sizeof(stemp3)); // SetOption20 - Control power in relation to Dimmer/Color/Ct changes
TryResponseAppend_P(HASS_DISCOVER_LIGHT_DIMMER, brightness_command_topic, state_topic, stemp3);
#ifdef USE_LIGHT
if (Light.subtype >= LST_RGB)
{
char *rgb_command_topic = stemp1;
@ -246,9 +245,8 @@ void HAssAnnounceRelayLight(void)
GetTopic_P(color_temp_command_topic, CMND, mqtt_topic, D_CMND_COLORTEMPERATURE);
TryResponseAppend_P(HASS_DISCOVER_LIGHT_CT, color_temp_command_topic, state_topic);
}
#endif // USE_LIGHT
}
#endif // defined(USE_LIGHT) || defined(USE_PWM_DIMMER)
#endif // USE_LIGHT
TryResponseAppend_P(PSTR("}"));
}
MqttPublish(stopic, true);

File diff suppressed because it is too large Load Diff