From 0cbe2fc58796b5c3b1aa8024d9a8b26160bd3aba Mon Sep 17 00:00:00 2001 From: s-hadinger <49731213+s-hadinger@users.noreply.github.com> Date: Wed, 3 May 2023 18:30:34 +0200 Subject: [PATCH] Matter support for Shutters with Tilt (#18569) --- CHANGELOG.md | 1 + .../src/embedded/Matter_Plugin_Shutter.be | 12 +- .../src/embedded/Matter_Plugin_ShutterTilt.be | 68 ++- .../solidified_Matter_Plugin_Shutter.h | 38 +- .../solidified_Matter_Plugin_ShutterTilt.h | 404 ++++++++++++++---- 5 files changed, 399 insertions(+), 124 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67f37e0ee..ee3c3bebb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file. - Matter UI to change endpoints configuration (#18498) - Matter support for Shutters (without Tilt) (#18509) - Support for TC74 temperature sensor by Michael Loftis (#18042) +- Matter support for Shutters with Tilt ### Breaking Changed diff --git a/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_Shutter.be b/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_Shutter.be index c3e0f38df..7648bf5e5 100644 --- a/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_Shutter.be +++ b/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_Shutter.be @@ -153,8 +153,8 @@ class Matter_Plugin_Shutter : Matter_Plugin_Device ############################################################# # parse sensor # - # The device calls regularly `tasmota.read_sensors()` and converts - # it to json. + # parse the output from `ShutterPosition` + # Ex: `{"Shutter1":{"Position":50,"Direction":0,"Target":50,"Tilt":30}}` def parse_sensors(payload) import string var k = "Shutter" + str(self.tasmota_shutter_index + 1) @@ -169,14 +169,6 @@ class Matter_Plugin_Shutter : Matter_Plugin_Device end self.shadow_shutter_pos = val_pos end - # Tilt - we can keep it here knowing that it won't change if not implemented - var val_tilt = v.find("Tilt") - if val_tilt != nil - if val_tilt != self.shadow_shutter_tilt - self.attribute_updated(0x0102, 0x000F) # CurrentPositionTiltPercent100ths - end - self.shadow_shutter_tilt = val_tilt - end # Direction var val_dir = v.find("Direction") if val_dir != nil diff --git a/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_ShutterTilt.be b/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_ShutterTilt.be index 7d8adb7b4..c181cff36 100644 --- a/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_ShutterTilt.be +++ b/lib/libesp32/berry_matter/src/embedded/Matter_Plugin_ShutterTilt.be @@ -44,6 +44,7 @@ class Matter_Plugin_ShutterTilt : Matter_Plugin_Shutter # var shadow_shutter_target # var shadow_shutter_tilt # var shadow_shutter_direction # 1=opening -1=closing 0=not moving TODO + var tilt_min, tilt_max ############################################################# # Constructor inherited @@ -51,6 +52,46 @@ class Matter_Plugin_ShutterTilt : Matter_Plugin_Shutter ############################################################# # Update shadow inherited + ############################################################# + # parse sensor + # + # parse the output from `ShutterPosition` + # Ex: `{"Shutter1":{"Position":50,"Direction":0,"Target":50,"Tilt":30}}` + def parse_sensors(payload) + import string + var k = "Shutter" + str(self.tasmota_shutter_index + 1) + if payload.contains(k) + var v = payload[k] + # Tilt - we can keep it here knowing that it won't change if not implemented + var val_tilt = v.find("Tilt") + if val_tilt != nil + if val_tilt != self.shadow_shutter_tilt + self.attribute_updated(0x0102, 0x000F) # CurrentPositionTiltPercent100ths + end + self.shadow_shutter_tilt = val_tilt + end + # + end + super(self).parse_sensors(payload) # parse other shutter values + end + + ############################################################# + # Update tilt min/max + # + # Update the min and max tilt values from Status 12 + def update_tilt_min_max() + # get the min/max tilt values + var r_st13 = tasmota.cmd("Status 13", true) # issue `Status 13` + if r_st13.contains('StatusSHT') + r_st13 = r_st13['StatusSHT'] # skip root + var d = r_st13.find("SHT"+str(self.tasmota_shutter_index), {}).find('TiltConfig') + if d != nil + self.tilt_min = int(d[0]) + self.tilt_max = int(d[1]) + end + end + end + ############################################################# # read an attribute # @@ -67,9 +108,20 @@ class Matter_Plugin_ShutterTilt : Matter_Plugin_Shutter return TLV.create_TLV(TLV.U1, 1 + 8 + 16) # Operational + Lift Position Aware + Tilt Position Aware elif attribute == 0x000F # ---------- CurrentPositionTiltPercent100ths / u8 ---------- - return TLV.create_TLV(TLV.U2, (100 - self.shadow_shutter_tilt) * 100) + self.update_tilt_min_max() + if self.tilt_min != nil && self.tilt_max != nil + var tilt_percentage = tasmota.scale_uint(self.shadow_shutter_tilt, self.tilt_min, self.tilt_max, 0, 1000) + return TLV.create_TLV(TLV.U2, tilt_percentage) + else + return TLV.create_TLV(TLV.NULL, nil) # return invalid + end elif attribute == 0x000C # ---------- TargetPositionTiltPercent100ths / u16 ---------- - return TLV.create_TLV(TLV.U1, 0) # TODO + if self.tilt_min != nil && self.tilt_max != nil + var tilt_percentage = tasmota.scale_uint(self.shadow_shutter_tilt, self.tilt_min, self.tilt_max, 0, 1000) + return TLV.create_TLV(TLV.U2, tilt_percentage) + else + return TLV.create_TLV(TLV.NULL, nil) # return invalid + end elif attribute == 0xFFFC # ---------- FeatureMap / map32 ---------- return TLV.create_TLV(TLV.U4, 3 + 4 + 16) # Lift + Tilt + PA_LF + PA_TL @@ -96,8 +148,16 @@ class Matter_Plugin_ShutterTilt : Matter_Plugin_Shutter if command == 0x0008 # ---------- GoToTiltPercentage ---------- var tilt = val.findsubval(0) if tilt != nil - tilt = tilt / 10 - ctx.log = "tilt%:"+str(tilt) + self.update_tilt_min_max() + if self.tilt_min != nil && self.tilt_max != nil + var tilt_val = tasmota.scale_uint(tilt, 0, 1000, self.tilt_min, self.tilt_max) + tasmota.cmd("ShutterTilt"+str(self.tasmota_shutter_index+1) + " " + str(tilt_val), false) # TODO + self.update_shadow() + ctx.log = "tilt%:"+str(tilt) + else + ctx.log = "tilt%(no_tilt_support):"+str(tilt) + end + end return true end diff --git a/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_Shutter.h b/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_Shutter.h index 54edf5622..ec02f9890 100644 --- a/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_Shutter.h +++ b/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_Shutter.h @@ -464,7 +464,7 @@ be_local_closure(Matter_Plugin_Shutter_invoke_request, /* name */ ********************************************************************/ be_local_closure(Matter_Plugin_Shutter_parse_sensors, /* name */ be_nested_proto( - 13, /* nstack */ + 12, /* nstack */ 2, /* argc */ 2, /* varg */ 0, /* has upvals */ @@ -472,7 +472,7 @@ be_local_closure(Matter_Plugin_Shutter_parse_sensors, /* name */ 0, /* has sup protos */ NULL, /* no sub protos */ 1, /* has constants */ - ( &(const bvalue[15]) { /* constants */ + ( &(const bvalue[13]) { /* constants */ /* K0 */ be_nested_str_weak(string), /* K1 */ be_nested_str_weak(Shutter), /* K2 */ be_nested_str_weak(tasmota_shutter_index), @@ -482,16 +482,14 @@ be_local_closure(Matter_Plugin_Shutter_parse_sensors, /* name */ /* K6 */ be_nested_str_weak(Position), /* K7 */ be_nested_str_weak(shadow_shutter_pos), /* K8 */ be_nested_str_weak(attribute_updated), - /* K9 */ be_nested_str_weak(Tilt), - /* K10 */ be_nested_str_weak(shadow_shutter_tilt), - /* K11 */ be_nested_str_weak(Direction), - /* K12 */ be_nested_str_weak(shadow_shutter_direction), - /* K13 */ be_nested_str_weak(Target), - /* K14 */ be_nested_str_weak(shadow_shutter_target), + /* K9 */ be_nested_str_weak(Direction), + /* K10 */ be_nested_str_weak(shadow_shutter_direction), + /* K11 */ be_nested_str_weak(Target), + /* K12 */ be_nested_str_weak(shadow_shutter_target), }), be_str_weak(parse_sensors), &be_const_str_solidified, - ( &(const binstruction[68]) { /* code */ + ( &(const binstruction[54]) { /* code */ 0xA40A0000, // 0000 IMPORT R2 K0 0x600C0008, // 0001 GETGBL R3 G8 0x88100102, // 0002 GETMBR R4 R0 K2 @@ -501,7 +499,7 @@ be_local_closure(Matter_Plugin_Shutter_parse_sensors, /* name */ 0x8C100304, // 0006 GETMET R4 R1 K4 0x5C180600, // 0007 MOVE R6 R3 0x7C100400, // 0008 CALL R4 2 - 0x78120038, // 0009 JMPF R4 #0043 + 0x7812002A, // 0009 JMPF R4 #0035 0x94100203, // 000A GETIDX R4 R1 R3 0x8C140905, // 000B GETMET R5 R4 K5 0x581C0006, // 000C LDCONST R7 K6 @@ -528,7 +526,7 @@ be_local_closure(Matter_Plugin_Shutter_parse_sensors, /* name */ 0x781E0003, // 0021 JMPF R7 #0026 0x8C1C0108, // 0022 GETMET R7 R0 K8 0x54260101, // 0023 LDINT R9 258 - 0x542A000E, // 0024 LDINT R10 15 + 0x542A0009, // 0024 LDINT R10 10 0x7C1C0600, // 0025 CALL R7 3 0x90021406, // 0026 SETMBR R0 K10 R6 0x8C1C0905, // 0027 GETMET R7 R4 K5 @@ -542,24 +540,10 @@ be_local_closure(Matter_Plugin_Shutter_parse_sensors, /* name */ 0x78220003, // 002F JMPF R8 #0034 0x8C200108, // 0030 GETMET R8 R0 K8 0x542A0101, // 0031 LDINT R10 258 - 0x542E0009, // 0032 LDINT R11 10 + 0x542E000A, // 0032 LDINT R11 11 0x7C200600, // 0033 CALL R8 3 0x90021807, // 0034 SETMBR R0 K12 R7 - 0x8C200905, // 0035 GETMET R8 R4 K5 - 0x5828000D, // 0036 LDCONST R10 K13 - 0x7C200400, // 0037 CALL R8 2 - 0x4C240000, // 0038 LDNIL R9 - 0x20241009, // 0039 NE R9 R8 R9 - 0x78260007, // 003A JMPF R9 #0043 - 0x8824010E, // 003B GETMBR R9 R0 K14 - 0x20241009, // 003C NE R9 R8 R9 - 0x78260003, // 003D JMPF R9 #0042 - 0x8C240108, // 003E GETMET R9 R0 K8 - 0x542E0101, // 003F LDINT R11 258 - 0x5432000A, // 0040 LDINT R12 11 - 0x7C240600, // 0041 CALL R9 3 - 0x90021C08, // 0042 SETMBR R0 K14 R8 - 0x80000000, // 0043 RET 0 + 0x80000000, // 0035 RET 0 }) ) ); diff --git a/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_ShutterTilt.h b/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_ShutterTilt.h index 8126a9e45..9e22968e0 100644 --- a/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_ShutterTilt.h +++ b/lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_ShutterTilt.h @@ -6,12 +6,82 @@ extern const bclass be_class_Matter_Plugin_ShutterTilt; +/******************************************************************** +** Solidified function: update_tilt_min_max +********************************************************************/ +be_local_closure(Matter_Plugin_ShutterTilt_update_tilt_min_max, /* name */ + be_nested_proto( + 6, /* nstack */ + 1, /* argc */ + 2, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[13]) { /* constants */ + /* K0 */ be_nested_str_weak(tasmota), + /* K1 */ be_nested_str_weak(cmd), + /* K2 */ be_nested_str_weak(Status_X2013), + /* K3 */ be_nested_str_weak(contains), + /* K4 */ be_nested_str_weak(StatusSHT), + /* K5 */ be_nested_str_weak(find), + /* K6 */ be_nested_str_weak(SHT), + /* K7 */ be_nested_str_weak(tasmota_shutter_index), + /* K8 */ be_nested_str_weak(TiltConfig), + /* K9 */ be_nested_str_weak(tilt_min), + /* K10 */ be_const_int(0), + /* K11 */ be_nested_str_weak(tilt_max), + /* K12 */ be_const_int(1), + }), + be_str_weak(update_tilt_min_max), + &be_const_str_solidified, + ( &(const binstruction[33]) { /* code */ + 0xB8060000, // 0000 GETNGBL R1 K0 + 0x8C040301, // 0001 GETMET R1 R1 K1 + 0x580C0002, // 0002 LDCONST R3 K2 + 0x50100200, // 0003 LDBOOL R4 1 0 + 0x7C040600, // 0004 CALL R1 3 + 0x8C080303, // 0005 GETMET R2 R1 K3 + 0x58100004, // 0006 LDCONST R4 K4 + 0x7C080400, // 0007 CALL R2 2 + 0x780A0016, // 0008 JMPF R2 #0020 + 0x94040304, // 0009 GETIDX R1 R1 K4 + 0x8C080305, // 000A GETMET R2 R1 K5 + 0x60100008, // 000B GETGBL R4 G8 + 0x88140107, // 000C GETMBR R5 R0 K7 + 0x7C100200, // 000D CALL R4 1 + 0x00120C04, // 000E ADD R4 K6 R4 + 0x60140013, // 000F GETGBL R5 G19 + 0x7C140000, // 0010 CALL R5 0 + 0x7C080600, // 0011 CALL R2 3 + 0x8C080505, // 0012 GETMET R2 R2 K5 + 0x58100008, // 0013 LDCONST R4 K8 + 0x7C080400, // 0014 CALL R2 2 + 0x4C0C0000, // 0015 LDNIL R3 + 0x200C0403, // 0016 NE R3 R2 R3 + 0x780E0007, // 0017 JMPF R3 #0020 + 0x600C0009, // 0018 GETGBL R3 G9 + 0x9410050A, // 0019 GETIDX R4 R2 K10 + 0x7C0C0200, // 001A CALL R3 1 + 0x90021203, // 001B SETMBR R0 K9 R3 + 0x600C0009, // 001C GETGBL R3 G9 + 0x9410050C, // 001D GETIDX R4 R2 K12 + 0x7C0C0200, // 001E CALL R3 1 + 0x90021603, // 001F SETMBR R0 K11 R3 + 0x80000000, // 0020 RET 0 + }) + ) +); +/*******************************************************************/ + + /******************************************************************** ** Solidified function: invoke_request ********************************************************************/ be_local_closure(Matter_Plugin_ShutterTilt_invoke_request, /* name */ be_nested_proto( - 13, /* nstack */ + 16, /* nstack */ 4, /* argc */ 2, /* varg */ 0, /* has upvals */ @@ -19,7 +89,7 @@ be_local_closure(Matter_Plugin_ShutterTilt_invoke_request, /* name */ 0, /* has sup protos */ NULL, /* no sub protos */ 1, /* has constants */ - ( &(const bvalue[11]) { /* constants */ + ( &(const bvalue[23]) { /* constants */ /* K0 */ be_nested_str_weak(light), /* K1 */ be_nested_str_weak(matter), /* K2 */ be_nested_str_weak(TLV), @@ -28,13 +98,25 @@ be_local_closure(Matter_Plugin_ShutterTilt_invoke_request, /* name */ /* K5 */ be_nested_str_weak(update_shadow_lazy), /* K6 */ be_nested_str_weak(findsubval), /* K7 */ be_const_int(0), - /* K8 */ be_nested_str_weak(log), - /* K9 */ be_nested_str_weak(tilt_X25_X3A), - /* K10 */ be_nested_str_weak(invoke_request), + /* K8 */ be_nested_str_weak(update_tilt_min_max), + /* K9 */ be_nested_str_weak(tilt_min), + /* K10 */ be_nested_str_weak(tilt_max), + /* K11 */ be_nested_str_weak(tasmota), + /* K12 */ be_nested_str_weak(scale_uint), + /* K13 */ be_nested_str_weak(cmd), + /* K14 */ be_nested_str_weak(ShutterTilt), + /* K15 */ be_nested_str_weak(tasmota_shutter_index), + /* K16 */ be_const_int(1), + /* K17 */ be_nested_str_weak(_X20), + /* K18 */ be_nested_str_weak(update_shadow), + /* K19 */ be_nested_str_weak(log), + /* K20 */ be_nested_str_weak(tilt_X25_X3A), + /* K21 */ be_nested_str_weak(tilt_X25_X28no_tilt_support_X29_X3A), + /* K22 */ be_nested_str_weak(invoke_request), }), be_str_weak(invoke_request), &be_const_str_solidified, - ( &(const binstruction[37]) { /* code */ + ( &(const binstruction[75]) { /* code */ 0xA4120000, // 0000 IMPORT R4 K0 0xB8160200, // 0001 GETNGBL R5 K1 0x88140B02, // 0002 GETMBR R5 R5 K2 @@ -42,36 +124,74 @@ be_local_closure(Matter_Plugin_ShutterTilt_invoke_request, /* name */ 0x881C0704, // 0004 GETMBR R7 R3 K4 0x54220101, // 0005 LDINT R8 258 0x1C200C08, // 0006 EQ R8 R6 R8 - 0x78220013, // 0007 JMPF R8 #001C + 0x78220039, // 0007 JMPF R8 #0042 0x8C200105, // 0008 GETMET R8 R0 K5 0x7C200200, // 0009 CALL R8 1 0x54220007, // 000A LDINT R8 8 0x1C200E08, // 000B EQ R8 R7 R8 - 0x7822000E, // 000C JMPF R8 #001C + 0x78220034, // 000C JMPF R8 #0042 0x8C200506, // 000D GETMET R8 R2 K6 0x58280007, // 000E LDCONST R10 K7 0x7C200400, // 000F CALL R8 2 0x4C240000, // 0010 LDNIL R9 0x20241009, // 0011 NE R9 R8 R9 - 0x78260006, // 0012 JMPF R9 #001A - 0x54260009, // 0013 LDINT R9 10 - 0x0C201009, // 0014 DIV R8 R8 R9 - 0x60240008, // 0015 GETGBL R9 G8 - 0x5C281000, // 0016 MOVE R10 R8 - 0x7C240200, // 0017 CALL R9 1 - 0x00261209, // 0018 ADD R9 K9 R9 - 0x900E1009, // 0019 SETMBR R3 K8 R9 - 0x50240200, // 001A LDBOOL R9 1 0 - 0x80041200, // 001B RET 1 R9 - 0x60200003, // 001C GETGBL R8 G3 - 0x5C240000, // 001D MOVE R9 R0 - 0x7C200200, // 001E CALL R8 1 - 0x8C20110A, // 001F GETMET R8 R8 K10 - 0x5C280200, // 0020 MOVE R10 R1 - 0x5C2C0400, // 0021 MOVE R11 R2 - 0x5C300600, // 0022 MOVE R12 R3 - 0x7C200800, // 0023 CALL R8 4 - 0x80041000, // 0024 RET 1 R8 + 0x7826002C, // 0012 JMPF R9 #0040 + 0x8C240108, // 0013 GETMET R9 R0 K8 + 0x7C240200, // 0014 CALL R9 1 + 0x88240109, // 0015 GETMBR R9 R0 K9 + 0x4C280000, // 0016 LDNIL R10 + 0x2024120A, // 0017 NE R9 R9 R10 + 0x78260021, // 0018 JMPF R9 #003B + 0x8824010A, // 0019 GETMBR R9 R0 K10 + 0x4C280000, // 001A LDNIL R10 + 0x2024120A, // 001B NE R9 R9 R10 + 0x7826001D, // 001C JMPF R9 #003B + 0xB8261600, // 001D GETNGBL R9 K11 + 0x8C24130C, // 001E GETMET R9 R9 K12 + 0x5C2C1000, // 001F MOVE R11 R8 + 0x58300007, // 0020 LDCONST R12 K7 + 0x543603E7, // 0021 LDINT R13 1000 + 0x88380109, // 0022 GETMBR R14 R0 K9 + 0x883C010A, // 0023 GETMBR R15 R0 K10 + 0x7C240C00, // 0024 CALL R9 6 + 0xB82A1600, // 0025 GETNGBL R10 K11 + 0x8C28150D, // 0026 GETMET R10 R10 K13 + 0x60300008, // 0027 GETGBL R12 G8 + 0x8834010F, // 0028 GETMBR R13 R0 K15 + 0x00341B10, // 0029 ADD R13 R13 K16 + 0x7C300200, // 002A CALL R12 1 + 0x00321C0C, // 002B ADD R12 K14 R12 + 0x00301911, // 002C ADD R12 R12 K17 + 0x60340008, // 002D GETGBL R13 G8 + 0x5C381200, // 002E MOVE R14 R9 + 0x7C340200, // 002F CALL R13 1 + 0x0030180D, // 0030 ADD R12 R12 R13 + 0x50340000, // 0031 LDBOOL R13 0 0 + 0x7C280600, // 0032 CALL R10 3 + 0x8C280112, // 0033 GETMET R10 R0 K18 + 0x7C280200, // 0034 CALL R10 1 + 0x60280008, // 0035 GETGBL R10 G8 + 0x5C2C1000, // 0036 MOVE R11 R8 + 0x7C280200, // 0037 CALL R10 1 + 0x002A280A, // 0038 ADD R10 K20 R10 + 0x900E260A, // 0039 SETMBR R3 K19 R10 + 0x70020004, // 003A JMP #0040 + 0x60240008, // 003B GETGBL R9 G8 + 0x5C281000, // 003C MOVE R10 R8 + 0x7C240200, // 003D CALL R9 1 + 0x00262A09, // 003E ADD R9 K21 R9 + 0x900E2609, // 003F SETMBR R3 K19 R9 + 0x50240200, // 0040 LDBOOL R9 1 0 + 0x80041200, // 0041 RET 1 R9 + 0x60200003, // 0042 GETGBL R8 G3 + 0x5C240000, // 0043 MOVE R9 R0 + 0x7C200200, // 0044 CALL R8 1 + 0x8C201116, // 0045 GETMET R8 R8 K22 + 0x5C280200, // 0046 MOVE R10 R1 + 0x5C2C0400, // 0047 MOVE R11 R2 + 0x5C300600, // 0048 MOVE R12 R3 + 0x7C200800, // 0049 CALL R8 4 + 0x80041000, // 004A RET 1 R8 }) ) ); @@ -83,7 +203,7 @@ be_local_closure(Matter_Plugin_ShutterTilt_invoke_request, /* name */ ********************************************************************/ be_local_closure(Matter_Plugin_ShutterTilt_read_attribute, /* name */ be_nested_proto( - 12, /* nstack */ + 14, /* nstack */ 3, /* argc */ 2, /* varg */ 0, /* has upvals */ @@ -91,7 +211,7 @@ be_local_closure(Matter_Plugin_ShutterTilt_read_attribute, /* name */ 0, /* has sup protos */ NULL, /* no sub protos */ 1, /* has constants */ - ( &(const bvalue[15]) { /* constants */ + ( &(const bvalue[21]) { /* constants */ /* K0 */ be_nested_str_weak(string), /* K1 */ be_nested_str_weak(matter), /* K2 */ be_nested_str_weak(TLV), @@ -101,16 +221,22 @@ be_local_closure(Matter_Plugin_ShutterTilt_read_attribute, /* name */ /* K6 */ be_nested_str_weak(create_TLV), /* K7 */ be_nested_str_weak(U1), /* K8 */ be_const_int(1), - /* K9 */ be_nested_str_weak(U2), - /* K10 */ be_nested_str_weak(shadow_shutter_tilt), - /* K11 */ be_const_int(0), - /* K12 */ be_nested_str_weak(U4), - /* K13 */ be_const_int(3), - /* K14 */ be_nested_str_weak(read_attribute), + /* K9 */ be_nested_str_weak(update_tilt_min_max), + /* K10 */ be_nested_str_weak(tilt_min), + /* K11 */ be_nested_str_weak(tilt_max), + /* K12 */ be_nested_str_weak(tasmota), + /* K13 */ be_nested_str_weak(scale_uint), + /* K14 */ be_nested_str_weak(shadow_shutter_tilt), + /* K15 */ be_const_int(0), + /* K16 */ be_nested_str_weak(U2), + /* K17 */ be_nested_str_weak(NULL), + /* K18 */ be_nested_str_weak(U4), + /* K19 */ be_const_int(3), + /* K20 */ be_nested_str_weak(read_attribute), }), be_str_weak(read_attribute), &be_const_str_solidified, - ( &(const binstruction[63]) { /* code */ + ( &(const binstruction[105]) { /* code */ 0xA40E0000, // 0000 IMPORT R3 K0 0xB8120200, // 0001 GETNGBL R4 K1 0x88100902, // 0002 GETMBR R4 R4 K2 @@ -118,7 +244,7 @@ be_local_closure(Matter_Plugin_ShutterTilt_read_attribute, /* name */ 0x88180504, // 0004 GETMBR R6 R2 K4 0x541E0101, // 0005 LDINT R7 258 0x1C1C0A07, // 0006 EQ R7 R5 R7 - 0x781E002E, // 0007 JMPF R7 #0037 + 0x781E0058, // 0007 JMPF R7 #0061 0x8C1C0105, // 0008 GETMET R7 R0 K5 0x7C1C0200, // 0009 CALL R7 1 0x541E0006, // 000A LDINT R7 7 @@ -132,48 +258,156 @@ be_local_closure(Matter_Plugin_ShutterTilt_read_attribute, /* name */ 0x0028140B, // 0012 ADD R10 R10 R11 0x7C1C0600, // 0013 CALL R7 3 0x80040E00, // 0014 RET 1 R7 - 0x70020020, // 0015 JMP #0037 + 0x7002004A, // 0015 JMP #0061 0x541E000E, // 0016 LDINT R7 15 0x1C1C0C07, // 0017 EQ R7 R6 R7 - 0x781E0009, // 0018 JMPF R7 #0023 - 0x8C1C0906, // 0019 GETMET R7 R4 K6 - 0x88240909, // 001A GETMBR R9 R4 K9 - 0x542A0063, // 001B LDINT R10 100 - 0x882C010A, // 001C GETMBR R11 R0 K10 - 0x0428140B, // 001D SUB R10 R10 R11 - 0x542E0063, // 001E LDINT R11 100 - 0x0828140B, // 001F MUL R10 R10 R11 - 0x7C1C0600, // 0020 CALL R7 3 - 0x80040E00, // 0021 RET 1 R7 - 0x70020013, // 0022 JMP #0037 - 0x541E000B, // 0023 LDINT R7 12 - 0x1C1C0C07, // 0024 EQ R7 R6 R7 - 0x781E0005, // 0025 JMPF R7 #002C - 0x8C1C0906, // 0026 GETMET R7 R4 K6 - 0x88240907, // 0027 GETMBR R9 R4 K7 - 0x5828000B, // 0028 LDCONST R10 K11 - 0x7C1C0600, // 0029 CALL R7 3 - 0x80040E00, // 002A RET 1 R7 - 0x7002000A, // 002B JMP #0037 - 0x541EFFFB, // 002C LDINT R7 65532 - 0x1C1C0C07, // 002D EQ R7 R6 R7 - 0x781E0007, // 002E JMPF R7 #0037 - 0x8C1C0906, // 002F GETMET R7 R4 K6 - 0x8824090C, // 0030 GETMBR R9 R4 K12 - 0x542A0003, // 0031 LDINT R10 4 - 0x002A1A0A, // 0032 ADD R10 K13 R10 - 0x542E000F, // 0033 LDINT R11 16 - 0x0028140B, // 0034 ADD R10 R10 R11 - 0x7C1C0600, // 0035 CALL R7 3 - 0x80040E00, // 0036 RET 1 R7 - 0x601C0003, // 0037 GETGBL R7 G3 - 0x5C200000, // 0038 MOVE R8 R0 - 0x7C1C0200, // 0039 CALL R7 1 - 0x8C1C0F0E, // 003A GETMET R7 R7 K14 - 0x5C240200, // 003B MOVE R9 R1 - 0x5C280400, // 003C MOVE R10 R2 - 0x7C1C0600, // 003D CALL R7 3 - 0x80040E00, // 003E RET 1 R7 + 0x781E001D, // 0018 JMPF R7 #0037 + 0x8C1C0109, // 0019 GETMET R7 R0 K9 + 0x7C1C0200, // 001A CALL R7 1 + 0x881C010A, // 001B GETMBR R7 R0 K10 + 0x4C200000, // 001C LDNIL R8 + 0x201C0E08, // 001D NE R7 R7 R8 + 0x781E0011, // 001E JMPF R7 #0031 + 0x881C010B, // 001F GETMBR R7 R0 K11 + 0x4C200000, // 0020 LDNIL R8 + 0x201C0E08, // 0021 NE R7 R7 R8 + 0x781E000D, // 0022 JMPF R7 #0031 + 0xB81E1800, // 0023 GETNGBL R7 K12 + 0x8C1C0F0D, // 0024 GETMET R7 R7 K13 + 0x8824010E, // 0025 GETMBR R9 R0 K14 + 0x8828010A, // 0026 GETMBR R10 R0 K10 + 0x882C010B, // 0027 GETMBR R11 R0 K11 + 0x5830000F, // 0028 LDCONST R12 K15 + 0x543603E7, // 0029 LDINT R13 1000 + 0x7C1C0C00, // 002A CALL R7 6 + 0x8C200906, // 002B GETMET R8 R4 K6 + 0x88280910, // 002C GETMBR R10 R4 K16 + 0x5C2C0E00, // 002D MOVE R11 R7 + 0x7C200600, // 002E CALL R8 3 + 0x80041000, // 002F RET 1 R8 + 0x70020004, // 0030 JMP #0036 + 0x8C1C0906, // 0031 GETMET R7 R4 K6 + 0x88240911, // 0032 GETMBR R9 R4 K17 + 0x4C280000, // 0033 LDNIL R10 + 0x7C1C0600, // 0034 CALL R7 3 + 0x80040E00, // 0035 RET 1 R7 + 0x70020029, // 0036 JMP #0061 + 0x541E000B, // 0037 LDINT R7 12 + 0x1C1C0C07, // 0038 EQ R7 R6 R7 + 0x781E001B, // 0039 JMPF R7 #0056 + 0x881C010A, // 003A GETMBR R7 R0 K10 + 0x4C200000, // 003B LDNIL R8 + 0x201C0E08, // 003C NE R7 R7 R8 + 0x781E0011, // 003D JMPF R7 #0050 + 0x881C010B, // 003E GETMBR R7 R0 K11 + 0x4C200000, // 003F LDNIL R8 + 0x201C0E08, // 0040 NE R7 R7 R8 + 0x781E000D, // 0041 JMPF R7 #0050 + 0xB81E1800, // 0042 GETNGBL R7 K12 + 0x8C1C0F0D, // 0043 GETMET R7 R7 K13 + 0x8824010E, // 0044 GETMBR R9 R0 K14 + 0x8828010A, // 0045 GETMBR R10 R0 K10 + 0x882C010B, // 0046 GETMBR R11 R0 K11 + 0x5830000F, // 0047 LDCONST R12 K15 + 0x543603E7, // 0048 LDINT R13 1000 + 0x7C1C0C00, // 0049 CALL R7 6 + 0x8C200906, // 004A GETMET R8 R4 K6 + 0x88280910, // 004B GETMBR R10 R4 K16 + 0x5C2C0E00, // 004C MOVE R11 R7 + 0x7C200600, // 004D CALL R8 3 + 0x80041000, // 004E RET 1 R8 + 0x70020004, // 004F JMP #0055 + 0x8C1C0906, // 0050 GETMET R7 R4 K6 + 0x88240911, // 0051 GETMBR R9 R4 K17 + 0x4C280000, // 0052 LDNIL R10 + 0x7C1C0600, // 0053 CALL R7 3 + 0x80040E00, // 0054 RET 1 R7 + 0x7002000A, // 0055 JMP #0061 + 0x541EFFFB, // 0056 LDINT R7 65532 + 0x1C1C0C07, // 0057 EQ R7 R6 R7 + 0x781E0007, // 0058 JMPF R7 #0061 + 0x8C1C0906, // 0059 GETMET R7 R4 K6 + 0x88240912, // 005A GETMBR R9 R4 K18 + 0x542A0003, // 005B LDINT R10 4 + 0x002A260A, // 005C ADD R10 K19 R10 + 0x542E000F, // 005D LDINT R11 16 + 0x0028140B, // 005E ADD R10 R10 R11 + 0x7C1C0600, // 005F CALL R7 3 + 0x80040E00, // 0060 RET 1 R7 + 0x601C0003, // 0061 GETGBL R7 G3 + 0x5C200000, // 0062 MOVE R8 R0 + 0x7C1C0200, // 0063 CALL R7 1 + 0x8C1C0F14, // 0064 GETMET R7 R7 K20 + 0x5C240200, // 0065 MOVE R9 R1 + 0x5C280400, // 0066 MOVE R10 R2 + 0x7C1C0600, // 0067 CALL R7 3 + 0x80040E00, // 0068 RET 1 R7 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: parse_sensors +********************************************************************/ +be_local_closure(Matter_Plugin_ShutterTilt_parse_sensors, /* name */ + be_nested_proto( + 10, /* nstack */ + 2, /* argc */ + 2, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[10]) { /* constants */ + /* K0 */ be_nested_str_weak(string), + /* K1 */ be_nested_str_weak(Shutter), + /* K2 */ be_nested_str_weak(tasmota_shutter_index), + /* K3 */ be_const_int(1), + /* K4 */ be_nested_str_weak(contains), + /* K5 */ be_nested_str_weak(find), + /* K6 */ be_nested_str_weak(Tilt), + /* K7 */ be_nested_str_weak(shadow_shutter_tilt), + /* K8 */ be_nested_str_weak(attribute_updated), + /* K9 */ be_nested_str_weak(parse_sensors), + }), + be_str_weak(parse_sensors), + &be_const_str_solidified, + ( &(const binstruction[32]) { /* code */ + 0xA40A0000, // 0000 IMPORT R2 K0 + 0x600C0008, // 0001 GETGBL R3 G8 + 0x88100102, // 0002 GETMBR R4 R0 K2 + 0x00100903, // 0003 ADD R4 R4 K3 + 0x7C0C0200, // 0004 CALL R3 1 + 0x000E0203, // 0005 ADD R3 K1 R3 + 0x8C100304, // 0006 GETMET R4 R1 K4 + 0x5C180600, // 0007 MOVE R6 R3 + 0x7C100400, // 0008 CALL R4 2 + 0x7812000E, // 0009 JMPF R4 #0019 + 0x94100203, // 000A GETIDX R4 R1 R3 + 0x8C140905, // 000B GETMET R5 R4 K5 + 0x581C0006, // 000C LDCONST R7 K6 + 0x7C140400, // 000D CALL R5 2 + 0x4C180000, // 000E LDNIL R6 + 0x20180A06, // 000F NE R6 R5 R6 + 0x781A0007, // 0010 JMPF R6 #0019 + 0x88180107, // 0011 GETMBR R6 R0 K7 + 0x20180A06, // 0012 NE R6 R5 R6 + 0x781A0003, // 0013 JMPF R6 #0018 + 0x8C180108, // 0014 GETMET R6 R0 K8 + 0x54220101, // 0015 LDINT R8 258 + 0x5426000E, // 0016 LDINT R9 15 + 0x7C180600, // 0017 CALL R6 3 + 0x90020E05, // 0018 SETMBR R0 K7 R5 + 0x60100003, // 0019 GETGBL R4 G3 + 0x5C140000, // 001A MOVE R5 R0 + 0x7C100200, // 001B CALL R4 1 + 0x8C100909, // 001C GETMET R4 R4 K9 + 0x5C180200, // 001D MOVE R6 R1 + 0x7C100400, // 001E CALL R4 2 + 0x80000000, // 001F RET 0 }) ) ); @@ -185,15 +419,15 @@ be_local_closure(Matter_Plugin_ShutterTilt_read_attribute, /* name */ ********************************************************************/ extern const bclass be_class_Matter_Plugin_Shutter; be_local_class(Matter_Plugin_ShutterTilt, - 0, + 2, &be_class_Matter_Plugin_Shutter, - be_nested_map(5, + be_nested_map(9, ( (struct bmapnode*) &(const bmapnode[]) { - { be_const_key_weak(TYPE, 1), be_nested_str_weak(shutter_X2Btilt) }, + { be_const_key_weak(TYPE, -1), be_nested_str_weak(shutter_X2Btilt) }, + { be_const_key_weak(update_tilt_min_max, 0), be_const_closure(Matter_Plugin_ShutterTilt_update_tilt_min_max_closure) }, + { be_const_key_weak(parse_sensors, 7), be_const_closure(Matter_Plugin_ShutterTilt_parse_sensors_closure) }, { be_const_key_weak(NAME, -1), be_nested_str_weak(Shutter_X20_X2B_X20Tilt) }, - { be_const_key_weak(invoke_request, 3), be_const_closure(Matter_Plugin_ShutterTilt_invoke_request_closure) }, - { be_const_key_weak(read_attribute, -1), be_const_closure(Matter_Plugin_ShutterTilt_read_attribute_closure) }, - { be_const_key_weak(CLUSTERS, 0), be_const_simple_instance(be_nested_simple_instance(&be_class_map, { + { be_const_key_weak(CLUSTERS, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_map, { be_const_map( * be_nested_map(1, ( (struct bmapnode*) &(const bmapnode[]) { { be_const_key_int(258, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { @@ -205,6 +439,10 @@ be_local_class(Matter_Plugin_ShutterTilt, be_const_int(65532), })) ) } )) }, })) ) } )) }, + { be_const_key_weak(invoke_request, -1), be_const_closure(Matter_Plugin_ShutterTilt_invoke_request_closure) }, + { be_const_key_weak(tilt_min, 2), be_const_var(0) }, + { be_const_key_weak(read_attribute, -1), be_const_closure(Matter_Plugin_ShutterTilt_read_attribute_closure) }, + { be_const_key_weak(tilt_max, -1), be_const_var(1) }, })), be_str_weak(Matter_Plugin_ShutterTilt) );