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

Zigbee support for air sensors #18665

Merged
merged 2 commits into from
May 15, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ All notable changes to this project will be documented in this file.
- Support for GM861 1D and 2D bar code reader (#18399)
- Berry `re` (regex) add `match2` and optional offset
- Support for PCA9557 8-bit I/O expander (#18632)
- Zigbee support for air sensors

### Breaking Changed
- Change command ``FileUpload`` index binary data detection from >199 to >299
Expand Down
6 changes: 3 additions & 3 deletions tasmota/tasmota_xdrv_driver/xdrv_23_zigbee_1z_libs.ino
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ public:
// Bit #9 is `0` command is cluster specific, or `1` general_command
uint8_t key_suffix; // append a suffix to key (default is 1, explicitly output if >1)
uint8_t attr_type; // [opt] type of the attribute, default to Zunk (0xFF)
uint16_t attr_multiplier; // [opt] multiplier for attribute, defaults to 0x01 (no change)
uint16_t attr_divider; // [opt] divider
int16_t attr_base; // [opt] base for conversion
uint16_t manuf; // manufacturer id (0 if none)
uint32_t attr_multiplier; // [opt] multiplier for attribute, defaults to 0x01 (no change)
uint32_t attr_divider; // [opt] divider
int32_t attr_base; // [opt] base for conversion

// Constructor with all defaults
Z_attribute():
Expand Down
20 changes: 10 additions & 10 deletions tasmota/tasmota_xdrv_driver/xdrv_23_zigbee_5_1_attributes.ino
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,9 @@ public:
}

uint8_t type; // zigbee type, Zunk by default
uint16_t multiplier; // multiply by x (ignore if 0 or 1)
uint16_t divider; // divide by x (ignore if 0 or 1)
int16_t base; // add x (ignore if 0)
uint32_t multiplier; // multiply by x (ignore if 0 or 1)
uint32_t divider; // divide by x (ignore if 0 or 1)
int32_t base; // add x (ignore if 0)
uint16_t cluster; // cluster number
uint16_t attribute; // attribute number
uint16_t manuf; // manufacturer code, 0 if none
Expand All @@ -338,7 +338,7 @@ public:
{};

void set(uint16_t cluster, uint16_t attribute, uint16_t new_cluster, uint16_t new_attribute,
int8_t multiplier = 1, int8_t divider = 1, int16_t base = 0) {
uint32_t multiplier = 1, uint32_t divider = 1, int32_t base = 0) {
this->cluster = cluster;
this->attribute = attribute;
this->new_cluster = new_cluster;
Expand All @@ -354,9 +354,9 @@ public:
uint16_t attribute; // attribute to match
uint16_t new_cluster; // replace with this cluster
uint16_t new_attribute; // replace with this attribute
uint16_t multiplier; // multiply by x (ignore if 0 or 1)
uint16_t divider; // divide by x (ignore if 0 or 1)
int16_t base; // add x (ignore if 0)
uint32_t multiplier; // multiply by x (ignore if 0 or 1)
uint32_t divider; // divide by x (ignore if 0 or 1)
int32_t base; // add x (ignore if 0)
};

//
Expand Down Expand Up @@ -530,9 +530,9 @@ public:
uint16_t cluster = 0xFFFF;
uint16_t attribute = 0xFFFF;
const char * name = nullptr;
uint16_t multiplier = 1;
uint16_t divider = 1;
int16_t base = 0;
uint32_t multiplier = 1;
uint32_t divider = 1;
int32_t base = 0;
uint8_t zigbee_type = Znodata;
uint8_t map_offset = 0;
Z_Data_Type map_type = Z_Data_Type::Z_Unknown;
Expand Down
6 changes: 3 additions & 3 deletions tasmota/tasmota_xdrv_driver/xdrv_23_zigbee_5_2_converters.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1000,9 +1000,9 @@ void ZCLFrame::parseReadConfigAttributes(uint16_t shortaddr, Z_attribute_list& a
}

// find the multiplier
uint16_t multiplier = 1;
uint16_t divider = 1;
int16_t base = 0;
uint32_t multiplier = 1;
uint32_t divider = 1;
int32_t base = 0;
Z_attribute_match matched_attr = Z_findAttributeMatcherById(shortaddr, cluster, attrid, false);
if (matched_attr.found()) {
attr_2.addAttribute(matched_attr.name, true).setBool(true);
Expand Down
14 changes: 7 additions & 7 deletions tasmota/tasmota_xdrv_driver/xdrv_23_zigbee_7_7_plugin.ino
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ bool ZbLoad_inner(const char *filename, File &fp) {
uint16_t attr_id = 0xFFFF;
uint16_t cluster_id = 0xFFFF;
uint8_t type_id = Zunk;
uint16_t multiplier = 1;
uint16_t divider = 1;
int16_t base = 0;
uint32_t multiplier = 1;
uint32_t divider = 1;
int32_t base = 0;
char * name = nullptr;
uint16_t manuf = 0;

Expand Down Expand Up @@ -281,9 +281,9 @@ bool ZbLoad_inner(const char *filename, File &fp) {
char * delimiter_slash2 = strchr(tok2, '/');
uint16_t new_cluster_id = strtoul(tok2, &delimiter_slash2, 16);
uint16_t new_attr_id = strtoul(delimiter_slash2+1, nullptr, 16);
uint16_t multiplier = 1;
uint16_t divider = 1;
int16_t base = 0;
uint32_t multiplier = 1;
uint32_t divider = 1;
int32_t base = 0;

// ADDITIONAL ELEMENTS?
while (token = strtok_r(rest, ",", &rest)) {
Expand Down Expand Up @@ -386,7 +386,7 @@ bool ZbUnload(const char *filename_raw) {
}

// append modifiers like mul/div/manuf
void Z_AppendModifiers(char * buf, size_t buf_len, uint16_t multiplier, uint16_t divider, int16_t base, uint16_t manuf) {
void Z_AppendModifiers(char * buf, size_t buf_len, uint32_t multiplier, uint32_t divider, int32_t base, uint16_t manuf) {
if (multiplier != 0 && multiplier != 1) {
ext_snprintf_P(buf, buf_len, "%s,%s%i", buf, Z_MUL, multiplier);
}
Expand Down
2 changes: 1 addition & 1 deletion tasmota/tasmota_xdrv_driver/xdrv_23_zigbee_A_impl.ino
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ void zigbeeZCLSendCmd(class ZCLFrame &zcl) {
// I.e. multipliers and dividers are inversed
// multiplier == 0: ignore
// multiplier == 1: ignore
void ZbApplyMultiplierForWrites(double &val_d, uint16_t multiplier, uint16_t divider, int16_t base) {
void ZbApplyMultiplierForWrites(double &val_d, uint32_t multiplier, uint32_t divider, int32_t base) {
if (0 != base) {
val_d = val_d - base;
}
Expand Down
7 changes: 7 additions & 0 deletions tasmota/zigbee/air_quality.zb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#Z2Tv1
# Extension for Air Quality - clusters from Concentration Measurement
: # apply to all devices
040D/0000,CO2,mul:1000000 # concentration in ppm
040D/0001,CO2Min,mul:1000000
040D/0002,CO2Max,mul:1000000
040D/0003,CO2Tolerance,mul:1000000