@@ -196,6 +196,30 @@ class EditAttributeListModel : public TouchesMatterStackModel
196
196
ESP_LOGI (TAG, " SystemMode changed to : %d" , n);
197
197
app::Clusters::Thermostat::Attributes::OccupiedHeatingSetpoint::Set (1 , n);
198
198
}
199
+ else if (name == " Current Lift" )
200
+ {
201
+ // update the current lift here for hardcoded endpoint 1
202
+ ESP_LOGI (TAG, " Current position lift percent 100ths changed to : %d" , n * 100 );
203
+ app::Clusters::WindowCovering::Attributes::CurrentPositionLiftPercent100ths::Set (1 , static_cast <uint16_t >(n * 100 ));
204
+ }
205
+ else if (name == " Current Tilt" )
206
+ {
207
+ // update the current tilt here for hardcoded endpoint 1
208
+ ESP_LOGI (TAG, " Current position tilt percent 100ths changed to : %d" , n * 100 );
209
+ app::Clusters::WindowCovering::Attributes::CurrentPositionTiltPercent100ths::Set (1 , static_cast <uint16_t >(n * 100 ));
210
+ }
211
+ else if (name == " Opr Status" )
212
+ {
213
+ // update the operational status here for hardcoded endpoint 1
214
+ ESP_LOGI (TAG, " Operational status changed to : %d" , n);
215
+ app::Clusters::WindowCovering::Attributes::OperationalStatus::Set (1 , static_cast <uint8_t >(n));
216
+ }
217
+ else if (name == " Bat remaining" )
218
+ {
219
+ // update the battery percent remaining here for hardcoded endpoint 1
220
+ ESP_LOGI (TAG, " Battery percent remaining changed to : %d" , n);
221
+ app::Clusters::PowerSource::Attributes::BatteryPercentRemaining::Set (1 , static_cast <uint8_t >(n * 2 ));
222
+ }
199
223
value = buffer;
200
224
}
201
225
else if (IsBooleanAttribute ())
@@ -223,18 +247,47 @@ class EditAttributeListModel : public TouchesMatterStackModel
223
247
else
224
248
{
225
249
auto & name = std::get<0 >(attribute);
226
- auto & cluster = std::get<0 >(std::get<1 >(std::get<1 >(devices[deviceIndex])[endpointIndex])[i ]);
250
+ auto & cluster = std::get<0 >(std::get<1 >(std::get<1 >(devices[deviceIndex])[endpointIndex])[0 ]);
227
251
228
252
ESP_LOGI (TAG, " editing attribute as string: '%s' (%s)" , value.c_str (), i == 0 ? " +" : " -" );
229
- value = (value == " Closed" ) ? " Open" : " Closed" ;
230
253
ESP_LOGI (TAG, " name and cluster: '%s' (%s)" , name.c_str (), cluster.c_str ());
231
254
if (name == " State" && cluster == " Lock" )
232
255
{
256
+ value = (value == " Closed" ) ? " Open" : " Closed" ;
233
257
using namespace chip ::app::Clusters;
234
258
// update the doorlock attribute here
235
259
auto attributeValue = value == " Closed" ? DoorLock::DlLockState::kLocked : DoorLock::DlLockState::kUnlocked ;
236
260
DoorLock::Attributes::LockState::Set (DOOR_LOCK_SERVER_ENDPOINT, attributeValue);
237
261
}
262
+ else if (name == " Charge level" && cluster == " Power Source" )
263
+ {
264
+ using namespace chip ::app::Clusters::PowerSource;
265
+ auto attributeValue = BatChargeLevel::kOk ;
266
+
267
+ if (value == " OK" )
268
+ {
269
+ value = " Warning" ;
270
+ attributeValue = BatChargeLevel::kWarning ;
271
+ }
272
+ else if (value == " Warning" )
273
+ {
274
+ value = " Critical" ;
275
+ attributeValue = BatChargeLevel::kCritical ;
276
+ }
277
+ else
278
+ {
279
+ value = " OK" ;
280
+ attributeValue = BatChargeLevel::kOk ;
281
+ }
282
+
283
+ // update the battery charge level here for hardcoded endpoint 1
284
+ ESP_LOGI (TAG, " Battery charge level changed to : %u" , static_cast <uint8_t >(attributeValue));
285
+ app::Clusters::PowerSource::Attributes::BatteryChargeLevel::Set (1 , static_cast <uint8_t >(attributeValue));
286
+ }
287
+ else
288
+ {
289
+ value = (value == " Closed" ) ? " Open" : " Closed" ;
290
+ }
238
291
}
239
292
}
240
293
};
@@ -520,6 +573,24 @@ void SetupPretendDevices()
520
573
app::Clusters::ColorControl::Attributes::CurrentHue::Set (1 , 200 );
521
574
AddAttribute (" Current Saturation\n " , " 150" );
522
575
app::Clusters::ColorControl::Attributes::CurrentSaturation::Set (1 , 150 );
576
+
577
+ AddDevice (" Window Covering" );
578
+ AddEndpoint (" 1" );
579
+ AddCluster (" Window Covering" );
580
+ AddAttribute (" Current Lift" , " 5" );
581
+ app::Clusters::WindowCovering::Attributes::CurrentPositionLiftPercent100ths::Set (1 , static_cast <uint16_t >(5 * 100 ));
582
+ AddAttribute (" Current Tilt" , " 5" );
583
+ app::Clusters::WindowCovering::Attributes::CurrentPositionTiltPercent100ths::Set (1 , static_cast <uint16_t >(5 * 100 ));
584
+ AddAttribute (" Opr Status" , " 0" );
585
+ app::Clusters::WindowCovering::Attributes::OperationalStatus::Set (1 , static_cast <uint8_t >(0 ));
586
+
587
+ AddDevice (" Battery" );
588
+ AddEndpoint (" 1" );
589
+ AddCluster (" Power Source" );
590
+ AddAttribute (" Bat remaining" , " 70" );
591
+ app::Clusters::PowerSource::Attributes::BatteryPercentRemaining::Set (1 , static_cast <uint8_t >(70 * 2 ));
592
+ AddAttribute (" Charge level" , " 0" );
593
+ app::Clusters::PowerSource::Attributes::BatteryChargeLevel::Set (1 , static_cast <uint8_t >(0 ));
523
594
}
524
595
525
596
esp_err_t InitM5Stack (std::string qrCodeText)
0 commit comments