|
28 | 28 | HvacAutoModeState, |
29 | 29 | HvacPowerState, |
30 | 30 | HvilStatus, |
| 31 | + Key, |
31 | 32 | LaneAssistLevel, |
32 | 33 | MediaStatus, |
33 | 34 | PowershareState, |
|
38 | 39 | SentryModeState, |
39 | 40 | ShiftState, |
40 | 41 | Signal, |
| 42 | + State, |
| 43 | + Status, |
| 44 | + NetworkInterface, |
41 | 45 | SunroofInstalledState, |
42 | 46 | TemperatureUnit, |
43 | 47 | TeslaLocation, |
@@ -162,6 +166,49 @@ def _enable_field(self, field: Signal) -> None: |
162 | 166 | """Enable a field for streaming from a listener.""" |
163 | 167 | asyncio.create_task(self.add_field(field)) |
164 | 168 |
|
| 169 | + # Add listeners for other streaming fields |
| 170 | + def listen_State(self, callback: Callable[[bool], None]) -> Callable[[],None]: |
| 171 | + """Listen for State polling.""" |
| 172 | + return self.stream.async_add_listener( |
| 173 | + lambda x: callback(x[Key.STATE] == State.ONLINE), |
| 174 | + {Key.VIN: self.vin, Key.STATE: None} |
| 175 | + ) |
| 176 | + |
| 177 | + def listen_VehicleData(self, callback: Callable[[dict], None]) -> Callable[[],None]: |
| 178 | + """Listen for Vehicle Data polling.""" |
| 179 | + return self.stream.async_add_listener( |
| 180 | + lambda x: callback(x[Key.VEHICLE_DATA]), |
| 181 | + {Key.VIN: self.vin, Key.VEHICLE_DATA: None} |
| 182 | + ) |
| 183 | + |
| 184 | + def listen_Cellular(self, callback: Callable[[bool], None]) -> Callable[[],None]: |
| 185 | + """Listen for Cellular connectivity.""" |
| 186 | + return self.stream.async_add_listener( |
| 187 | + lambda x: callback(x[Key.STATUS] == Status.CONNECTED), |
| 188 | + {Key.VIN: self.vin, Key.NETWORK_INTERFACE: NetworkInterface.CELLULAR} |
| 189 | + ) |
| 190 | + |
| 191 | + def listen_Wifi(self, callback: Callable[[bool], None]) -> Callable[[],None]: |
| 192 | + """Listen for WiFi connectivity.""" |
| 193 | + return self.stream.async_add_listener( |
| 194 | + lambda x: callback(x[Key.STATUS] == Status.CONNECTED), |
| 195 | + {Key.VIN: self.vin, Key.NETWORK_INTERFACE: NetworkInterface.WIFI} |
| 196 | + ) |
| 197 | + |
| 198 | + def listen_Alerts(self, callback: Callable[[list[dict]], None]) -> Callable[[],None]: |
| 199 | + """Listen for Alerts.""" |
| 200 | + return self.stream.async_add_listener( |
| 201 | + lambda x: callback(x[Key.ALERTS]), |
| 202 | + {Key.VIN: self.vin, Key.ALERTS: None} |
| 203 | + ) |
| 204 | + |
| 205 | + def listen_Errors(self, callback: Callable[[list[dict]], None]) -> Callable[[],None]: |
| 206 | + """Listen for Errors.""" |
| 207 | + return self.stream.async_add_listener( |
| 208 | + lambda x: callback(x[Key.ERRORS]), |
| 209 | + {Key.VIN: self.vin, Key.ERRORS: None} |
| 210 | + ) |
| 211 | + |
165 | 212 | # Add listeners for each signal |
166 | 213 | def listen_ACChargingEnergyIn(self, callback: Callable[[float | None], None]) -> Callable[[],None]: |
167 | 214 | """Listen for AC Charging Energy In.""" |
|
0 commit comments