Skip to content

Commit 7b223be

Browse files
authored
Fix matter lights (#24126)
* matter: add FeatureMap to Light 1 * matter: add missing attributes to Light 2 * matter: fix datatype of attributes on Light 3
1 parent 4614ab3 commit 7b223be

File tree

6 files changed

+313
-274
lines changed

6 files changed

+313
-274
lines changed

lib/libesp32/berry_matter/src/embedded/Matter_Plugin_0.be

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class Matter_Plugin
4747
# static var TYPES = { <device_type>: <revision> } # needs to be defined for each endpoint
4848
# `FEATURE_MAPS` contains any non-zero value per cluster, if not present default to `0`
4949
static var FEATURE_MAPS = { # feature map per cluster
50+
0x0008: 0x03, # Level Control: On/Off + Lighting
5051
0x0031: 0x04, # Put Eth for now which should work for any on-network
5152
# 0x0046: 0x04, # LITS: LongIdleTimeSupport
5253
0x0102: 1 + 4, # Lift + PA_LF

lib/libesp32/berry_matter/src/embedded/Matter_Plugin_4_Light2.be

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Matter_Plugin_Light2 : Matter_Plugin_Light1
3535
# 0x0005: inherited # Scenes 1.4 p.30 - no writable
3636
# 0x0006: inherited # On/Off 1.5 p.48
3737
# 0x0008: inherited # Level Control 1.6 p.57
38-
0x0300: [7,8,0xF,0x400B,0x400C], # Color Control 3.2 p.111
38+
0x0300: [7,8,0xF,0x10,0x4001,0x400A,0x400B,0x400C], # Color Control 3.2 p.111
3939
})
4040
static var UPDATE_COMMANDS = matter.UC_LIST(_class, "CT")
4141
static var TYPES = { 0x010C: 2 } # Color Temperature Light
@@ -135,16 +135,24 @@ class Matter_Plugin_Light2 : Matter_Plugin_Light1
135135
if cluster == 0x0300 # ========== Color Control 3.2 p.111 ==========
136136
self.update_shadow_lazy()
137137
if attribute == 0x0007 # ---------- ColorTemperatureMireds / u2 ----------
138-
return tlv_solo.set_or_nil(TLV.U1, self.shadow_ct) # if `nil` it is replaced with TLV.NULL
138+
return tlv_solo.set_or_nil(TLV.U2, self.shadow_ct) # if `nil` it is replaced with TLV.NULL
139139
elif attribute == 0x0008 # ---------- ColorMode / u1 ----------
140-
return tlv_solo.set(TLV.U1, 2)# 2 = ColorTemperatureMireds
140+
return tlv_solo.set(TLV.U1, 2) # 2 = ColorTemperatureMireds
141141
elif attribute == 0x000F # ---------- Options / u1 ----------
142142
return tlv_solo.set(TLV.U1, 0)
143+
elif attribute == 0x4001 # ---------- EnhancedColorMode / u1 ----------
144+
return tlv_solo.set(TLV.U1, 2) # 2 = ColorTemperatureMireds
145+
elif attribute == 0x400A # ---------- ColorCapabilities / map2 ----------
146+
return tlv_solo.set(TLV.U2, 0x10) # CT
143147
elif attribute == 0x400B # ---------- ColorTempPhysicalMinMireds / u2 ----------
144-
return tlv_solo.set(TLV.U1, self.ct_min)
148+
return tlv_solo.set(TLV.U2, self.ct_min)
145149
elif attribute == 0x400C # ---------- ColorTempPhysicalMaxMireds / u2 ----------
146-
return tlv_solo.set(TLV.U1, self.ct_max)
150+
return tlv_solo.set(TLV.U2, self.ct_max)
147151

152+
# Defined Primaries Information Attribute Set
153+
elif attribute == 0x0010 # ---------- NumberOfPrimaries / u1 ----------
154+
return tlv_solo.set(TLV.U1, 0)
155+
148156
elif attribute == 0xFFFC # ---------- FeatureMap / map32 ----------
149157
return tlv_solo.set(TLV.U4, 0x10) # CT
150158
end

lib/libesp32/berry_matter/src/embedded/Matter_Plugin_4_Light3.be

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,15 @@ class Matter_Plugin_Light3 : Matter_Plugin_Light1
150150
elif attribute == 0x0001 # ---------- CurrentSaturation / u2 ----------
151151
return tlv_solo.set_or_nil(TLV.U1, self.shadow_sat)
152152
elif attribute == 0x0007 # ---------- ColorTemperatureMireds / u2 ----------
153-
return tlv_solo.set(TLV.U1, 0)
153+
return tlv_solo.set(TLV.U2, 0)
154154
elif attribute == 0x0008 # ---------- ColorMode / u1 ----------
155155
return tlv_solo.set(TLV.U1, 0)# 0 = CurrentHue and CurrentSaturation
156156
elif attribute == 0x000F # ---------- Options / u1 ----------
157157
return tlv_solo.set(TLV.U1, 0)
158158
elif attribute == 0x4001 # ---------- EnhancedColorMode / u1 ----------
159159
return tlv_solo.set(TLV.U1, 0)
160160
elif attribute == 0x400A # ---------- ColorCapabilities / map2 ----------
161-
return tlv_solo.set(TLV.U1, 0x01) # HS
161+
return tlv_solo.set(TLV.U2, 0x01) # HS
162162

163163
# Defined Primaries Information Attribute Set
164164
elif attribute == 0x0010 # ---------- NumberOfPrimaries / u1 ----------

lib/libesp32/berry_matter/src/solidify/solidified_Matter_Plugin_0.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,10 +1430,11 @@ be_local_class(Matter_Plugin,
14301430
{ be_const_key_weak(endpoint, 6), be_const_var(2) },
14311431
{ be_const_key_weak(get_endpoint, -1), be_const_closure(class_Matter_Plugin_get_endpoint_closure) },
14321432
{ be_const_key_weak(FEATURE_MAPS, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_map, {
1433-
be_const_map( * be_nested_map(3,
1433+
be_const_map( * be_nested_map(4,
14341434
( (struct bmapnode*) &(const bmapnode[]) {
1435-
{ be_const_key_int(258, -1), be_const_int(5) },
1436-
{ be_const_key_int(49, 2), be_const_int(4) },
1435+
{ be_const_key_int(8, -1), be_const_int(3) },
1436+
{ be_const_key_int(49, -1), be_const_int(4) },
1437+
{ be_const_key_int(258, 3), be_const_int(5) },
14371438
{ be_const_key_int(514, -1), be_const_int(2) },
14381439
})) ) } )) },
14391440
{ be_const_key_weak(ARG, -1), be_nested_str_weak() },

0 commit comments

Comments
 (0)