@@ -93,6 +93,43 @@ describe("Shelly 2PM Gen4 cover mode", () => {
9393 ) ;
9494 } ) ;
9595
96+ it ( "persists Shelly slat control from Cover.GetConfig params during configure" , async ( ) => {
97+ const response = JSON . stringify ( { id : 1 , params : { id : 0 , slat : { enable : true } } } ) ;
98+ const read = vi
99+ . fn ( )
100+ . mockResolvedValueOnce ( { rxCtl : 0 } )
101+ . mockResolvedValueOnce ( { rxCtl : 0 } )
102+ . mockResolvedValueOnce ( { rxCtl : response . length } )
103+ . mockResolvedValueOnce ( { data : response } ) ;
104+ const device = mockShelly2PMCoverWithInputs ( read ) ;
105+ const save = vi . spyOn ( device , "save" ) . mockImplementation ( ( ) => { } ) ;
106+ const definition = await findByDevice ( device ) ;
107+
108+ await definition . configure ?.( device , mockShelly2PMCover ( ) . getEndpoint ( 1 ) , definition ) ;
109+
110+ expect ( device . meta . cover_tilt_enabled ) . toBe ( true ) ;
111+ expect ( save ) . toHaveBeenCalledTimes ( 1 ) ;
112+ } ) ;
113+
114+ it ( "overwrites stale persisted slat control from Cover.GetConfig during configure" , async ( ) => {
115+ const response = JSON . stringify ( { id : 1 , result : { id : 0 , slat : { enable : false } } } ) ;
116+ const read = vi
117+ . fn ( )
118+ . mockResolvedValueOnce ( { rxCtl : 0 } )
119+ . mockResolvedValueOnce ( { rxCtl : 0 } )
120+ . mockResolvedValueOnce ( { rxCtl : response . length } )
121+ . mockResolvedValueOnce ( { data : response } ) ;
122+ const device = mockShelly2PMCoverWithInputs ( read ) ;
123+ device . meta . cover_tilt_enabled = true ;
124+ const save = vi . spyOn ( device , "save" ) . mockImplementation ( ( ) => { } ) ;
125+ const definition = await findByDevice ( device ) ;
126+
127+ await definition . configure ?.( device , mockShelly2PMCover ( ) . getEndpoint ( 1 ) , definition ) ;
128+
129+ expect ( device . meta . cover_tilt_enabled ) . toBe ( false ) ;
130+ expect ( save ) . toHaveBeenCalledTimes ( 1 ) ;
131+ } ) ;
132+
96133 it ( "leaves persisted slat control unchanged when Cover.GetConfig has no boolean slat flag" , async ( ) => {
97134 const response = JSON . stringify ( { id : 1 , result : { id : 0 } } ) ;
98135 const read = vi
0 commit comments