Auto-binding for TRV

This commit is contained in:
Stephan Hadinger 2020-10-02 22:05:55 +02:00
parent a9630b9d05
commit c09828617d
2 changed files with 12 additions and 1 deletions

View File

@ -1302,6 +1302,7 @@ void ZCLFrame::parseReadConfigAttributes(Z_attribute_list& attr_list) {
} }
// find the attribute name // find the attribute name
int8_t multiplier = 1;
for (uint32_t i = 0; i < ARRAY_SIZE(Z_PostProcess); i++) { for (uint32_t i = 0; i < ARRAY_SIZE(Z_PostProcess); i++) {
const Z_AttributeConverter *converter = &Z_PostProcess[i]; const Z_AttributeConverter *converter = &Z_PostProcess[i];
uint16_t conv_cluster = CxToCluster(pgm_read_byte(&converter->cluster_short)); uint16_t conv_cluster = CxToCluster(pgm_read_byte(&converter->cluster_short));
@ -1310,6 +1311,7 @@ void ZCLFrame::parseReadConfigAttributes(Z_attribute_list& attr_list) {
if ((conv_cluster == _cluster_id) && (conv_attribute == attrid)) { if ((conv_cluster == _cluster_id) && (conv_attribute == attrid)) {
const char * attr_name = Z_strings + pgm_read_word(&converter->name_offset); const char * attr_name = Z_strings + pgm_read_word(&converter->name_offset);
attr_2.addAttribute(attr_name, true).setBool(true); attr_2.addAttribute(attr_name, true).setBool(true);
multiplier = pgm_read_byte(&converter->multiplier);
break; break;
} }
} }
@ -1337,6 +1339,12 @@ void ZCLFrame::parseReadConfigAttributes(Z_attribute_list& attr_list) {
// decode Reportable Change // decode Reportable Change
Z_attribute &attr_change = attr_2.addAttribute(F("ReportableChange")); Z_attribute &attr_change = attr_2.addAttribute(F("ReportableChange"));
i += parseSingleAttribute(attr_change, _payload, i, attr_type); i += parseSingleAttribute(attr_change, _payload, i, attr_type);
if ((1 != multiplier) && (0 != multiplier)) {
float fval = attr_change.getFloat();
if (multiplier > 0) { fval = fval * multiplier; }
else { fval = fval / (-multiplier); }
attr_change.setFloat(fval);
}
} }
} }
} }

View File

@ -562,7 +562,7 @@ int32_t Z_ReceiveActiveEp(int32_t res, const class SBuffer &buf) {
// list of clusters that need bindings // list of clusters that need bindings
const uint8_t Z_bindings[] PROGMEM = { const uint8_t Z_bindings[] PROGMEM = {
Cx0001, Cx0006, Cx0008, Cx0300, Cx0001, Cx0006, Cx0008, Cx0201, Cx0300,
Cx0400, Cx0402, Cx0403, Cx0405, Cx0406, Cx0400, Cx0402, Cx0403, Cx0405, Cx0406,
Cx0500, Cx0500,
}; };
@ -1216,6 +1216,9 @@ const Z_autoAttributeReporting_t Z_autoAttributeReporting[] PROGMEM = {
{ 0x0001, 0x0020, 15*60, 15*60, 0.1 }, // BatteryVoltage { 0x0001, 0x0020, 15*60, 15*60, 0.1 }, // BatteryVoltage
{ 0x0001, 0x0021, 15*60, 15*60, 1 }, // BatteryPercentage { 0x0001, 0x0021, 15*60, 15*60, 1 }, // BatteryPercentage
{ 0x0006, 0x0000, 1, 60*60, 0 }, // Power { 0x0006, 0x0000, 1, 60*60, 0 }, // Power
{ 0x0201, 0x0000, 60, 60*10, 0.5 }, // LocalTemperature
{ 0x0201, 0x0008, 60, 60*10, 10 }, // PIHeatingDemand
{ 0x0201, 0x0012, 60, 60*10, 0.5 }, // OccupiedHeatingSetpoint
{ 0x0008, 0x0000, 1, 60*60, 5 }, // Dimmer { 0x0008, 0x0000, 1, 60*60, 5 }, // Dimmer
{ 0x0300, 0x0000, 1, 60*60, 5 }, // Hue { 0x0300, 0x0000, 1, 60*60, 5 }, // Hue
{ 0x0300, 0x0001, 1, 60*60, 5 }, // Sat { 0x0300, 0x0001, 1, 60*60, 5 }, // Sat