Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DevGroupSend command #8093

Merged
merged 1 commit into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 96 additions & 7 deletions Device_Groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ To enable device groups, execute the command SetOption85 1.

The device group name is set with the DevGroupName command. If the device group name is not set for a group, the MQTT group topic is used (with the device group number appended for device group numbers > 1). All devices in the same IP network with the same device group name are in the same group. Some modules may define additional device groups. For example, if Remote Device Mode is enabled, the PWM Dimmer module defines three devices groups.

The items that are sent to the group and the items that are received from the group are selected with the DevGroupShare command. By default all items are sent and received from the group. An example of when the DevGroupShare command would be used is when you have a group of lights that you control with a dimmer switch and home automation software. You want the dimmer switch to be able to control all items. The home automation software controls each light individually. When it controls the whole group, it actually sends command to each light in the group. If you use the home automation software to turn an individual light on or off or change it’s brightness, color or scheme, you do not want the change to be replicated to the other lights. In this case, you would set the incoming and outgoing item masks to 0xffffffff (all items) on the dimmer switch (DevGroupShare 0xffffffff,0xffffffff) and set the incoming item mask to 0xffffffff and outgoing item mask to 0 on all the lights (DevGroupShare 0xffffffff,0).
The items that are sent to the group and the items that are received from the group are selected with the DevGroupShare command. By default all items are sent and received from the group. An example of when the DevGroupShare command would be used is when you have a group of lights that you control with a dimmer switch and home automation software. You want the dimmer switch to be able to control all items. The home automation software controls each light individually. When it controls the whole group, it actually sends command to each light in the group. If you use the home automation software to turn an individual light on or off or change it’s brightness, color or scheme, you do not want the change to be replicated to the other lights. In this case, you would set the incoming and outgoing item masks to 0xffffffff (all items) on the dimmer switch (DevGroupShare 0xffffffff,0xffffffff) and set the incoming item mask to 0xffffffff and outgoing item mask to 0 on all the lights (DevGroupShare 0xffffffff,0).


### Commands
Expand All @@ -27,17 +27,106 @@ The items that are sent to the group and the items that are received from the gr
</td>
</tr>
<tr>
<td>DevGroupShare
<td>DevGroupName&lt;x>
</td>
<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>0 = clear device group &lt;x> name and restart<br>
&lt;value> = set device group &lt;x> name and restart
</td>
</tr>
</tr>
<tr>
<td>DevGroupName&lt;x>
<td>DevGroupSend&lt;x>
</td>
<td>0 = clear device group &lt;x> name and restart<br>
&lt;value> = set device group &lt;x>name and restart
<td>&lt;item>=&lt;value>[ ...] = send an update to device grouup &lt;x>. The device group name must have been previously set with DevGroupName&lt;x>. Multiple items/value pairs can be specified separated by a space. For example, DevGroupSend 4=90 128=1 will send an update to set the light brightness to 90 and turn relay 1 on.<br>
<br>
For items with numeric values, &lt;value> can be specified as @&lt;operator>&lt;value> to send a value after performing an operation on the current value. &lt;operator> can be + (add), - (subtract) or ^ (invert). If a value is not specified for the invert operator, 0xffffffff is used. For example, if the group's current light brightness is 40, DevGroupSend 4=@10 will send an update to increase the light brightness to 50. If all the groups relays are currently on, DevGroupSend 128=^ will turn all the relays off.<br><br>
<table>
<tr>
<td><strong>Item</strong>
</td>
<td><strong>Description</strong>
</td>
<td><strong>Value</strong>
</td>
</tr>
<tr>
<td>2
</td>
<td>Light fade
</td>
<td>0 = Off<br>1 = On
</tr>
<tr>
<td>3
</td>
<td>Light speed
</td>
<td>1..40
</tr>
<tr>
<td>4
</td>
<td>Light brightness
</td>
<td>0..255
</tr>
<tr>
<td>5
</td>
<td>Light scheme
</td>
<td>See Scheme command in <a href="https://tasmota.github.io/docs/Commands/#light">Light Commands</a>
</tr>
<tr>
<td>6
</td>
<td>Light fixed color
</td>
<td>0 = white (using CT channels), 1 = red, 2 = green, 3 = blue, 4 = orange, 5 = light green, 6 = light blue, 7 = amber, 8 = cyan, 9 = purple, 10 = yellow, 11 = pink, 12 = white (using RGB channels)
</tr>
<tr>
<td>7
</td>
<td>PWM dimmer low preset
</td>
<td>0..255
</tr>
<tr>
<td>8
</td>
<td>PWM dimmer high preset
</td>
<td>0..255
</tr>
<tr>
<td>9
</td>
<td>PWM dimmer power-on brightness
</td>
<td>0..255
</tr>
<tr>
<td>128
</td>
<td>Relay Power
</td>
<td>Bitmask with bits set for relays to be powered on. The number of relays can be specified in bits 24 - 31. If the number of relays is not specified, only relay 1 is set.
</tr>
<tr>
<td>224
</td>
<td>Light channels
</td>
<td>Comma separated list of brightness levels (0..255) for channels 1 - 5 (e.g. 255,128,0,0,0 will turn the red channel on at 100% and the green channel on at 50% on an RBG light).
</tr>
</table>
</td>
</tr>
</tr>
<tr>
<td>DevGroupShare
</td>
<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>
</table>
1 change: 1 addition & 0 deletions tasmota/i18n.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@
#define D_CMND_I2CSCAN "I2CScan"
#define D_CMND_I2CDRIVER "I2CDriver"
#define D_CMND_DEVGROUP_NAME "DevGroupName"
#define D_CMND_DEVGROUP_SEND "DevGroupSend"
#define D_CMND_DEVGROUP_SHARE "DevGroupShare"
#define D_CMND_SERIALSEND "SerialSend"
#define D_CMND_SERIALDELIMITER "SerialDelimiter"
Expand Down
5 changes: 3 additions & 2 deletions tasmota/my_user_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,10 @@
#define USE_EXS_DIMMER // Add support for ES-Store WiFi Dimmer (+1k5 code)
// #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_DEVICE_GROUPS // Add support for device groups (+5k code)
#define USE_DEVICE_GROUPS_SEND // Add support for the DevGroupSend command (+0k6 code)
#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_PWM_DIMMER_REMOTE // Add support for remote switches to PWM Dimmer, also adds device groups support (+1k 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)

Expand Down
23 changes: 21 additions & 2 deletions tasmota/support_command.ino
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ const char kTasmotaCommands[] PROGMEM = "|" // No prefix
D_CMND_I2CSCAN "|" D_CMND_I2CDRIVER "|"
#endif
#ifdef USE_DEVICE_GROUPS
D_CMND_DEVGROUP_NAME "|" D_CMND_DEVGROUP_SHARE "|"
D_CMND_DEVGROUP_NAME "|"
#ifdef USE_DEVICE_GROUPS_SEND
D_CMND_DEVGROUP_SEND "|"
#endif // USE_DEVICE_GROUPS_SEND
D_CMND_DEVGROUP_SHARE "|"
#endif // USE_DEVICE_GROUPS
D_CMND_SENSOR "|" D_CMND_DRIVER;

Expand All @@ -51,7 +55,11 @@ void (* const TasmotaCommand[])(void) PROGMEM = {
&CmndI2cScan, CmndI2cDriver,
#endif
#ifdef USE_DEVICE_GROUPS
&CmndDevGroupName, &CmndDevGroupShare,
&CmndDevGroupName,
#ifdef USE_DEVICE_GROUPS_SEND
&CmndDevGroupSend,
#endif // USE_DEVICE_GROUPS_SEND
&CmndDevGroupShare,
#endif // USE_DEVICE_GROUPS
&CmndSensor, &CmndDriver };

Expand Down Expand Up @@ -1722,6 +1730,17 @@ void CmndDevGroupName(void)
}
}

#ifdef USE_DEVICE_GROUPS_SEND
void CmndDevGroupSend(void)
{
uint8_t device_group_index = (XdrvMailbox.usridx ? XdrvMailbox.index - 1 : 0);
if (device_group_index < device_group_count) {
_SendDeviceGroupMessage(device_group_index, DGR_MSGTYPE_UPDATE_COMMAND);
ResponseCmndChar(XdrvMailbox.data);
}
}
#endif // USE_DEVICE_GROUPS_SEND

void CmndDevGroupShare(void)
{
uint32_t parm[2] = { Settings.device_group_share_in, Settings.device_group_share_out };
Expand Down
Loading