@@ -80,6 +80,16 @@ async def get_basic_info(self) -> dict[str, Any] | None:
8080 return None
8181
8282 _tilt = max (min (_data [6 ], 100 ), 0 )
83+ _moving = bool (_data [5 ] & 0b00000011 )
84+ if _moving :
85+ _opening = bool (_data [5 ] & 0b00000010 )
86+ _closing = not _opening and bool (_data [5 ] & 0b00000001 )
87+ if _opening :
88+ _flag = bool (_data [5 ] & 0b00000001 )
89+ _up = _flag if self ._reverse else not _flag
90+ else :
91+ _up = _tilt < 50 if self ._reverse else _tilt > 50
92+
8393 return {
8494 "battery" : _data [1 ],
8595 "firmware" : _data [2 ] / 10.0 ,
@@ -88,10 +98,12 @@ async def get_basic_info(self) -> dict[str, Any] | None:
8898 "solarPanel" : bool (_data [5 ] & 0b00001000 ),
8999 "calibration" : bool (_data [5 ] & 0b00000100 ),
90100 "calibrated" : bool (_data [5 ] & 0b00000100 ),
91- "inMotion" : bool ( _data [ 5 ] & 0b00000011 ) ,
101+ "inMotion" : _moving ,
92102 "motionDirection" : {
93- "up" : bool (_data [5 ] & (0b00000010 if self ._reverse else 0b00000001 )),
94- "down" : bool (_data [5 ] & (0b00000001 if self ._reverse else 0b00000010 )),
103+ "opening" : _moving and _opening ,
104+ "closing" : _moving and _closing ,
105+ "up" : _moving and _up ,
106+ "down" : _moving and not _up ,
95107 },
96108 "tilt" : (100 - _tilt ) if self ._reverse else _tilt ,
97109 "timers" : _data [7 ],
0 commit comments