Skip to content

Commit

Permalink
Lots of enums, icons, and strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Bre77 committed Dec 17, 2024
1 parent 23b3575 commit e0412c1
Show file tree
Hide file tree
Showing 6 changed files with 362 additions and 116 deletions.
17 changes: 11 additions & 6 deletions custom_components/teslemetry/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class TeslemetryBinarySensorEntityDescription(BinarySensorEntityDescription):
key="state",
polling=True,
polling_value_fn=lambda x: x == TeslemetryState.ONLINE,
device_class=BinarySensorDeviceClass.CONNECTIVITY,
),
TeslemetryBinarySensorEntityDescription(
key="charge_state_battery_heater_on",
Expand Down Expand Up @@ -228,11 +229,6 @@ class TeslemetryBinarySensorEntityDescription(BinarySensorEntityDescription):
streaming_key=Signal.BRAKE_PEDAL,
entity_registry_enabled_default=False,
),
TeslemetryBinarySensorEntityDescription(
key="charge_enable_request",
streaming_key=Signal.CHARGE_ENABLE_REQUEST,
entity_registry_enabled_default=False,
),
TeslemetryBinarySensorEntityDescription(
key="charge_port_cold_weather_mode",
streaming_key=Signal.CHARGE_PORT_COLD_WEATHER_MODE,
Expand All @@ -243,7 +239,6 @@ class TeslemetryBinarySensorEntityDescription(BinarySensorEntityDescription):
streaming_key=Signal.SERVICE_MODE,
entity_registry_enabled_default=False,
),
# NEEDS TRANSLATION
TeslemetryBinarySensorEntityDescription(
key="pin_to_drive_enabled",
streaming_key=Signal.PIN_TO_DRIVE_ENABLED,
Expand Down Expand Up @@ -292,6 +287,16 @@ class TeslemetryBinarySensorEntityDescription(BinarySensorEntityDescription):
streaming_key=Signal.DC_DC_ENABLE,
entity_registry_enabled_default=False,
),
TeslemetryBinarySensorEntityDescription(
key="emergency_lane_departure_avoidance",
streaming_key=Signal.EMERGENCY_LANE_DEPARTURE_AVOIDANCE,
entity_registry_enabled_default=False,
),
TeslemetryBinarySensorEntityDescription(
key="supercharger_session_trip_planner",
streaming_key=Signal.SUPERCHARGER_SESSION_TRIP_PLANNER,
entity_registry_enabled_default=False,
),
)

ENERGY_LIVE_DESCRIPTIONS: tuple[BinarySensorEntityDescription, ...] = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ class TeslemetryEnum:

def __init__(self, prefix: str, options: list[str]):
"""Create a new options list."""
self.prefix = prefix
self.options = options
self.prefix = prefix.lower()
self.options = [option.lower() for option in options]

def get(self, value, default:str|None=None) -> str | None:
def get(self, value, default: str | None = None) -> str | None:
"""Get the value if it is a valid option."""
if isinstance(value, str):
option = value.replace(self.prefix, "").lower()
option = value.lower().replace(self.prefix, "")
if option in self.options:
return option
return default
Expand Down Expand Up @@ -129,6 +129,51 @@ def get(self, value, default:str|None=None) -> str | None:
"exhaustingpressureintermediate",
"exhausted"
])
#HvacAutoModeState is climate
#CabinOverheatProtectionModeState and CabinOverheatProtectionModeState is climate
#DefrostModeState is a switch
#ClimateKeeperModeState is climate
#HvacPowerState is climate
FastCharger = TeslemetryEnum("FastCharger", [
"supercharger",
"chademo",
"gb",
"acsinglewirecan",
"combo",
"mcsinglewirecan",
"other",
"sna"
])
CableType = TeslemetryEnum("CableType", [
"iec",
"sae",
"gb_ac",
"gb_dc",
"sna"
])
#TonneauTentModeState and TonneauPositionState are covers
PowershareState = TeslemetryEnum("PowershareState", [
"inactive",
"handshaking",
"init",
"enabled",
"enabledreconnectingsoon",
"stopped"
])
PowershareStopReasonStatus = TeslemetryEnum("PowershareStopReasonStatus", [
"none",
"soctoolow",
"retry",
"fault",
"user",
"reconnecting",
"authentication"
])
PowershareTypeStatus = TeslemetryEnum("PowershareTypeStatus", [
"none",
"load",
"home"
])
DisplayState = TeslemetryEnum("DisplayState", [
"off",
"dim",
Expand All @@ -141,5 +186,3 @@ def get(self, value, default:str|None=None) -> str | None:
"dog",
"entertainment"
])
#HvacAutoModeState is climate
#CabinOverheatProtectionModeState and CabinOverheatProtectionModeState is climate
170 changes: 134 additions & 36 deletions custom_components/teslemetry/icons.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,88 @@
}
},
"charge_state_conn_charge_cable": {
"default": "mdi:ev-plug-tesla"
},
"charge_state_scheduled_charging_mode": {
"default": "mdi:battery-clock"
},
"emergency_lane_departure_avoidance": {
"default": "mdi:road-variant"
},
"dc_dc_enable": {
"default": "mdi:flash-triangle"
},
"guest_mode_enabled": {
"default": "mdi:account-clock"
},
"gps_state": {
"default": "mdi:crosshairs-gps"
},
"fast_charger_present": {
"default": "mdi:ev-plug-tesla"
},
"passenger_seat_belt": {
"default": "mdi:seatbelt"
},
"driver_seat_occupied": {
"default": "mdi:car-seat"
},
"driver_seat_belt": {
"default": "mdi:seatbelt"
},
"drive_rail": {
"default": "mdi:flash-triangle"
},
"pin_to_drive_enabled": {
"default": "mdi:car-key"
},
"service_mode": {
"default": "mdi:car-settings"
},
"charge_port_cold_weather_mode": {
"default": "mdi:snowflake"
},
"brake_pedal": {
"default": "mdi:car-brake-low-pressure"
},
"charge_state_charger_phases": {
"state": {
"default": "mdi:ev-plug-tesla"
"off": "mdi:numeric-1-box",
"on": "mdi:plus-box"
}
},
"charge_state_scheduled_charging_mode": {
"charge_state_scheduled_charging_pending": {
"state": {
"default": "mdi:battery-clock"
"off": "mdi:timeline-clock-outline",
"on": "mdi:timeline-clock"
}
},
"automatic_blind_spot_camera": {
"default": "mdi:camera-rear"
},
"automatic_emergency_braking_off": {
"default": "mdi:car-brake-alert"
},
"blind_spot_collision_warning_chime": {
"default": "mdi:car-sensor"
},
"bms_full_charge_complete": {
"default": "mdi:battery-check"
},
"supercharger_session_trip_planner": {
"default": "mdi:map-marker-path"
},
"backup_capable": {
"default": "mdi:backup-restore"
},
"grid_services_active": {
"default": "mdi:transmission-tower"
},
"components_grid_services_enabled": {
"default": "mdi:transmission-tower"
},
"charge_state_trip_charging": {
"default": "mdi:timeline-clock"
}
},
"button": {
Expand Down Expand Up @@ -342,7 +416,7 @@
"default": "mdi:battery-sync"
},
"brake_pedal_position": {
"default": "mdi:car-brake-alert"
"default": "mdi:car-brake-low-pressure"
},
"brick_voltage_max": {
"default": "mdi:battery-arrow-up"
Expand All @@ -368,9 +442,6 @@
"dc_charging_power": {
"default": "mdi:flash"
},
"dc_dc_enable": {
"default": "mdi:flash-triangle"
},
"di_axle_speed_front": {
"default": "mdi:speedometer"
},
Expand Down Expand Up @@ -443,30 +514,12 @@
"di_voltage_battery_rear_right": {
"default": "mdi:battery-check"
},
"drive_rail": {
"default": "mdi:flash-triangle"
},
"driver_seat_belt": {
"default": "mdi:seatbelt"
},
"driver_seat_occupied": {
"default": "mdi:car-seat"
},
"energy_remaining": {
"default": "mdi:lightning-bolt"
},
"fast_charger_present": {
"default": "mdi:ev-plug-tesla"
},
"forward_collision_warning": {
"default": "mdi:car-multiple"
},
"gps_state": {
"default": "mdi:crosshairs-gps"
},
"guest_mode_enabled": {
"default": "mdi:account-clock"
},
"guest_mode_mobile_access_state": {
"default": "mdi:account-clock"
},
Expand All @@ -476,9 +529,6 @@
"isolation_resistance": {
"default": "mdi:resistor"
},
"emergency_lane_departure_avoidance": {
"default": "mdi:road-variant"
},
"lane_departure_avoidance": {
"default": "mdi:road-variant"
},
Expand Down Expand Up @@ -518,12 +568,6 @@
"paired_key_quantity": {
"default": "mdi:cellphone-key"
},
"passenger_seat_belt": {
"default": "mdi:seatbelt"
},
"pin_to_drive_enabled": {
"default": "mdi:car-key"
},
"rated_range": {
"default": "mdi:arrow-left-right"
},
Expand All @@ -533,7 +577,7 @@
"speed_limit_warning": {
"default": "mdi:car-speed-limiter"
},
"vehicle_config_exterior_color": {
"vehicle_config_exterior_color": {
"default": "mdi:palette"
},
"charge_state_conn_charge_cable": {
Expand All @@ -547,6 +591,60 @@
},
"drive_state_active_route_traffic_minutes_delay": {
"default": "mdi:traffic-light"
},
"vehicle_config_roof_color": {
"default": "mdi:palette"
},
"di_salve_torque_command": {
"default": "mdi:car-turbocharger"
},
"di_torque_actual_front": {
"default": "mdi:car-turbocharger"
},
"di_torque_actual_rear": {
"default": "mdi:car-turbocharger"
},
"di_torque_actual_rear_left": {
"default": "mdi:car-turbocharger"
},
"di_torque_actual_rear_right": {
"default": "mdi:car-turbocharger"
},
"di_torque_motor": {
"default": "mdi:car-turbocharger"
},
"gps_heading": {
"default": "mdi:compass"
},
"pedal_position": {
"default": "mdi:car-brake-hold"
},
"trim": {
"default": "mdi:car-info"
},
"vehicle_name": {
"default": "mdi:car"
},
"efficiency_package": {
"default": "mdi:leaf"
},
"homelink_device_count": {
"default": "mdi:garage"
},
"powershare_type": {
"default": "mdi:transmission-tower"
},
"tpms_hard_warnings": {
"default": "mdi:alert-circle"
},
"tpms_soft_warnings": {
"default": "mdi:alert-circle-outline"
},
"wheel_type": {
"default": "mdi:car-tire-alert"
},
"grid_status": {
"default": "mdi:power-plug"
}
},
"switch": {
Expand Down Expand Up @@ -593,4 +691,4 @@
"valet_mode": "mdi:speedometer-slow",
"time_of_use": "mdi:clock-time-eight-outline"
}
}
}
Loading

0 comments on commit e0412c1

Please sign in to comment.