@@ -23,6 +23,7 @@ MatterOnOffLight OnOffLight;
23
23
24
24
// it will keep last OnOff state stored, using Preferences
25
25
Preferences lastStatePref;
26
+ #define ON_OFF_PREF_KEY " lastOnOffState"
26
27
27
28
// set your board LED pin here
28
29
#ifdef LED_BUILTIN
@@ -48,7 +49,7 @@ bool setLightOnOff(bool state) {
48
49
digitalWrite (ledPin, LOW);
49
50
}
50
51
// store last OnOff state for when the Light is restarted / power goes off
51
- lastStatePref.putBool (" lastOnOffState " , state);
52
+ lastStatePref.putBool (ON_OFF_PREF_KEY , state);
52
53
// This callback must return the success state to Matter core
53
54
return true ;
54
55
}
@@ -83,8 +84,8 @@ void setup() {
83
84
84
85
// Initialize Matter EndPoint
85
86
lastStatePref.begin (" matterLight" , false );
86
- bool lastOnOffState = lastStatePref.getBool (" lastOnOffState " , true );
87
- OnOffLight.begin (lastOnOffState);
87
+ bool lastOnOffState = lastStatePref.getBool (ON_OFF_PREF_KEY , true );
88
+ OnOffLight.begin (lastOnOffState);
88
89
OnOffLight.onChange (setLightOnOff);
89
90
90
91
// Matter beginning - Last step, after all EndPoints are initialized
0 commit comments