Fix for Matter flow sensor (#19961)

* Update Matter_Plugin_4_Bridge_Sensor_Flow.be

MeasuredValue represents 10 x flow in m3/h

* Update Matter_Plugin_3_Sensor_Flow.be

MeasuredValue represents 10 x flow in m3/h

* Update Matter_Plugin_4_Bridge_Sensor_Flow.be

MinMeasuredValue comment
This commit is contained in:
Ludovic BOUÉ 2023-11-08 21:39:20 +01:00 committed by GitHub
parent 27fa6f34ea
commit 0303cca1db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 13 deletions

View File

@ -31,7 +31,7 @@ class Matter_Plugin_Sensor_Flow : Matter_Plugin_Sensor
static var CLUSTERS = matter.consolidate_clusters(_class, { static var CLUSTERS = matter.consolidate_clusters(_class, {
0x0404: [0,1,2,0xFFFC,0xFFFD], # Flow Measurement 0x0404: [0,1,2,0xFFFC,0xFFFD], # Flow Measurement
}) })
static var TYPES = { 0x0306: 2 } # Flow Sensor, rev 2 static var TYPES = { 0x0306: 1 } # Flow Sensor, rev 1
############################################################# #############################################################
# Pre-process value # Pre-process value
@ -39,7 +39,7 @@ class Matter_Plugin_Sensor_Flow : Matter_Plugin_Sensor
# This must be overriden. # This must be overriden.
# This allows to convert the raw sensor value to the target one, typically int # This allows to convert the raw sensor value to the target one, typically int
def pre_value(val) def pre_value(val)
return val != nil ? int(val) : nil return val != nil ? int(val * 10) : nil # MeasuredValue represents 10 x flow in m3/h
end end
############################################################# #############################################################
@ -63,14 +63,14 @@ class Matter_Plugin_Sensor_Flow : Matter_Plugin_Sensor
if cluster == 0x0404 # ========== Flow Measurement 2.4 p.98 ========== if cluster == 0x0404 # ========== Flow Measurement 2.4 p.98 ==========
if attribute == 0x0000 # ---------- MeasuredValue / i16 ---------- if attribute == 0x0000 # ---------- MeasuredValue / i16 ----------
if self.shadow_value != nil if self.shadow_value != nil
return tlv_solo.set(TLV.I2, int(self.shadow_value)) # MeasuredValue represents the flow in m3/h return tlv_solo.set(TLV.U2, int(self.shadow_value)) # MeasuredValue represents 10 x flow in m3/h.
else else
return tlv_solo.set(TLV.NULL, nil) return tlv_solo.set(TLV.NULL, nil)
end end
elif attribute == 0x0001 # ---------- MinMeasuredValue / i16 ---------- elif attribute == 0x0001 # ---------- MinMeasuredValue / i16 ----------
return tlv_solo.set(TLV.I2, 0) # 500 m3/h return tlv_solo.set(TLV.U2, 0) # 0 m3/h
elif attribute == 0x0002 # ---------- MaxMeasuredValue / i16 ---------- elif attribute == 0x0002 # ---------- MaxMeasuredValue / i16 ----------
return tlv_solo.set(TLV.I2, 65534) # 65534 m3/h return tlv_solo.set(TLV.U2, 65534) # 65534 m3/h
elif attribute == 0xFFFC # ---------- FeatureMap / map32 ---------- elif attribute == 0xFFFC # ---------- FeatureMap / map32 ----------
return tlv_solo.set(TLV.U4, 0) # 0 = no Extended Range return tlv_solo.set(TLV.U4, 0) # 0 = no Extended Range
elif attribute == 0xFFFD # ---------- ClusterRevision / u2 ---------- elif attribute == 0xFFFD # ---------- ClusterRevision / u2 ----------

View File

@ -30,7 +30,7 @@ class Matter_Plugin_Bridge_Sensor_Flow : Matter_Plugin_Bridge_Sensor
static var CLUSTERS = matter.consolidate_clusters(_class, { static var CLUSTERS = matter.consolidate_clusters(_class, {
0x0404: [0,1,2,0xFFFC,0xFFFD], # Flow Measurement 0x0404: [0,1,2,0xFFFC,0xFFFD], # Flow Measurement
}) })
static var TYPES = { 0x0306: 2 } # Flow Sensor, rev 2 static var TYPES = { 0x0306: 1 } # Flow Sensor, rev 1
############################################################# #############################################################
# Called when the value changed compared to shadow value # Called when the value changed compared to shadow value
@ -47,7 +47,7 @@ class Matter_Plugin_Bridge_Sensor_Flow : Matter_Plugin_Bridge_Sensor
# This must be overriden. # This must be overriden.
# This allows to convert the raw sensor value to the target one, typically int # This allows to convert the raw sensor value to the target one, typically int
def pre_value(val) def pre_value(val)
return val != nil ? int(val) : nil return val != nil ? int(val * 10) : nil # MeasuredValue represents 10 x flow in m3/h
end end
############################################################# #############################################################
@ -62,14 +62,14 @@ class Matter_Plugin_Bridge_Sensor_Flow : Matter_Plugin_Bridge_Sensor
if cluster == 0x0404 # ========== Flow Measurement 2.1.2 p.127 ========== if cluster == 0x0404 # ========== Flow Measurement 2.1.2 p.127 ==========
if attribute == 0x0000 # ---------- MeasuredValue / i16 ---------- if attribute == 0x0000 # ---------- MeasuredValue / i16 ----------
if self.shadow_value != nil if self.shadow_value != nil
return tlv_solo.set(TLV.I2, int(self.shadow_value)) # MeasuredValue represents the flow in m3/h return tlv_solo.set(TLV.U2, int(self.shadow_value)) # MeasuredValue represents 10 x flow in m3/h.
else else
return tlv_solo.set(TLV.NULL, nil) return tlv_solo.set(TLV.NULL, nil)
end end
elif attribute == 0x0001 # ---------- MinMeasuredValue / i16 ---------- elif attribute == 0x0001 # ---------- MinMeasuredValue / i16 ----------
return tlv_solo.set(TLV.I2, 0) # 500 m3/h return tlv_solo.set(TLV.U2, 0) # 0 m3/h
elif attribute == 0x0002 # ---------- MaxMeasuredValue / i16 ---------- elif attribute == 0x0002 # ---------- MaxMeasuredValue / i16 ----------
return tlv_solo.set(TLV.I2, 65534) # 65534 m3/h return tlv_solo.set(TLV.U2, 65534) # 65534 m3/h
elif attribute == 0xFFFC # ---------- FeatureMap / map32 ---------- elif attribute == 0xFFFC # ---------- FeatureMap / map32 ----------
return tlv_solo.set(TLV.U4, 0) # 0 = no Extended Range return tlv_solo.set(TLV.U4, 0) # 0 = no Extended Range
elif attribute == 0xFFFD # ---------- ClusterRevision / u2 ---------- elif attribute == 0xFFFD # ---------- ClusterRevision / u2 ----------