mirror of
https://github.com/arendst/Tasmota.git
synced 2025-04-25 07:17:16 +00:00
Merge branch 'development' of https://github.com/arendst/Tasmota into development
This commit is contained in:
commit
99a00613b8
@ -52,7 +52,7 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
### Version 8.1.0.10
|
### Version 8.1.0.11
|
||||||
|
|
||||||
- Change default my_user_config.h driver and sensor support removing most sensors and adding most drivers
|
- Change default my_user_config.h driver and sensor support removing most sensors and adding most drivers
|
||||||
- Change DHT driver (#7468, #7717)
|
- Change DHT driver (#7468, #7717)
|
||||||
@ -116,3 +116,4 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
|
|||||||
- Add support for Jarolift rollers by Keeloq algorithm
|
- Add support for Jarolift rollers by Keeloq algorithm
|
||||||
- Add support for MaxBotix HRXL-MaxSonar ultrasonic range finders by Jon Little (#7814)
|
- Add support for MaxBotix HRXL-MaxSonar ultrasonic range finders by Jon Little (#7814)
|
||||||
- Add support for Romanian language translations by Augustin Marti
|
- Add support for Romanian language translations by Augustin Marti
|
||||||
|
- Add HAss Discovery support for Button and Switch triggers by Federico Leoni (#7901)
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
## Unreleased (development)
|
## Unreleased (development)
|
||||||
|
|
||||||
|
### 8.1.0.11 20200313
|
||||||
|
|
||||||
|
- Add HAss Discovery support for Button and Switch triggers by Federico Leoni (#7901)
|
||||||
|
|
||||||
### 8.1.0.10 20200227
|
### 8.1.0.10 20200227
|
||||||
|
|
||||||
- Change default my_user_config.h driver and sensor support removing most sensors and adding most drivers
|
- Change default my_user_config.h driver and sensor support removing most sensors and adding most drivers
|
||||||
|
@ -1342,7 +1342,7 @@ void CmndWifiConfig(void)
|
|||||||
void CmndFriendlyname(void)
|
void CmndFriendlyname(void)
|
||||||
{
|
{
|
||||||
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_FRIENDLYNAMES)) {
|
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_FRIENDLYNAMES)) {
|
||||||
if (!XdrvMailbox.usridx) {
|
if (!XdrvMailbox.usridx && !XdrvMailbox.data_len) {
|
||||||
ResponseCmndAll(SET_FRIENDLYNAME1, MAX_FRIENDLYNAMES);
|
ResponseCmndAll(SET_FRIENDLYNAME1, MAX_FRIENDLYNAMES);
|
||||||
} else {
|
} else {
|
||||||
if (XdrvMailbox.data_len > 0) {
|
if (XdrvMailbox.data_len > 0) {
|
||||||
|
@ -23,21 +23,25 @@
|
|||||||
#ifdef USE_DEVICE_GROUPS
|
#ifdef USE_DEVICE_GROUPS
|
||||||
|
|
||||||
//#define DEVICE_GROUPS_DEBUG
|
//#define DEVICE_GROUPS_DEBUG
|
||||||
|
#define DGR_MEMBER_TIMEOUT 45000
|
||||||
|
#define DGR_ANNOUNCEMENT_INTERVAL 60000
|
||||||
|
|
||||||
extern bool udp_connected;
|
extern bool udp_connected;
|
||||||
|
|
||||||
struct device_group_member {
|
struct device_group_member {
|
||||||
struct device_group_member * flink;
|
struct device_group_member * flink;
|
||||||
IPAddress ip_address;
|
IPAddress ip_address;
|
||||||
uint32_t timeout_time;
|
|
||||||
uint16_t received_sequence;
|
uint16_t received_sequence;
|
||||||
uint16_t acked_sequence;
|
uint16_t acked_sequence;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct device_group {
|
struct device_group {
|
||||||
|
uint32_t next_announcement_time;
|
||||||
uint32_t next_ack_check_time;
|
uint32_t next_ack_check_time;
|
||||||
|
uint32_t member_timeout_time;
|
||||||
uint16_t last_full_status_sequence;
|
uint16_t last_full_status_sequence;
|
||||||
uint16_t message_length;
|
uint16_t message_length;
|
||||||
|
uint16_t ack_check_interval;
|
||||||
uint8_t message_header_length;
|
uint8_t message_header_length;
|
||||||
uint8_t initial_status_requests_remaining;
|
uint8_t initial_status_requests_remaining;
|
||||||
bool local;
|
bool local;
|
||||||
@ -48,12 +52,12 @@ struct device_group {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct device_group * device_groups;
|
struct device_group * device_groups;
|
||||||
|
uint32_t next_check_time = 0;
|
||||||
uint16_t outgoing_sequence = 0;
|
uint16_t outgoing_sequence = 0;
|
||||||
bool device_groups_initialized = false;
|
bool device_groups_initialized = false;
|
||||||
bool device_groups_initialization_failed = false;
|
bool device_groups_initialization_failed = false;
|
||||||
bool building_status_message = false;
|
bool building_status_message = false;
|
||||||
bool processing_remote_device_message = false;
|
bool processing_remote_device_message = false;
|
||||||
bool waiting_for_acks;
|
|
||||||
bool udp_was_connected = false;
|
bool udp_was_connected = false;
|
||||||
|
|
||||||
void DeviceGroupsInit(void)
|
void DeviceGroupsInit(void)
|
||||||
@ -90,6 +94,17 @@ char * IPAddressToString(const IPAddress& ip_address)
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char * BeginDeviceGroupMessage(struct device_group * device_group, uint16_t flags, bool hold_sequence = false)
|
||||||
|
{
|
||||||
|
char * message_ptr = &device_group->message[device_group->message_header_length];
|
||||||
|
if (!hold_sequence && !++outgoing_sequence) outgoing_sequence = 1;
|
||||||
|
*message_ptr++ = outgoing_sequence & 0xff;
|
||||||
|
*message_ptr++ = outgoing_sequence >> 8;
|
||||||
|
*message_ptr++ = flags & 0xff;
|
||||||
|
*message_ptr++ = flags >> 8;
|
||||||
|
return message_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
// Return true if we're configured to share the specified item.
|
// Return true if we're configured to share the specified item.
|
||||||
bool DeviceGroupItemShared(bool incoming, uint8_t item)
|
bool DeviceGroupItemShared(bool incoming, uint8_t item)
|
||||||
{
|
{
|
||||||
@ -121,6 +136,7 @@ bool DeviceGroupItemShared(bool incoming, uint8_t item)
|
|||||||
|
|
||||||
void SendDeviceGroupPacket(IPAddress ip, char * packet, int len, const char * label)
|
void SendDeviceGroupPacket(IPAddress ip, char * packet, int len, const char * label)
|
||||||
{
|
{
|
||||||
|
if (!ip) ip = IPAddress(239,255,255,250);
|
||||||
for (int attempt = 1; attempt <= 5; attempt++) {
|
for (int attempt = 1; attempt <= 5; attempt++) {
|
||||||
if (PortUdp.beginPacket(ip, 1900)) {
|
if (PortUdp.beginPacket(ip, 1900)) {
|
||||||
PortUdp.write(packet, len);
|
PortUdp.write(packet, len);
|
||||||
@ -166,7 +182,7 @@ void _SendDeviceGroupMessage(uint8_t device_group_index, DeviceGroupMessageType
|
|||||||
device_group->message_length = 0;
|
device_group->message_length = 0;
|
||||||
SendDeviceGroupMessage(device_group_index, DGR_MSGTYP_PARTIAL_UPDATE, DGR_ITEM_POWER, power);
|
SendDeviceGroupMessage(device_group_index, DGR_MSGTYP_PARTIAL_UPDATE, DGR_ITEM_POWER, power);
|
||||||
XdrvMailbox.command_code = DGR_ITEM_STATUS;
|
XdrvMailbox.command_code = DGR_ITEM_STATUS;
|
||||||
XdrvCall(FUNC_DEVICE_GROUP_REQUEST);
|
XdrvCall(FUNC_DEVICE_GROUP_ITEM);
|
||||||
building_status_message = false;
|
building_status_message = false;
|
||||||
|
|
||||||
// If we have nothing to share with the other members, restore the message sequence and return.
|
// If we have nothing to share with the other members, restore the message sequence and return.
|
||||||
@ -190,10 +206,6 @@ void _SendDeviceGroupMessage(uint8_t device_group_index, DeviceGroupMessageType
|
|||||||
#ifdef DEVICE_GROUPS_DEBUG
|
#ifdef DEVICE_GROUPS_DEBUG
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("Building device group %s packet"), device_group->group_name);
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("Building device group %s packet"), device_group->group_name);
|
||||||
#endif // DEVICE_GROUPS_DEBUG
|
#endif // DEVICE_GROUPS_DEBUG
|
||||||
uint16_t original_sequence = outgoing_sequence;
|
|
||||||
if (!building_status_message && message_type != DGR_MSGTYP_PARTIAL_UPDATE && !++outgoing_sequence) outgoing_sequence = 1;
|
|
||||||
*message_ptr++ = outgoing_sequence & 0xff;
|
|
||||||
*message_ptr++ = outgoing_sequence >> 8;
|
|
||||||
|
|
||||||
value = 0;
|
value = 0;
|
||||||
if (message_type == DGR_MSGTYP_UPDATE_MORE_TO_COME)
|
if (message_type == DGR_MSGTYP_UPDATE_MORE_TO_COME)
|
||||||
@ -203,9 +215,7 @@ void _SendDeviceGroupMessage(uint8_t device_group_index, DeviceGroupMessageType
|
|||||||
#ifdef DEVICE_GROUPS_DEBUG
|
#ifdef DEVICE_GROUPS_DEBUG
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(">sequence=%u, flags=%u"), outgoing_sequence, value);
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(">sequence=%u, flags=%u"), outgoing_sequence, value);
|
||||||
#endif // DEVICE_GROUPS_DEBUG
|
#endif // DEVICE_GROUPS_DEBUG
|
||||||
*message_ptr++ = value & 0xff;
|
message_ptr = BeginDeviceGroupMessage(device_group, value, building_status_message || message_type == DGR_MSGTYP_PARTIAL_UPDATE);
|
||||||
*message_ptr++ = value >> 8;
|
|
||||||
char * first_item_ptr = message_ptr;
|
|
||||||
|
|
||||||
// If we're still building this update or all group members haven't acknowledged the previous
|
// If we're still building this update or all group members haven't acknowledged the previous
|
||||||
// update yet, update the message to include these new updates. First we need to rebuild the
|
// update yet, update the message to include these new updates. First we need to rebuild the
|
||||||
@ -356,13 +366,6 @@ void _SendDeviceGroupMessage(uint8_t device_group_index, DeviceGroupMessageType
|
|||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
// If there weren't any items added to the message, restore the outgoing message sequence and
|
|
||||||
// return.
|
|
||||||
if (message_ptr == first_item_ptr) {
|
|
||||||
outgoing_sequence = original_sequence;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the EOL item code and calculate the message length.
|
// Add the EOL item code and calculate the message length.
|
||||||
*message_ptr++ = 0;
|
*message_ptr++ = 0;
|
||||||
device_group->message_length = message_ptr - device_group->message;
|
device_group->message_length = message_ptr - device_group->message;
|
||||||
@ -375,17 +378,24 @@ void _SendDeviceGroupMessage(uint8_t device_group_index, DeviceGroupMessageType
|
|||||||
#ifdef DEVICE_GROUPS_DEBUG
|
#ifdef DEVICE_GROUPS_DEBUG
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DGR: sending %u-byte device group %s packet via multicast, sequence=%u"), device_group->message_length, device_group->group_name, device_group->message[device_group->message_header_length] | device_group->message[device_group->message_header_length + 1] << 8);
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DGR: sending %u-byte device group %s packet via multicast, sequence=%u"), device_group->message_length, device_group->group_name, device_group->message[device_group->message_header_length] | device_group->message[device_group->message_header_length + 1] << 8);
|
||||||
#endif // DEVICE_GROUPS_DEBUG
|
#endif // DEVICE_GROUPS_DEBUG
|
||||||
SendDeviceGroupPacket(IPAddress(239,255,255,250), device_group->message, device_group->message_length, PSTR("Multicast"));
|
SendDeviceGroupPacket(0, device_group->message, device_group->message_length, PSTR("Multicast"));
|
||||||
device_group->next_ack_check_time = millis() + 100;
|
|
||||||
|
|
||||||
|
uint32_t now = millis();
|
||||||
if (message_type == DGR_MSGTYP_UPDATE_MORE_TO_COME) {
|
if (message_type == DGR_MSGTYP_UPDATE_MORE_TO_COME) {
|
||||||
for (struct device_group_member * device_group_member = device_group->device_group_members; device_group_member != nullptr; device_group_member = device_group_member->flink) {
|
device_group->next_ack_check_time = 0;
|
||||||
device_group_member->acked_sequence = outgoing_sequence;
|
// for (struct device_group_member * device_group_member = device_group->device_group_members; device_group_member != nullptr; device_group_member = device_group_member->flink) {
|
||||||
}
|
// device_group_member->acked_sequence = outgoing_sequence;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
waiting_for_acks = true;
|
device_group->ack_check_interval = 100;
|
||||||
|
device_group->next_ack_check_time = now + device_group->ack_check_interval;
|
||||||
|
if (device_group->next_ack_check_time < next_check_time) next_check_time = device_group->next_ack_check_time;
|
||||||
|
device_group->member_timeout_time = now + DGR_MEMBER_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
device_group->next_announcement_time = now + DGR_ANNOUNCEMENT_INTERVAL;
|
||||||
|
if (device_group->next_announcement_time < next_check_time) next_check_time = device_group->next_announcement_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessDeviceGroupMessage(char * packet, int packet_length)
|
void ProcessDeviceGroupMessage(char * packet, int packet_length)
|
||||||
@ -452,13 +462,15 @@ void ProcessDeviceGroupMessage(char * packet, int packet_length)
|
|||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("Received device group %s packet from %s: sequence=%u, flags=%u"), device_group->group_name, IPAddressToString(remote_ip), message_sequence, flags);
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("Received device group %s packet from %s: sequence=%u, flags=%u"), device_group->group_name, IPAddressToString(remote_ip), message_sequence, flags);
|
||||||
#endif // DEVICE_GROUPS_DEBUG
|
#endif // DEVICE_GROUPS_DEBUG
|
||||||
|
|
||||||
|
// If this is an announcement, simply return.
|
||||||
|
if (flags == DGR_FLAG_ANNOUNCEMENT) return;
|
||||||
|
|
||||||
// If this is an ack message, save the message sequence if it's newwer than the last ack we
|
// If this is an ack message, save the message sequence if it's newwer than the last ack we
|
||||||
// received from this member.
|
// received from this member.
|
||||||
if (flags == DGR_FLAG_ACK) {
|
if (flags == DGR_FLAG_ACK) {
|
||||||
if (message_sequence > device_group_member->acked_sequence || device_group_member->acked_sequence - message_sequence < 64536) {
|
if (message_sequence > device_group_member->acked_sequence || device_group_member->acked_sequence - message_sequence < 64536) {
|
||||||
device_group_member->acked_sequence = message_sequence;
|
device_group_member->acked_sequence = message_sequence;
|
||||||
}
|
}
|
||||||
device_group_member->timeout_time = 0;
|
|
||||||
#ifdef DEVICE_GROUPS_DEBUG
|
#ifdef DEVICE_GROUPS_DEBUG
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("<ack"));
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("<ack"));
|
||||||
#endif // DEVICE_GROUPS_DEBUG
|
#endif // DEVICE_GROUPS_DEBUG
|
||||||
@ -468,7 +480,7 @@ void ProcessDeviceGroupMessage(char * packet, int packet_length)
|
|||||||
// Send an ack message to the sender.
|
// Send an ack message to the sender.
|
||||||
if (!(flags & DGR_FLAG_MORE_TO_COME)) {
|
if (!(flags & DGR_FLAG_MORE_TO_COME)) {
|
||||||
*(message_ptr - 2) = DGR_FLAG_ACK;
|
*(message_ptr - 2) = DGR_FLAG_ACK;
|
||||||
*(message_ptr - 1) = 0;
|
*(message_ptr - 1) = 0;
|
||||||
SendDeviceGroupPacket(remote_ip, packet, message_ptr - packet, PSTR("Ack"));
|
SendDeviceGroupPacket(remote_ip, packet, message_ptr - packet, PSTR("Ack"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,11 +497,13 @@ void ProcessDeviceGroupMessage(char * packet, int packet_length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If we already processed this or a later message from this group member, ignore this message.
|
// If we already processed this or a later message from this group member, ignore this message.
|
||||||
if (message_sequence < device_group_member->received_sequence && device_group_member->received_sequence - message_sequence > 64536) {
|
if (message_sequence <= device_group_member->received_sequence) {
|
||||||
|
if (message_sequence == device_group_member->received_sequence || device_group_member->received_sequence - message_sequence > 64536) {
|
||||||
#ifdef DEVICE_GROUPS_DEBUG
|
#ifdef DEVICE_GROUPS_DEBUG
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("<old message"));
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("<old message"));
|
||||||
#endif // DEVICE_GROUPS_DEBUG
|
#endif // DEVICE_GROUPS_DEBUG
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
device_group_member->received_sequence = message_sequence;
|
device_group_member->received_sequence = message_sequence;
|
||||||
|
|
||||||
@ -583,13 +597,13 @@ void ProcessDeviceGroupMessage(char * packet, int packet_length)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
XdrvCall(FUNC_DEVICE_GROUP_REQUEST);
|
XdrvCall(FUNC_DEVICE_GROUP_ITEM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XdrvMailbox.command_code = DGR_ITEM_EOL;
|
XdrvMailbox.command_code = DGR_ITEM_EOL;
|
||||||
XdrvCall(FUNC_DEVICE_GROUP_REQUEST);
|
XdrvCall(FUNC_DEVICE_GROUP_ITEM);
|
||||||
skip_light_fade = false;
|
skip_light_fade = false;
|
||||||
|
|
||||||
processing_remote_device_message = false;
|
processing_remote_device_message = false;
|
||||||
@ -610,72 +624,93 @@ void DeviceGroupsLoop(void)
|
|||||||
{
|
{
|
||||||
if (!Settings.flag4.device_groups_enabled) return;
|
if (!Settings.flag4.device_groups_enabled) return;
|
||||||
if (udp_connected) {
|
if (udp_connected) {
|
||||||
|
uint32_t now = millis();
|
||||||
|
|
||||||
|
// If UDP was not connected before, (re)initialize.
|
||||||
if (!udp_was_connected) {
|
if (!udp_was_connected) {
|
||||||
udp_was_connected = true;
|
udp_was_connected = true;
|
||||||
|
|
||||||
if (!device_groups_initialized) DeviceGroupsInit();
|
if (!device_groups_initialized) DeviceGroupsInit();
|
||||||
if (device_groups_initialization_failed) return;
|
if (device_groups_initialization_failed) return;
|
||||||
|
|
||||||
|
// Load the status request message for all device groups. This message will be multicast 5
|
||||||
|
// times.
|
||||||
|
next_check_time = now + 1000;
|
||||||
for (uint32_t device_group_index = 0; device_group_index < device_group_count; device_group_index++) {
|
for (uint32_t device_group_index = 0; device_group_index < device_group_count; device_group_index++) {
|
||||||
device_group * device_group = &device_groups[device_group_index];
|
device_group * device_group = &device_groups[device_group_index];
|
||||||
char * message_ptr = &device_group->message[device_group->message_header_length];
|
device_group->message_length = BeginDeviceGroupMessage(device_group, DGR_FLAG_RESET | DGR_FLAG_STATUS_REQUEST) - device_group->message;
|
||||||
if (!++outgoing_sequence) outgoing_sequence = 1;
|
|
||||||
*message_ptr++ = outgoing_sequence & 0xff;
|
|
||||||
*message_ptr++ = outgoing_sequence >> 8;
|
|
||||||
*message_ptr++ = DGR_FLAG_RESET | DGR_FLAG_STATUS_REQUEST;
|
|
||||||
*message_ptr++ = 0;
|
|
||||||
device_group->message_length = message_ptr - device_group->message;
|
|
||||||
device_group->initial_status_requests_remaining = 5;
|
device_group->initial_status_requests_remaining = 5;
|
||||||
device_group->next_ack_check_time = millis() + 1000;
|
device_group->next_ack_check_time = next_check_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
waiting_for_acks = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device_groups_initialization_failed) return;
|
if (device_groups_initialization_failed) return;
|
||||||
|
|
||||||
if (waiting_for_acks) {
|
// If it's time to check on things, iterate through the device groups.
|
||||||
uint32_t now = millis();
|
if (next_check_time <= now) {
|
||||||
waiting_for_acks = false;
|
#ifdef DEVICE_GROUPS_DEBUG
|
||||||
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DGR: Ckecking next_check_time=%u, now=%u"), next_check_time, now);
|
||||||
|
#endif // DEVICE_GROUPS_DEBUG
|
||||||
|
next_check_time = now + DGR_ANNOUNCEMENT_INTERVAL * 2;
|
||||||
|
|
||||||
for (uint32_t device_group_index = 0; device_group_index < device_group_count; device_group_index++) {
|
for (uint32_t device_group_index = 0; device_group_index < device_group_count; device_group_index++) {
|
||||||
device_group * device_group = &device_groups[device_group_index];
|
device_group * device_group = &device_groups[device_group_index];
|
||||||
|
|
||||||
|
// If we're still waiting for acks to the last update from this device group, ...
|
||||||
if (device_group->next_ack_check_time) {
|
if (device_group->next_ack_check_time) {
|
||||||
|
|
||||||
|
// If it's time to check for acks, ...
|
||||||
if (device_group->next_ack_check_time <= now) {
|
if (device_group->next_ack_check_time <= now) {
|
||||||
|
|
||||||
|
// If we're still sending the initial status request message, send it.
|
||||||
if (device_group->initial_status_requests_remaining) {
|
if (device_group->initial_status_requests_remaining) {
|
||||||
#ifdef DEVICE_GROUPS_DEBUG
|
#ifdef DEVICE_GROUPS_DEBUG
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DGR: sending initial status request for group %s"), device_group->group_name);
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DGR: sending initial status request for group %s"), device_group->group_name);
|
||||||
#endif // DEVICE_GROUPS_DEBUG
|
#endif // DEVICE_GROUPS_DEBUG
|
||||||
if (--device_group->initial_status_requests_remaining) {
|
if (--device_group->initial_status_requests_remaining) {
|
||||||
SendDeviceGroupPacket(IPAddress(239,255,255,250), device_group->message, device_group->message_length, PSTR("Initial"));
|
SendDeviceGroupPacket(0, device_group->message, device_group->message_length, PSTR("Initial"));
|
||||||
device_group->message[device_group->message_header_length + 2] = DGR_FLAG_STATUS_REQUEST; // The reset flag is on only for the first packet - turn it off now
|
device_group->message[device_group->message_header_length + 2] = DGR_FLAG_STATUS_REQUEST; // The reset flag is on only for the first packet - turn it off now
|
||||||
device_group->next_ack_check_time = now + 200;
|
device_group->next_ack_check_time = now + 200;
|
||||||
waiting_for_acks = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we've sent the initial status request message 5 times, send our status to all
|
||||||
|
// the members.
|
||||||
else {
|
else {
|
||||||
device_group->next_ack_check_time = 0;
|
device_group->next_ack_check_time = 0;
|
||||||
_SendDeviceGroupMessage(device_group_index, DGR_MSGTYP_FULL_STATUS);
|
_SendDeviceGroupMessage(device_group_index, DGR_MSGTYP_FULL_STATUS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we're done initializing, iterate through the group memebers, ...
|
||||||
else {
|
else {
|
||||||
|
#ifdef DEVICE_GROUPS_DEBUG
|
||||||
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DGR: checking for ack's"));
|
||||||
|
#endif // DEVICE_GROUPS_DEBUG
|
||||||
bool acked = true;
|
bool acked = true;
|
||||||
struct device_group_member ** flink = &device_group->device_group_members;
|
struct device_group_member ** flink = &device_group->device_group_members;
|
||||||
struct device_group_member * device_group_member;
|
struct device_group_member * device_group_member;
|
||||||
while ((device_group_member = *flink)) {
|
while ((device_group_member = *flink)) {
|
||||||
|
|
||||||
|
// If we have not received an ack to our last message from this member, ...
|
||||||
if (device_group_member->acked_sequence != outgoing_sequence) {
|
if (device_group_member->acked_sequence != outgoing_sequence) {
|
||||||
|
|
||||||
if (device_group_member->timeout_time && device_group_member->timeout_time < now) {
|
// If we haven't receive an ack from this member in DGR_MEMBER_TIMEOUT ms, assume
|
||||||
|
// they're offline and remove them from the group.
|
||||||
|
if (device_group->member_timeout_time < now) {
|
||||||
#ifdef DEVICE_GROUPS_DEBUG
|
#ifdef DEVICE_GROUPS_DEBUG
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DGR: removing member %s (%p)"), IPAddressToString(device_group_member->ip_address), device_group_member);
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DGR: removing member %s (%p)"), IPAddressToString(device_group_member->ip_address), device_group_member);
|
||||||
#endif // DEVICE_GROUPS_DEBUG
|
#endif // DEVICE_GROUPS_DEBUG
|
||||||
*flink = device_group_member->flink;
|
*flink = device_group_member->flink;
|
||||||
free(device_group_member);
|
free(device_group_member);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Otherwise, unicast the last message directly to this member.
|
||||||
else {
|
else {
|
||||||
#ifdef DEVICE_GROUPS_DEBUG
|
#ifdef DEVICE_GROUPS_DEBUG
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DGR: sending %u-byte device group %s packet via unicast to %s, sequence %u, last message acked=%u"), device_group->message_length, device_group->group_name, IPAddressToString(device_group_member->ip_address), outgoing_sequence, device_group_member->acked_sequence);
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DGR: sending %u-byte device group %s packet via unicast to %s, sequence %u, last message acked=%u"), device_group->message_length, device_group->group_name, IPAddressToString(device_group_member->ip_address), outgoing_sequence, device_group_member->acked_sequence);
|
||||||
#endif // DEVICE_GROUPS_DEBUG
|
#endif // DEVICE_GROUPS_DEBUG
|
||||||
SendDeviceGroupPacket(device_group_member->ip_address, device_group->message, device_group->message_length, PSTR("Unicast"));
|
SendDeviceGroupPacket(device_group_member->ip_address, device_group->message, device_group->message_length, PSTR("Unicast"));
|
||||||
if (!device_group_member->timeout_time) device_group_member->timeout_time = now + 15000;
|
|
||||||
acked = false;
|
acked = false;
|
||||||
flink = &device_group_member->flink;
|
flink = &device_group_member->flink;
|
||||||
}
|
}
|
||||||
@ -684,20 +719,45 @@ void DeviceGroupsLoop(void)
|
|||||||
flink = &device_group_member->flink;
|
flink = &device_group_member->flink;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we've received an ack to the last message from all members, clear the ack check
|
||||||
|
// time and zero-out the message length.
|
||||||
if (acked) {
|
if (acked) {
|
||||||
device_group->next_ack_check_time = 0;
|
device_group->next_ack_check_time = 0;
|
||||||
device_group->message_length = 0;
|
device_group->message_length = 0; // Let _SendDeviceGroupMessage know we're done with this update
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If there are still members we haven't received an ack from, set the next ack check
|
||||||
|
// time. We start at 200ms and double the interval each pass with a maximum interval of
|
||||||
|
// 5 seconds.
|
||||||
else {
|
else {
|
||||||
device_group->next_ack_check_time = now + 500;
|
device_group->ack_check_interval *= 2;
|
||||||
waiting_for_acks = true;
|
if (device_group->ack_check_interval > 5000) device_group->ack_check_interval = 5000;
|
||||||
|
device_group->next_ack_check_time = now + device_group->ack_check_interval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
waiting_for_acks = true;
|
if (device_group->next_ack_check_time < next_check_time) next_check_time = device_group->next_ack_check_time;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If it's time to send multicast announcement for this group, send it. This is to
|
||||||
|
// announcement ourself to any members that have somehow not heard about us. We send it at
|
||||||
|
// the announcement interval plus a random number of milliseconds so that even if all the
|
||||||
|
// devices booted at the same time, they don't all multicast their announcements at the same
|
||||||
|
// time.
|
||||||
|
#ifdef DEVICE_GROUPS_DEBUG
|
||||||
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DGR: next_announcement_time=%u, now=%u"), device_group->next_announcement_time, now);
|
||||||
|
#endif // DEVICE_GROUPS_DEBUG
|
||||||
|
if (device_group->next_announcement_time <= now) {
|
||||||
|
device_group->message_length = BeginDeviceGroupMessage(device_group, DGR_FLAG_ANNOUNCEMENT) - device_group->message;
|
||||||
|
#ifdef DEVICE_GROUPS_DEBUG
|
||||||
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DGR: sending %u-byte device group %s announcement"), device_group->message_length, device_group->group_name);
|
||||||
|
#endif // DEVICE_GROUPS_DEBUG
|
||||||
|
SendDeviceGroupPacket(0, device_group->message, device_group->message_length, PSTR("Announcement"));
|
||||||
|
device_group->next_announcement_time = now + DGR_ANNOUNCEMENT_INTERVAL + random(10000);
|
||||||
|
}
|
||||||
|
if (device_group->next_announcement_time < next_check_time) next_check_time = device_group->next_announcement_time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -278,7 +278,7 @@ enum XsnsFunctions {FUNC_SETTINGS_OVERRIDE, FUNC_PIN_STATE, FUNC_MODULE_INIT, FU
|
|||||||
FUNC_ENERGY_EVERY_SECOND, FUNC_ENERGY_RESET,
|
FUNC_ENERGY_EVERY_SECOND, FUNC_ENERGY_RESET,
|
||||||
FUNC_RULES_PROCESS, FUNC_SERIAL, FUNC_FREE_MEM, FUNC_BUTTON_PRESSED,
|
FUNC_RULES_PROCESS, FUNC_SERIAL, FUNC_FREE_MEM, FUNC_BUTTON_PRESSED,
|
||||||
FUNC_WEB_ADD_BUTTON, FUNC_WEB_ADD_MAIN_BUTTON, FUNC_WEB_ADD_HANDLER, FUNC_SET_CHANNELS, FUNC_SET_SCHEME, FUNC_HOTPLUG_SCAN,
|
FUNC_WEB_ADD_BUTTON, FUNC_WEB_ADD_MAIN_BUTTON, FUNC_WEB_ADD_HANDLER, FUNC_SET_CHANNELS, FUNC_SET_SCHEME, FUNC_HOTPLUG_SCAN,
|
||||||
FUNC_DEVICE_GROUP_REQUEST };
|
FUNC_DEVICE_GROUP_ITEM };
|
||||||
|
|
||||||
enum AddressConfigSteps { ADDR_IDLE, ADDR_RECEIVE, ADDR_SEND };
|
enum AddressConfigSteps { ADDR_IDLE, ADDR_RECEIVE, ADDR_SEND };
|
||||||
|
|
||||||
@ -305,14 +305,13 @@ enum SettingsTextIndex { SET_OTAURL,
|
|||||||
|
|
||||||
enum DeviceGroupMessageType { DGR_MSGTYP_FULL_STATUS, DGR_MSGTYP_PARTIAL_UPDATE, DGR_MSGTYP_UPDATE, DGR_MSGTYP_UPDATE_MORE_TO_COME, DGR_MSGTYP_UPDATE_DIRECT, DGR_MSGTYP_REUPDATE };
|
enum DeviceGroupMessageType { DGR_MSGTYP_FULL_STATUS, DGR_MSGTYP_PARTIAL_UPDATE, DGR_MSGTYP_UPDATE, DGR_MSGTYP_UPDATE_MORE_TO_COME, DGR_MSGTYP_UPDATE_DIRECT, DGR_MSGTYP_REUPDATE };
|
||||||
|
|
||||||
enum DeviceGroupMessageFlag { DGR_FLAG_RESET = 1, DGR_FLAG_STATUS_REQUEST = 2, DGR_FLAG_FULL_STATUS = 4, DGR_FLAG_ACK = 8, DGR_FLAG_MORE_TO_COME = 16, DGR_FLAG_DIRECT = 32 };
|
enum DeviceGroupMessageFlag { DGR_FLAG_RESET = 1, DGR_FLAG_STATUS_REQUEST = 2, DGR_FLAG_FULL_STATUS = 4, DGR_FLAG_ACK = 8, DGR_FLAG_MORE_TO_COME = 16, DGR_FLAG_DIRECT = 32, DGR_FLAG_ANNOUNCEMENT = 64 };
|
||||||
|
|
||||||
enum DeviceGroupItem { DGR_ITEM_EOL, DGR_ITEM_STATUS,
|
enum DeviceGroupItem { DGR_ITEM_EOL, DGR_ITEM_STATUS,
|
||||||
DGR_ITEM_LIGHT_FADE, DGR_ITEM_LIGHT_SPEED, DGR_ITEM_LIGHT_BRI, DGR_ITEM_LIGHT_SCHEME, DGR_ITEM_LIGHT_FIXED_COLOR,
|
DGR_ITEM_LIGHT_FADE, DGR_ITEM_LIGHT_SPEED, DGR_ITEM_LIGHT_BRI, DGR_ITEM_LIGHT_SCHEME, DGR_ITEM_LIGHT_FIXED_COLOR,
|
||||||
DGR_ITEM_BRI_PRESET_LOW, DGR_ITEM_BRI_PRESET_HIGH, DGR_ITEM_BRI_POWER_ON,
|
DGR_ITEM_BRI_PRESET_LOW, DGR_ITEM_BRI_PRESET_HIGH, DGR_ITEM_BRI_POWER_ON,
|
||||||
// Add new 8-bit items before this line
|
// Add new 8-bit items before this line
|
||||||
DGR_ITEM_LAST_8BIT, DGR_ITEM_MAX_8BIT = 63,
|
DGR_ITEM_LAST_8BIT, DGR_ITEM_MAX_8BIT = 63,
|
||||||
DGR_ITEM_ACK,
|
|
||||||
DGR_ITEM_ANALOG1, DGR_ITEM_ANALOG2, DGR_ITEM_ANALOG3, DGR_ITEM_ANALOG4, DGR_ITEM_ANALOG5,
|
DGR_ITEM_ANALOG1, DGR_ITEM_ANALOG2, DGR_ITEM_ANALOG3, DGR_ITEM_ANALOG4, DGR_ITEM_ANALOG5,
|
||||||
// Add new 16-bit items before this line
|
// Add new 16-bit items before this line
|
||||||
DGR_ITEM_LAST_16BIT, DGR_ITEM_MAX_16BIT = 127,
|
DGR_ITEM_LAST_16BIT, DGR_ITEM_MAX_16BIT = 127,
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#ifndef _TASMOTA_VERSION_H_
|
#ifndef _TASMOTA_VERSION_H_
|
||||||
#define _TASMOTA_VERSION_H_
|
#define _TASMOTA_VERSION_H_
|
||||||
|
|
||||||
const uint32_t VERSION = 0x0801000A;
|
const uint32_t VERSION = 0x0801000B;
|
||||||
|
|
||||||
// Lowest compatible version
|
// Lowest compatible version
|
||||||
const uint32_t VERSION_COMPATIBLE = 0x07010006;
|
const uint32_t VERSION_COMPATIBLE = 0x07010006;
|
||||||
|
@ -712,13 +712,6 @@ void MqttCheck(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ButtonTopicActive(void)
|
|
||||||
{
|
|
||||||
char key_topic[TOPSZ];
|
|
||||||
Format(key_topic, SettingsText(SET_MQTT_BUTTON_TOPIC), sizeof(key_topic));
|
|
||||||
return ((strlen(key_topic) != 0) && strcmp(key_topic, "0"));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool KeyTopicActive(uint32_t key)
|
bool KeyTopicActive(uint32_t key)
|
||||||
{
|
{
|
||||||
// key = 0 - Button topic
|
// key = 0 - Button topic
|
||||||
|
@ -2090,7 +2090,7 @@ void LightSendDeviceGroupStatus()
|
|||||||
DGR_ITEM_LIGHT_BRI, (power ? light_state.getBri() : 0));
|
DGR_ITEM_LIGHT_BRI, (power ? light_state.getBri() : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightHandleDeviceGroupRequest()
|
void LightHandleDeviceGroupItem()
|
||||||
{
|
{
|
||||||
static bool send_state = false;
|
static bool send_state = false;
|
||||||
uint32_t value = XdrvMailbox.payload;
|
uint32_t value = XdrvMailbox.payload;
|
||||||
@ -2716,8 +2716,8 @@ bool Xdrv04(uint8_t function)
|
|||||||
LightAnimate();
|
LightAnimate();
|
||||||
break;
|
break;
|
||||||
#ifdef USE_DEVICE_GROUPS
|
#ifdef USE_DEVICE_GROUPS
|
||||||
case FUNC_DEVICE_GROUP_REQUEST:
|
case FUNC_DEVICE_GROUP_ITEM:
|
||||||
LightHandleDeviceGroupRequest();
|
LightHandleDeviceGroupItem();
|
||||||
break;
|
break;
|
||||||
#endif // USE_DEVICE_GROUPS
|
#endif // USE_DEVICE_GROUPS
|
||||||
case FUNC_SET_POWER:
|
case FUNC_SET_POWER:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
xdrv_12_home_assistant.ino - home assistant support for Tasmota
|
xdrv_12_home_assistant.ino - home assistant support for Tasmota
|
||||||
|
|
||||||
Copyright (C) 2020 Theo Arends
|
Copyright (C) 2020 Erik Montnemery, Federico Leoni and Theo Arends
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -339,7 +339,7 @@ void HAssAnnounceSwitches(void)
|
|||||||
uint8_t hold = 0;
|
uint8_t hold = 0;
|
||||||
|
|
||||||
if (pin[GPIO_SWT1 + switch_index] < 99) { switch_present = 1; }
|
if (pin[GPIO_SWT1 + switch_index] < 99) { switch_present = 1; }
|
||||||
|
|
||||||
if (KeyTopicActive(1) && strcmp(SettingsText(SET_MQTT_SWITCH_TOPIC), mqtt_topic)) // Enable Discovery for Switches only if Switchtopic is set to a custom name
|
if (KeyTopicActive(1) && strcmp(SettingsText(SET_MQTT_SWITCH_TOPIC), mqtt_topic)) // Enable Discovery for Switches only if Switchtopic is set to a custom name
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -361,7 +361,7 @@ void HAssAnnounceSwitches(void)
|
|||||||
// 12 PUSHHOLDMULTI_INV NO TOGGLE (button_short_press) NONE CLEAR (button_long_press) 1,0
|
// 12 PUSHHOLDMULTI_INV NO TOGGLE (button_short_press) NONE CLEAR (button_long_press) 1,0
|
||||||
// INV (not available) INC_DEC (not available)
|
// INV (not available) INC_DEC (not available)
|
||||||
// Please note: SwitchMode11 and 12 will register just TOGGLE (button_short_press)
|
// Please note: SwitchMode11 and 12 will register just TOGGLE (button_short_press)
|
||||||
|
|
||||||
// Trigger types: "0 = none | 1 = button_short_press | 2 = button_long_press | 3 = button_double_press";
|
// Trigger types: "0 = none | 1 = button_short_press | 2 = button_long_press | 3 = button_double_press";
|
||||||
|
|
||||||
uint8_t swmode = Settings.switchmode[switch_index];
|
uint8_t swmode = Settings.switchmode[switch_index];
|
||||||
@ -390,7 +390,7 @@ void HAssAnnounceSwitches(void)
|
|||||||
hold = 3;
|
hold = 3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { switch_present = 0;}
|
} else { switch_present = 0;}
|
||||||
|
|
||||||
HAssAnnouncerTriggers(switch_index, switch_present, 1, toggle, hold);
|
HAssAnnouncerTriggers(switch_index, switch_present, 1, toggle, hold);
|
||||||
@ -417,21 +417,21 @@ void HAssAnnounceButtons(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// button matrix for triggers generation when buttontopic is set as custom (default TOGGLE = 1 HOLD = 0):
|
// button matrix for triggers generation when buttontopic is set as custom (default TOGGLE = 1 HOLD = 0):
|
||||||
// N SetOption1 SetOption11 SetOption13 PRESS DOUBLE PRESS HOLD T,H
|
// N SetOption1 SetOption11 SetOption13 PRESS DOUBLE PRESS HOLD T,H
|
||||||
// 1 0 0 0 TOGGLE (button_short_press) NONE (toggle real relay) NONE (reset device) 1,0
|
// 1 0 0 0 TOGGLE (button_short_press) NONE (toggle real relay) NONE (reset device) 1,0
|
||||||
// 2 1 0 0 TOGGLE (button_short_press) NONE (toggle real relay) HOLD (button_long_press) 1,2
|
// 2 1 0 0 TOGGLE (button_short_press) NONE (toggle real relay) HOLD (button_long_press) 1,2
|
||||||
// 3 0 1 0 NONE (toggle real relay) TOGGLE (button_double_press) NONE (reset device) 3,0
|
// 3 0 1 0 NONE (toggle real relay) TOGGLE (button_double_press) NONE (reset device) 3,0
|
||||||
// 4 1 1 0 NONE (toggle real relay) TOGGLE (button_double_press) HOLD (button_long_press) 3,2
|
// 4 1 1 0 NONE (toggle real relay) TOGGLE (button_double_press) HOLD (button_long_press) 3,2
|
||||||
// 5 0 0 1 TOGGLE (button_short_press) NONE (toggle real relay) NONE (reset device) 1,0
|
// 5 0 0 1 TOGGLE (button_short_press) NONE (toggle real relay) NONE (reset device) 1,0
|
||||||
// 6 1 0 1 TOGGLE (button_short_press) NONE (toggle real relay) NONE (MQTT HOLD) 1,0
|
// 6 1 0 1 TOGGLE (button_short_press) NONE (toggle real relay) NONE (MQTT HOLD) 1,0
|
||||||
// 7 0 1 1 NONE (toggle real relay) NONE (toggle real relay) NONE (reset device) 0,0
|
// 7 0 1 1 NONE (toggle real relay) NONE (toggle real relay) NONE (reset device) 0,0
|
||||||
// 8 1 1 1 NONE (toggle real relay) NONE (toggle real relay) NONE (MQTT HOLD) 0.0
|
// 8 1 1 1 NONE (toggle real relay) NONE (toggle real relay) NONE (MQTT HOLD) 0.0
|
||||||
|
|
||||||
// Trigger types: "0 = none | 1 = button_short_press | 2 = button_long_press | 3 = button_double_press";
|
// Trigger types: "0 = none | 1 = button_short_press | 2 = button_long_press | 3 = button_double_press";
|
||||||
|
|
||||||
if (Settings.flag.button_restrict) { // [SetOption1] Enable/Disable button multipress
|
if (Settings.flag.button_restrict) { // [SetOption1] Enable/Disable button multipress
|
||||||
if (!Settings.flag.button_single) {
|
if (!Settings.flag.button_single) {
|
||||||
hold = 2; // Default TOGGLE (button_short_press) + HOLD (button_long_press) trigger if [SetOption13] is OFF
|
hold = 2; // Default TOGGLE (button_short_press) + HOLD (button_long_press) trigger if [SetOption13] is OFF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -440,19 +440,19 @@ void HAssAnnounceButtons(void)
|
|||||||
if (!Settings.flag.button_restrict) {
|
if (!Settings.flag.button_restrict) {
|
||||||
hold = 0; // TOGGLE (button_double_press) and remove HOLD (button_long_press) trigger if [SetOption1] is OFF
|
hold = 0; // TOGGLE (button_double_press) and remove HOLD (button_long_press) trigger if [SetOption1] is OFF
|
||||||
}
|
}
|
||||||
toggle = 3; // TOGGLE (button_double_press)
|
toggle = 3; // TOGGLE (button_double_press)
|
||||||
} else {toggle = 0; hold = 0;} // [SetOption13] Immediate action on button press, no TOGGLE or HOLD triggers
|
} else {toggle = 0; hold = 0;} // [SetOption13] Immediate action on button press, no TOGGLE or HOLD triggers
|
||||||
}
|
}
|
||||||
|
|
||||||
if (KeyTopicActive(0)) { // Enable Discovery for Buttons only if Buttontopic is set to 1 or a custom name
|
if (KeyTopicActive(0)) { // Enable Discovery for Buttons only if Buttontopic is set to 1 or a custom name
|
||||||
|
|
||||||
if (!strcmp(SettingsText(SET_MQTT_BUTTON_TOPIC), mqtt_topic)) {
|
if (!strcmp(SettingsText(SET_MQTT_BUTTON_TOPIC), mqtt_topic)) {
|
||||||
toggle = 0; // When ButtonTopic is set to 1, TOGGLE is not allowed but an HOLD trigger can be generated.
|
toggle = 0; // When ButtonTopic is set to 1, TOGGLE is not allowed but an HOLD trigger can be generated.
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { button_present = 0; }
|
} else { button_present = 0; }
|
||||||
|
|
||||||
HAssAnnouncerTriggers(button_index, button_present, 0, toggle, hold);
|
HAssAnnouncerTriggers(button_index, button_present, 0, toggle, hold);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,8 +596,8 @@ void HAssAnnounceStatusSensor(void)
|
|||||||
|
|
||||||
Response_P(HASS_DISCOVER_BASE, name, state_topic, availability_topic);
|
Response_P(HASS_DISCOVER_BASE, name, state_topic, availability_topic);
|
||||||
TryResponseAppend_P(HASS_DISCOVER_SENSOR_HASS_STATUS, state_topic);
|
TryResponseAppend_P(HASS_DISCOVER_SENSOR_HASS_STATUS, state_topic);
|
||||||
TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO, unique_id, ESP.getChipId(), WiFi.macAddress().c_str(),
|
TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO, unique_id, ESP.getChipId(), SettingsText(SET_FRIENDLYNAME1),
|
||||||
SettingsText(SET_FRIENDLYNAME1), ModuleName().c_str(), my_version, my_image);
|
ModuleName().c_str(), my_version, my_image);
|
||||||
TryResponseAppend_P(PSTR("}"));
|
TryResponseAppend_P(PSTR("}"));
|
||||||
}
|
}
|
||||||
MqttPublish(stopic, true);
|
MqttPublish(stopic, true);
|
||||||
|
@ -228,7 +228,7 @@ void PWMDimmerSetBri(uint8_t bri)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_DEVICE_GROUPS
|
#ifdef USE_DEVICE_GROUPS
|
||||||
void PWMDimmerHandleDeviceGroupRequest()
|
void PWMDimmerHandleDeviceGroupItem()
|
||||||
{
|
{
|
||||||
static bool send_state = false;
|
static bool send_state = false;
|
||||||
uint32_t value = XdrvMailbox.payload;
|
uint32_t value = XdrvMailbox.payload;
|
||||||
@ -1041,8 +1041,8 @@ bool Xdrv35(uint8_t function)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef USE_DEVICE_GROUPS
|
#ifdef USE_DEVICE_GROUPS
|
||||||
case FUNC_DEVICE_GROUP_REQUEST:
|
case FUNC_DEVICE_GROUP_ITEM:
|
||||||
PWMDimmerHandleDeviceGroupRequest();
|
PWMDimmerHandleDeviceGroupItem();
|
||||||
break;
|
break;
|
||||||
#endif // USE_DEVICE_GROUPS
|
#endif // USE_DEVICE_GROUPS
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user