Add sentry mode sensor to Teslemetry (#143855)

* Add sentry mode sensor

* Fix state handler
This commit is contained in:
Brett Adams 2025-04-29 16:37:10 +10:00 committed by GitHub
parent d8d6decb38
commit 835cdad0a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 39 additions and 0 deletions

View File

@ -372,6 +372,17 @@
},
"consumer_energy_imported_from_generator": {
"default": "mdi:generator-stationary"
},
"sentry_mode": {
"default": "mdi:shield-car",
"state": {
"off": "mdi:shield-off-outline",
"idle": "mdi:shield-outline",
"armed": "mdi:shield-check",
"aware": "mdi:shield-alert",
"panic": "mdi:shield-alert-outline",
"quiet": "mdi:shield-half-full"
}
}
},
"switch": {

View File

@ -60,6 +60,15 @@ CHARGE_STATES = {
SHIFT_STATES = {"P": "p", "D": "d", "R": "r", "N": "n"}
SENTRY_MODE_STATES = {
"Off": "off",
"Idle": "idle",
"Armed": "armed",
"Aware": "aware",
"Panic": "panic",
"Quiet": "quiet",
}
@dataclass(frozen=True, kw_only=True)
class TeslemetryVehicleSensorEntityDescription(SensorEntityDescription):
@ -350,6 +359,14 @@ VEHICLE_DESCRIPTIONS: tuple[TeslemetryVehicleSensorEntityDescription, ...] = (
native_unit_of_measurement=UnitOfLength.MILES,
device_class=SensorDeviceClass.DISTANCE,
),
TeslemetryVehicleSensorEntityDescription(
key="sentry_mode",
streaming_listener=lambda x, y: x.listen_SentryMode(
lambda z: None if z is None else y(SENTRY_MODE_STATES.get(z))
),
options=list(SENTRY_MODE_STATES.values()),
device_class=SensorDeviceClass.ENUM,
),
)

View File

@ -644,6 +644,17 @@
},
"total_grid_energy_exported": {
"name": "Grid exported"
},
"sentry_mode": {
"name": "Sentry mode",
"state": {
"off": "Off",
"idle": "Idle",
"armed": "Armed",
"aware": "Aware",
"panic": "Panic",
"quiet": "Quiet"
}
}
},
"switch": {