Add valet switch to Teslemetry (#144167)

* Add valet switch

* Add snapshot
This commit is contained in:
Brett Adams 2025-05-05 14:28:01 +10:00 committed by GitHub
parent e2a8137140
commit e3b3c32751
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 72 additions and 0 deletions

View File

@ -60,6 +60,16 @@ VEHICLE_DESCRIPTIONS: tuple[TeslemetrySwitchEntityDescription, ...] = (
off_func=lambda api: api.set_sentry_mode(on=False),
scopes=[Scope.VEHICLE_CMDS],
),
TeslemetrySwitchEntityDescription(
key="vehicle_state_valet_mode",
streaming_listener=lambda vehicle, value: vehicle.listen_ValetModeEnabled(
value
),
streaming_firmware="2024.44.25",
on_func=lambda api: api.set_valet_mode(on=True, password=""),
off_func=lambda api: api.set_valet_mode(on=False, password=""),
scopes=[Scope.VEHICLE_CMDS],
),
TeslemetrySwitchEntityDescription(
key="climate_state_auto_seat_climate_left",
streaming_listener=lambda vehicle, callback: vehicle.listen_AutoSeatClimateLeft(

View File

@ -383,6 +383,54 @@
'state': 'off',
})
# ---
# name: test_switch[switch.test_valet_mode-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.test_valet_mode',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
'original_icon': None,
'original_name': 'Valet mode',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'vehicle_state_valet_mode',
'unique_id': 'LRW3F7EK4NC700000-vehicle_state_valet_mode',
'unit_of_measurement': None,
})
# ---
# name: test_switch[switch.test_valet_mode-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'switch',
'friendly_name': 'Test Valet mode',
}),
'context': <ANY>,
'entity_id': 'switch.test_valet_mode',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_switch_alt[switch.energy_site_allow_charging_from_grid-statealt]
StateSnapshot({
'attributes': ReadOnlyDict({
@ -495,6 +543,20 @@
'state': 'off',
})
# ---
# name: test_switch_alt[switch.test_valet_mode-statealt]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'switch',
'friendly_name': 'Test Valet mode',
}),
'context': <ANY>,
'entity_id': 'switch.test_valet_mode',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_switch_streaming[switch.test_auto_seat_climate_left]
'on'
# ---