mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 20:56:35 +00:00
Add DGR device map support
This commit is contained in:
parent
d4de1cd69b
commit
60252a9043
@ -324,6 +324,7 @@
|
|||||||
#define D_CMND_SPEEDUNIT "SpeedUnit"
|
#define D_CMND_SPEEDUNIT "SpeedUnit"
|
||||||
#define D_CMND_I2CSCAN "I2CScan"
|
#define D_CMND_I2CSCAN "I2CScan"
|
||||||
#define D_CMND_I2CDRIVER "I2CDriver"
|
#define D_CMND_I2CDRIVER "I2CDriver"
|
||||||
|
#define D_CMND_DEVGROUP_DEVICE "DevGroupDevice"
|
||||||
#define D_CMND_DEVGROUP_NAME "DevGroupName"
|
#define D_CMND_DEVGROUP_NAME "DevGroupName"
|
||||||
#define D_CMND_DEVGROUP_SEND "DevGroupSend"
|
#define D_CMND_DEVGROUP_SEND "DevGroupSend"
|
||||||
#define D_CMND_DEVGROUP_SHARE "DevGroupShare"
|
#define D_CMND_DEVGROUP_SHARE "DevGroupShare"
|
||||||
|
@ -631,7 +631,7 @@ struct {
|
|||||||
// Only 32 bit boundary variables below
|
// Only 32 bit boundary variables below
|
||||||
|
|
||||||
uint64_t rf_protocol_mask; // FA8
|
uint64_t rf_protocol_mask; // FA8
|
||||||
uint32_t device_group_maps; // FB0
|
uint8_t device_group_device[4]; // FB0
|
||||||
SysBitfield5 flag5; // FB4
|
SysBitfield5 flag5; // FB4
|
||||||
uint16_t pulse_counter_debounce_low; // FB8
|
uint16_t pulse_counter_debounce_low; // FB8
|
||||||
uint16_t pulse_counter_debounce_high; // FBA
|
uint16_t pulse_counter_debounce_high; // FBA
|
||||||
|
@ -1232,6 +1232,9 @@ void SettingsDelta(void) {
|
|||||||
Settings.interlock[i] = (i < 4) ? Settings.ex_interlock[i] : 0;
|
Settings.interlock[i] = (i < 4) ? Settings.ex_interlock[i] : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (Settings.version < 0x09020007) {
|
||||||
|
*(uint32_t *)&Settings.device_group_device = 0x04030201;
|
||||||
|
}
|
||||||
|
|
||||||
Settings.version = VERSION;
|
Settings.version = VERSION;
|
||||||
SettingsSave(1);
|
SettingsSave(1);
|
||||||
|
@ -32,7 +32,7 @@ const char kTasmotaCommands[] PROGMEM = "|" // No prefix
|
|||||||
D_CMND_I2CSCAN "|" D_CMND_I2CDRIVER "|"
|
D_CMND_I2CSCAN "|" D_CMND_I2CDRIVER "|"
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_DEVICE_GROUPS
|
#ifdef USE_DEVICE_GROUPS
|
||||||
D_CMND_DEVGROUP_NAME "|"
|
D_CMND_DEVGROUP_DEVICE "|" D_CMND_DEVGROUP_NAME "|"
|
||||||
#ifdef USE_DEVICE_GROUPS_SEND
|
#ifdef USE_DEVICE_GROUPS_SEND
|
||||||
D_CMND_DEVGROUP_SEND "|"
|
D_CMND_DEVGROUP_SEND "|"
|
||||||
#endif // USE_DEVICE_GROUPS_SEND
|
#endif // USE_DEVICE_GROUPS_SEND
|
||||||
@ -59,7 +59,7 @@ void (* const TasmotaCommand[])(void) PROGMEM = {
|
|||||||
&CmndI2cScan, CmndI2cDriver,
|
&CmndI2cScan, CmndI2cDriver,
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_DEVICE_GROUPS
|
#ifdef USE_DEVICE_GROUPS
|
||||||
&CmndDevGroupName,
|
&CmndDevGroupDevice, &CmndDevGroupName,
|
||||||
#ifdef USE_DEVICE_GROUPS_SEND
|
#ifdef USE_DEVICE_GROUPS_SEND
|
||||||
&CmndDevGroupSend,
|
&CmndDevGroupSend,
|
||||||
#endif // USE_DEVICE_GROUPS_SEND
|
#endif // USE_DEVICE_GROUPS_SEND
|
||||||
@ -2052,6 +2052,16 @@ void CmndI2cDriver(void)
|
|||||||
#endif // USE_I2C
|
#endif // USE_I2C
|
||||||
|
|
||||||
#ifdef USE_DEVICE_GROUPS
|
#ifdef USE_DEVICE_GROUPS
|
||||||
|
void CmndDevGroupDevice(void)
|
||||||
|
{
|
||||||
|
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_DEV_GROUP_NAMES)) {
|
||||||
|
if (XdrvMailbox.data_len > 0) {
|
||||||
|
Settings.device_group_device[XdrvMailbox.index - 1] = XdrvMailbox.payload;
|
||||||
|
}
|
||||||
|
ResponseCmndIdxNumber(Settings.device_group_device[XdrvMailbox.index - 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CmndDevGroupName(void)
|
void CmndDevGroupName(void)
|
||||||
{
|
{
|
||||||
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_DEV_GROUP_NAMES)) {
|
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_DEV_GROUP_NAMES)) {
|
||||||
@ -2072,7 +2082,7 @@ void CmndDevGroupSend(void)
|
|||||||
{
|
{
|
||||||
uint8_t device_group_index = (XdrvMailbox.usridx ? XdrvMailbox.index - 1 : 0);
|
uint8_t device_group_index = (XdrvMailbox.usridx ? XdrvMailbox.index - 1 : 0);
|
||||||
if (device_group_index < device_group_count) {
|
if (device_group_index < device_group_count) {
|
||||||
if (!_SendDeviceGroupMessage(device_group_index, (DevGroupMessageType)(DGR_MSGTYPE_UPDATE_COMMAND + DGR_MSGTYPFLAG_WITH_LOCAL))) {
|
if (!_SendDeviceGroupMessage(-device_group_index, (DevGroupMessageType)(DGR_MSGTYPE_UPDATE_COMMAND + DGR_MSGTYPFLAG_WITH_LOCAL))) {
|
||||||
ResponseCmndChar(XdrvMailbox.data);
|
ResponseCmndChar(XdrvMailbox.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -448,7 +448,7 @@ write_log:
|
|||||||
if (received) {
|
if (received) {
|
||||||
if ((flags & DGR_FLAG_STATUS_REQUEST)) {
|
if ((flags & DGR_FLAG_STATUS_REQUEST)) {
|
||||||
if ((flags & DGR_FLAG_RESET) || device_group_member->acked_sequence != device_group->last_full_status_sequence) {
|
if ((flags & DGR_FLAG_RESET) || device_group_member->acked_sequence != device_group->last_full_status_sequence) {
|
||||||
_SendDeviceGroupMessage(device_group_index, DGR_MSGTYP_FULL_STATUS);
|
_SendDeviceGroupMessage(-device_group_index, DGR_MSGTYP_FULL_STATUS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -479,7 +479,7 @@ cleanup:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _SendDeviceGroupMessage(uint8_t device_group_index, DevGroupMessageType message_type, ...)
|
bool _SendDeviceGroupMessage(uint32_t device, DevGroupMessageType message_type, ...)
|
||||||
{
|
{
|
||||||
// If device groups is not up, ignore this request.
|
// If device groups is not up, ignore this request.
|
||||||
if (!device_groups_up) return 1;
|
if (!device_groups_up) return 1;
|
||||||
@ -492,11 +492,16 @@ bool _SendDeviceGroupMessage(uint8_t device_group_index, DevGroupMessageType mes
|
|||||||
if (ignore_dgr_sends && message_type != DGR_MSGTYPE_UPDATE_COMMAND) return 0;
|
if (ignore_dgr_sends && message_type != DGR_MSGTYPE_UPDATE_COMMAND) return 0;
|
||||||
|
|
||||||
// If device is < 0, the device group index is the device negated. If not, get the device group
|
// If device is < 0, the device group index is the device negated. If not, get the device group
|
||||||
// index from the device group maps.
|
// index for this device.
|
||||||
// uint8_t device_group_index = -device;
|
uint8_t device_group_index = -device;
|
||||||
// if (device > 0) device_group_index = (Settings.device_group_maps >> (device - 1) * 3 & 0x7 - 1;
|
if (device > 0) {
|
||||||
|
device_group_index = 0;
|
||||||
// If the device group index is higher then the number of device groups, ignore this request.
|
if (Settings.flag4.multiple_device_groups) { // SetOption88 - Enable relays in separate device groups
|
||||||
|
for (; device_group_index < device_group_count; device_group_index++) {
|
||||||
|
if (Settings.device_group_device[device_group_index] == device) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (device_group_index >= device_group_count) return 0;
|
if (device_group_index >= device_group_count) return 0;
|
||||||
|
|
||||||
// Get a pointer to the device information for this device.
|
// Get a pointer to the device information for this device.
|
||||||
@ -507,7 +512,7 @@ bool _SendDeviceGroupMessage(uint8_t device_group_index, DevGroupMessageType mes
|
|||||||
|
|
||||||
// Load the message header, sequence and flags.
|
// Load the message header, sequence and flags.
|
||||||
#ifdef DEVICE_GROUPS_DEBUG
|
#ifdef DEVICE_GROUPS_DEBUG
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("DGR: Building %s %spacket"), device_group->group_name, (message_type == DGR_MSGTYP_FULL_STATUS ? PSTR("full status ") : PSTR("")));
|
AddLog(LOG_LEVEL_DEBUG, PSTR("DGR: Building %s %spacket"), device_group->group_name, (message_type == DGR_MSGTYP_FULL_STATUS ? PSTR("full status ") : PSTR("")));
|
||||||
#endif // DEVICE_GROUPS_DEBUG
|
#endif // DEVICE_GROUPS_DEBUG
|
||||||
uint16_t original_sequence = device_group->outgoing_sequence;
|
uint16_t original_sequence = device_group->outgoing_sequence;
|
||||||
uint16_t flags = 0;
|
uint16_t flags = 0;
|
||||||
@ -531,10 +536,9 @@ bool _SendDeviceGroupMessage(uint8_t device_group_index, DevGroupMessageType mes
|
|||||||
// Call the drivers to build the status update.
|
// Call the drivers to build the status update.
|
||||||
power_t power = TasmotaGlobal.power;
|
power_t power = TasmotaGlobal.power;
|
||||||
if (Settings.flag4.multiple_device_groups) { // SetOption88 - Enable relays in separate device groups
|
if (Settings.flag4.multiple_device_groups) { // SetOption88 - Enable relays in separate device groups
|
||||||
power >>= device_group_index;
|
power = (power >> (Settings.device_group_device[device_group_index] - 1)) & 1;
|
||||||
power &= 1;
|
|
||||||
}
|
}
|
||||||
SendDeviceGroupMessage(device_group_index, DGR_MSGTYP_PARTIAL_UPDATE, DGR_ITEM_NO_STATUS_SHARE, device_group->no_status_share, DGR_ITEM_POWER, power);
|
SendDeviceGroupMessage(-device_group_index, DGR_MSGTYP_PARTIAL_UPDATE, DGR_ITEM_NO_STATUS_SHARE, device_group->no_status_share, DGR_ITEM_POWER, power);
|
||||||
XdrvMailbox.index = 0;
|
XdrvMailbox.index = 0;
|
||||||
if (device_group_index == 0 && first_device_group_is_local) XdrvMailbox.index = DGR_FLAG_LOCAL;
|
if (device_group_index == 0 && first_device_group_is_local) XdrvMailbox.index = DGR_FLAG_LOCAL;
|
||||||
XdrvMailbox.command_code = DGR_ITEM_STATUS;
|
XdrvMailbox.command_code = DGR_ITEM_STATUS;
|
||||||
@ -620,22 +624,25 @@ bool _SendDeviceGroupMessage(uint8_t device_group_index, DevGroupMessageType mes
|
|||||||
switch (item) {
|
switch (item) {
|
||||||
case DGR_ITEM_LIGHT_CHANNELS:
|
case DGR_ITEM_LIGHT_CHANNELS:
|
||||||
{
|
{
|
||||||
int i = 0;
|
|
||||||
char * endptr;
|
char * endptr;
|
||||||
value = strtoul((char *)value_ptr, &endptr, 10);
|
value = strtoul((char *)value_ptr, &endptr, 10);
|
||||||
if ((*endptr && *endptr != ',' && *endptr != ' ') || value > 255) {
|
bool hex = (*endptr != ',');
|
||||||
for (; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
if (!*value_ptr || *value_ptr == ' ') break;
|
*out_ptr = 0;
|
||||||
uint8_t * next_value_ptr = value_ptr + 2;
|
if (*value_ptr != ' ') {
|
||||||
uint8_t save_char = *next_value_ptr;
|
if (hex) {
|
||||||
*next_value_ptr = 'X';
|
endptr = (char *)value_ptr + 2;
|
||||||
*out_ptr++ = strtoul((char *)value_ptr, (char **)&value_ptr, 16);
|
chr = *endptr;
|
||||||
*next_value_ptr = save_char;
|
*endptr = 0;
|
||||||
|
*out_ptr = strtoul((char *)value_ptr, (char **)&value_ptr, 16);
|
||||||
|
*endptr = chr;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*out_ptr = strtoul((char *)value_ptr, (char **)&value_ptr, 10);
|
||||||
|
if (*value_ptr == ',') value_ptr++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
out_ptr++;
|
||||||
for (; i < 6; i++) {
|
|
||||||
*out_ptr++ = (*value_ptr == ' ' ? 0 : strtoul((char *)value_ptr, (char **)&value_ptr, 10));
|
|
||||||
if (*value_ptr == ',') value_ptr++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -933,7 +940,7 @@ AddLog(LOG_LEVEL_DEBUG, PSTR("DGR: Checking next_check_time=%u, now=%u"), next_c
|
|||||||
// If we've sent the initial status request message the set number of times, send our
|
// If we've sent the initial status request message the set number of times, send our
|
||||||
// status to all the members.
|
// status to all the members.
|
||||||
else {
|
else {
|
||||||
_SendDeviceGroupMessage(device_group_index, DGR_MSGTYP_FULL_STATUS);
|
_SendDeviceGroupMessage(-device_group_index, DGR_MSGTYP_FULL_STATUS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,10 +586,11 @@ void ExecuteCommandPower(uint32_t device, uint32_t state, uint32_t source)
|
|||||||
}
|
}
|
||||||
#ifdef USE_DEVICE_GROUPS
|
#ifdef USE_DEVICE_GROUPS
|
||||||
if (TasmotaGlobal.power != old_power && SRC_REMOTE != source && SRC_RETRY != source) {
|
if (TasmotaGlobal.power != old_power && SRC_REMOTE != source && SRC_RETRY != source) {
|
||||||
if (Settings.flag4.multiple_device_groups) // SetOption88 - Enable relays in separate device groups
|
power_t dgr_power = TasmotaGlobal.power;
|
||||||
SendDeviceGroupMessage(device - 1, DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, (TasmotaGlobal.power >> (device - 1)) & 1 | 0x01000000); // Explicitly set number of relays to one
|
if (Settings.flag4.multiple_device_groups) { // SetOption88 - Enable relays in separate device groups
|
||||||
else
|
dgr_power = (dgr_power >> (device - 1)) & 1;
|
||||||
SendLocalDeviceGroupMessage(DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, TasmotaGlobal.power);
|
}
|
||||||
|
SendDeviceGroupMessage(device, DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, TasmotaGlobal.power);
|
||||||
}
|
}
|
||||||
#endif // USE_DEVICE_GROUPS
|
#endif // USE_DEVICE_GROUPS
|
||||||
SetDevicePower(TasmotaGlobal.power, source);
|
SetDevicePower(TasmotaGlobal.power, source);
|
||||||
|
@ -471,7 +471,6 @@ const char kWebColors[] PROGMEM =
|
|||||||
|
|
||||||
#ifdef USE_DEVICE_GROUPS
|
#ifdef USE_DEVICE_GROUPS
|
||||||
#define SendDeviceGroupMessage(DEVICE_INDEX, REQUEST_TYPE, ...) _SendDeviceGroupMessage(DEVICE_INDEX, REQUEST_TYPE, __VA_ARGS__, 0)
|
#define SendDeviceGroupMessage(DEVICE_INDEX, REQUEST_TYPE, ...) _SendDeviceGroupMessage(DEVICE_INDEX, REQUEST_TYPE, __VA_ARGS__, 0)
|
||||||
#define SendLocalDeviceGroupMessage(REQUEST_TYPE, ...) _SendDeviceGroupMessage(0, REQUEST_TYPE, __VA_ARGS__, 0)
|
|
||||||
uint8_t device_group_count = 0;
|
uint8_t device_group_count = 0;
|
||||||
bool first_device_group_is_local = true;
|
bool first_device_group_is_local = true;
|
||||||
#endif // USE_DEVICE_GROUPS
|
#endif // USE_DEVICE_GROUPS
|
||||||
|
@ -20,6 +20,6 @@
|
|||||||
#ifndef _TASMOTA_VERSION_H_
|
#ifndef _TASMOTA_VERSION_H_
|
||||||
#define _TASMOTA_VERSION_H_
|
#define _TASMOTA_VERSION_H_
|
||||||
|
|
||||||
const uint32_t VERSION = 0x09020006;
|
const uint32_t VERSION = 0x09020007;
|
||||||
|
|
||||||
#endif // _TASMOTA_VERSION_H_
|
#endif // _TASMOTA_VERSION_H_
|
||||||
|
@ -234,7 +234,6 @@ struct LIGHT {
|
|||||||
bool fade_initialized = false; // dont't fade at startup
|
bool fade_initialized = false; // dont't fade at startup
|
||||||
bool fade_running = false;
|
bool fade_running = false;
|
||||||
#ifdef USE_DEVICE_GROUPS
|
#ifdef USE_DEVICE_GROUPS
|
||||||
uint8_t device_group_index;
|
|
||||||
uint8_t last_scheme = 0;
|
uint8_t last_scheme = 0;
|
||||||
bool devgrp_no_channels_out = false; // don't share channels with device group (e.g. if scheme set by other device)
|
bool devgrp_no_channels_out = false; // don't share channels with device group (e.g. if scheme set by other device)
|
||||||
#ifdef USE_DGR_LIGHT_SEQUENCE
|
#ifdef USE_DGR_LIGHT_SEQUENCE
|
||||||
@ -1118,12 +1117,6 @@ void LightInit(void)
|
|||||||
Light.device--; // we take the last two devices as lights
|
Light.device--; // we take the last two devices as lights
|
||||||
}
|
}
|
||||||
LightCalcPWMRange();
|
LightCalcPWMRange();
|
||||||
#ifdef USE_DEVICE_GROUPS
|
|
||||||
Light.device_group_index = 0;
|
|
||||||
if (Settings.flag4.multiple_device_groups) { // SetOption88 - Enable relays in separate device groups
|
|
||||||
Light.device_group_index = Light.device - 1;
|
|
||||||
}
|
|
||||||
#endif // USE_DEVICE_GROUPS
|
|
||||||
#ifdef DEBUG_LIGHT
|
#ifdef DEBUG_LIGHT
|
||||||
AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightInit Light.pwm_multi_channels=%d Light.subtype=%d Light.device=%d TasmotaGlobal.devices_present=%d",
|
AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightInit Light.pwm_multi_channels=%d Light.subtype=%d Light.device=%d TasmotaGlobal.devices_present=%d",
|
||||||
Light.pwm_multi_channels, Light.subtype, Light.device, TasmotaGlobal.devices_present);
|
Light.pwm_multi_channels, Light.subtype, Light.device, TasmotaGlobal.devices_present);
|
||||||
@ -1708,7 +1701,7 @@ void LightAnimate(void)
|
|||||||
#ifdef USE_DEVICE_GROUPS
|
#ifdef USE_DEVICE_GROUPS
|
||||||
if (Settings.light_scheme != Light.last_scheme) {
|
if (Settings.light_scheme != Light.last_scheme) {
|
||||||
Light.last_scheme = Settings.light_scheme;
|
Light.last_scheme = Settings.light_scheme;
|
||||||
SendDeviceGroupMessage(Light.device_group_index, DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_SCHEME, Settings.light_scheme);
|
SendDeviceGroupMessage(Light.device, DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_SCHEME, Settings.light_scheme);
|
||||||
Light.devgrp_no_channels_out = false;
|
Light.devgrp_no_channels_out = false;
|
||||||
}
|
}
|
||||||
#endif // USE_DEVICE_GROUPS
|
#endif // USE_DEVICE_GROUPS
|
||||||
@ -2188,12 +2181,12 @@ void LightSendDeviceGroupStatus()
|
|||||||
if (building_status_message || memcmp(channels, last_channels, LST_MAX)) {
|
if (building_status_message || memcmp(channels, last_channels, LST_MAX)) {
|
||||||
memcpy(last_channels, channels, LST_MAX);
|
memcpy(last_channels, channels, LST_MAX);
|
||||||
last_channels[LST_MAX]++;
|
last_channels[LST_MAX]++;
|
||||||
SendDeviceGroupMessage(Light.device_group_index, (send_bri_update ? DGR_MSGTYP_PARTIAL_UPDATE : DGR_MSGTYP_UPDATE), DGR_ITEM_LIGHT_CHANNELS, last_channels);
|
SendDeviceGroupMessage(Light.device, (send_bri_update ? DGR_MSGTYP_PARTIAL_UPDATE : DGR_MSGTYP_UPDATE), DGR_ITEM_LIGHT_CHANNELS, last_channels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (send_bri_update) {
|
if (send_bri_update) {
|
||||||
last_bri = bri;
|
last_bri = bri;
|
||||||
SendDeviceGroupMessage(Light.device_group_index, DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_BRI, light_state.getBri());
|
SendDeviceGroupMessage(Light.device, DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_BRI, light_state.getBri());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2202,7 +2195,7 @@ void LightHandleDevGroupItem(void)
|
|||||||
static bool send_state = false;
|
static bool send_state = false;
|
||||||
static bool restore_power = false;
|
static bool restore_power = false;
|
||||||
|
|
||||||
if (*XdrvMailbox.topic != Light.device_group_index) return;
|
if (Settings.device_group_device[*XdrvMailbox.topic] != Light.device) return;
|
||||||
bool more_to_come;
|
bool more_to_come;
|
||||||
uint32_t value = XdrvMailbox.payload;
|
uint32_t value = XdrvMailbox.payload;
|
||||||
switch (XdrvMailbox.command_code) {
|
switch (XdrvMailbox.command_code) {
|
||||||
@ -2318,7 +2311,7 @@ void LightHandleDevGroupItem(void)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DGR_ITEM_STATUS:
|
case DGR_ITEM_STATUS:
|
||||||
SendLocalDeviceGroupMessage(DGR_MSGTYP_PARTIAL_UPDATE, DGR_ITEM_LIGHT_FADE, Settings.light_fade,
|
SendDeviceGroupMessage(Light.device, DGR_MSGTYP_PARTIAL_UPDATE, DGR_ITEM_LIGHT_FADE, Settings.light_fade,
|
||||||
DGR_ITEM_LIGHT_SPEED, Settings.light_speed, DGR_ITEM_LIGHT_SCHEME, Settings.light_scheme);
|
DGR_ITEM_LIGHT_SPEED, Settings.light_speed, DGR_ITEM_LIGHT_SCHEME, Settings.light_scheme);
|
||||||
LightSendDeviceGroupStatus();
|
LightSendDeviceGroupStatus();
|
||||||
break;
|
break;
|
||||||
@ -2742,7 +2735,7 @@ void CmndDimmer(void)
|
|||||||
uint8_t bri = light_state.getBri();
|
uint8_t bri = light_state.getBri();
|
||||||
if (bri != Settings.bri_power_on) {
|
if (bri != Settings.bri_power_on) {
|
||||||
Settings.bri_power_on = bri;
|
Settings.bri_power_on = bri;
|
||||||
SendDeviceGroupMessage(Light.device_group_index, DGR_MSGTYP_PARTIAL_UPDATE, DGR_ITEM_BRI_POWER_ON, Settings.bri_power_on);
|
SendDeviceGroupMessage(Light.device, DGR_MSGTYP_PARTIAL_UPDATE, DGR_ITEM_BRI_POWER_ON, Settings.bri_power_on);
|
||||||
}
|
}
|
||||||
#endif // USE_PWM_DIMMER && USE_DEVICE_GROUPS
|
#endif // USE_PWM_DIMMER && USE_DEVICE_GROUPS
|
||||||
Light.update = true;
|
Light.update = true;
|
||||||
@ -2849,7 +2842,7 @@ void CmndFade(void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef USE_DEVICE_GROUPS
|
#ifdef USE_DEVICE_GROUPS
|
||||||
if (XdrvMailbox.payload >= 0 && XdrvMailbox.payload <= 2) SendDeviceGroupMessage(Light.device_group_index, DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_FADE, Settings.light_fade);
|
if (XdrvMailbox.payload >= 0 && XdrvMailbox.payload <= 2) SendDeviceGroupMessage(Light.device, DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_FADE, Settings.light_fade);
|
||||||
#endif // USE_DEVICE_GROUPS
|
#endif // USE_DEVICE_GROUPS
|
||||||
if (!Settings.light_fade) { Light.fade_running = false; }
|
if (!Settings.light_fade) { Light.fade_running = false; }
|
||||||
ResponseCmndStateText(Settings.light_fade);
|
ResponseCmndStateText(Settings.light_fade);
|
||||||
@ -2883,7 +2876,7 @@ void CmndSpeed(void)
|
|||||||
if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload <= 40)) {
|
if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload <= 40)) {
|
||||||
Settings.light_speed = XdrvMailbox.payload;
|
Settings.light_speed = XdrvMailbox.payload;
|
||||||
#ifdef USE_DEVICE_GROUPS
|
#ifdef USE_DEVICE_GROUPS
|
||||||
SendDeviceGroupMessage(Light.device_group_index, DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_SPEED, Settings.light_speed);
|
SendDeviceGroupMessage(Light.device, DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_SPEED, Settings.light_speed);
|
||||||
#endif // USE_DEVICE_GROUPS
|
#endif // USE_DEVICE_GROUPS
|
||||||
}
|
}
|
||||||
ResponseCmndNumber(Settings.light_speed);
|
ResponseCmndNumber(Settings.light_speed);
|
||||||
|
@ -2191,7 +2191,7 @@ void CmndEvent(void)
|
|||||||
if (XdrvMailbox.data_len > 0) {
|
if (XdrvMailbox.data_len > 0) {
|
||||||
strlcpy(Rules.event_data, XdrvMailbox.data, sizeof(Rules.event_data));
|
strlcpy(Rules.event_data, XdrvMailbox.data, sizeof(Rules.event_data));
|
||||||
#ifdef USE_DEVICE_GROUPS
|
#ifdef USE_DEVICE_GROUPS
|
||||||
SendLocalDeviceGroupMessage(DGR_MSGTYP_UPDATE, DGR_ITEM_EVENT, XdrvMailbox.data);
|
SendDeviceGroupMessage(1, DGR_MSGTYP_UPDATE, DGR_ITEM_EVENT, XdrvMailbox.data);
|
||||||
#endif // USE_DEVICE_GROUPS
|
#endif // USE_DEVICE_GROUPS
|
||||||
}
|
}
|
||||||
if (XdrvMailbox.command) ResponseCmndDone();
|
if (XdrvMailbox.command) ResponseCmndDone();
|
||||||
|
@ -252,11 +252,11 @@ void PWMDimmerHandleDevGroupItem(void)
|
|||||||
#ifdef USE_PWM_DIMMER_REMOTE
|
#ifdef USE_PWM_DIMMER_REMOTE
|
||||||
if (is_local)
|
if (is_local)
|
||||||
#endif // USE_PWM_DIMMER_REMOTE
|
#endif // USE_PWM_DIMMER_REMOTE
|
||||||
SendLocalDeviceGroupMessage(DGR_MSGTYP_UPDATE, DGR_ITEM_BRI_POWER_ON, Settings.bri_power_on,
|
SendDeviceGroupMessage(0, DGR_MSGTYP_UPDATE, DGR_ITEM_BRI_POWER_ON, Settings.bri_power_on,
|
||||||
DGR_ITEM_BRI_PRESET_LOW, Settings.bri_preset_low, DGR_ITEM_BRI_PRESET_HIGH, Settings.bri_preset_high);
|
DGR_ITEM_BRI_PRESET_LOW, Settings.bri_preset_low, DGR_ITEM_BRI_PRESET_HIGH, Settings.bri_preset_high);
|
||||||
#ifdef USE_PWM_DIMMER_REMOTE
|
#ifdef USE_PWM_DIMMER_REMOTE
|
||||||
else
|
else
|
||||||
SendDeviceGroupMessage(device_group_index, DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, remote_pwm_dimmer->power_on,
|
SendDeviceGroupMessage(-device_group_index, DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, remote_pwm_dimmer->power_on,
|
||||||
DGR_ITEM_BRI_POWER_ON, remote_pwm_dimmer->bri_power_on, DGR_ITEM_BRI_PRESET_LOW, remote_pwm_dimmer->bri_preset_low,
|
DGR_ITEM_BRI_POWER_ON, remote_pwm_dimmer->bri_power_on, DGR_ITEM_BRI_PRESET_LOW, remote_pwm_dimmer->bri_preset_low,
|
||||||
DGR_ITEM_BRI_PRESET_HIGH, remote_pwm_dimmer->bri_preset_high);
|
DGR_ITEM_BRI_PRESET_HIGH, remote_pwm_dimmer->bri_preset_high);
|
||||||
#endif // USE_PWM_DIMMER_REMOTE
|
#endif // USE_PWM_DIMMER_REMOTE
|
||||||
@ -491,6 +491,7 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If we need to adjust the brightness, do it.
|
// If we need to adjust the brightness, do it.
|
||||||
|
uint32_t negated_device_group_index = -power_button_index;
|
||||||
if (bri_offset) {
|
if (bri_offset) {
|
||||||
int32_t bri;
|
int32_t bri;
|
||||||
#ifdef USE_PWM_DIMMER_REMOTE
|
#ifdef USE_PWM_DIMMER_REMOTE
|
||||||
@ -509,7 +510,7 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
|
|||||||
}
|
}
|
||||||
if (new_bri != bri) {
|
if (new_bri != bri) {
|
||||||
#ifdef USE_DEVICE_GROUPS
|
#ifdef USE_DEVICE_GROUPS
|
||||||
SendDeviceGroupMessage(power_button_index, (dgr_more_to_come ? DGR_MSGTYP_UPDATE_MORE_TO_COME : DGR_MSGTYP_UPDATE_DIRECT), DGR_ITEM_LIGHT_BRI, new_bri);
|
SendDeviceGroupMessage(negated_device_group_index, (dgr_more_to_come ? DGR_MSGTYP_UPDATE_MORE_TO_COME : DGR_MSGTYP_UPDATE_DIRECT), DGR_ITEM_LIGHT_BRI, new_bri);
|
||||||
#endif // USE_DEVICE_GROUPS
|
#endif // USE_DEVICE_GROUPS
|
||||||
#ifdef USE_PWM_DIMMER_REMOTE
|
#ifdef USE_PWM_DIMMER_REMOTE
|
||||||
if (active_remote_pwm_dimmer) {
|
if (active_remote_pwm_dimmer) {
|
||||||
@ -559,9 +560,9 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
|
|||||||
}
|
}
|
||||||
#endif // USE_PWM_DIMMER_REMOTE
|
#endif // USE_PWM_DIMMER_REMOTE
|
||||||
if (new_power)
|
if (new_power)
|
||||||
SendDeviceGroupMessage(power_button_index, DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_BRI, power_on_bri, DGR_ITEM_POWER, new_power);
|
SendDeviceGroupMessage(negated_device_group_index, DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_BRI, power_on_bri, DGR_ITEM_POWER, new_power);
|
||||||
else
|
else
|
||||||
SendDeviceGroupMessage(power_button_index, DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, new_power);
|
SendDeviceGroupMessage(negated_device_group_index, DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, new_power);
|
||||||
#endif // USE_DEVICE_GROUPS
|
#endif // USE_DEVICE_GROUPS
|
||||||
#ifdef USE_PWM_DIMMER_REMOTE
|
#ifdef USE_PWM_DIMMER_REMOTE
|
||||||
if (active_remote_pwm_dimmer)
|
if (active_remote_pwm_dimmer)
|
||||||
@ -639,7 +640,7 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
|
|||||||
if (handle_tap)
|
if (handle_tap)
|
||||||
#endif // USE_PWM_DIMMER_REMOTE
|
#endif // USE_PWM_DIMMER_REMOTE
|
||||||
message_type = (DevGroupMessageType)(message_type + DGR_MSGTYPFLAG_WITH_LOCAL);
|
message_type = (DevGroupMessageType)(message_type + DGR_MSGTYPFLAG_WITH_LOCAL);
|
||||||
SendDeviceGroupMessage(power_button_index, message_type, dgr_item, dgr_value);
|
SendDeviceGroupMessage(negated_device_group_index, message_type, dgr_item, dgr_value);
|
||||||
#endif // USE_DEVICE_GROUPS
|
#endif // USE_DEVICE_GROUPS
|
||||||
#ifdef USE_PWM_DIMMER_REMOTE
|
#ifdef USE_PWM_DIMMER_REMOTE
|
||||||
if (!active_remote_pwm_dimmer)
|
if (!active_remote_pwm_dimmer)
|
||||||
@ -697,7 +698,7 @@ void CmndBriPreset(void)
|
|||||||
Settings.bri_preset_high = parm[0];
|
Settings.bri_preset_high = parm[0];
|
||||||
}
|
}
|
||||||
#ifdef USE_DEVICE_GROUPS
|
#ifdef USE_DEVICE_GROUPS
|
||||||
SendLocalDeviceGroupMessage(DGR_MSGTYP_UPDATE, DGR_ITEM_BRI_PRESET_LOW, Settings.bri_preset_low, DGR_ITEM_BRI_PRESET_HIGH, Settings.bri_preset_high);
|
SendDeviceGroupMessage(0, DGR_MSGTYP_UPDATE, DGR_ITEM_BRI_PRESET_LOW, Settings.bri_preset_low, DGR_ITEM_BRI_PRESET_HIGH, Settings.bri_preset_high);
|
||||||
#endif // USE_DEVICE_GROUPS
|
#endif // USE_DEVICE_GROUPS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user