Skip to content

Commit a82587d

Browse files
committed
Fixes and new sensors
1 parent 8c78958 commit a82587d

File tree

9 files changed

+82
-9
lines changed

9 files changed

+82
-9
lines changed

custom_components/teslemetry/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
214214

215215
# Update firwmare
216216
for vehicle in vehicles:
217-
vehicle.firmware = vehicle.coordinator.data.get("vehicle_state_car_version", vehicle.firmware)
217+
vehicle.firmware = vehicle.coordinator.data.get("vehicle_state_car_version", vehicle.firmware).split(" ")[0]
218218

219219
# Setup Platforms
220220
entry.runtime_data = TeslemetryData(

custom_components/teslemetry/binary_sensor.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,48 @@ class TeslemetryBinarySensorEntityDescription(BinarySensorEntityDescription):
392392
streaming_firmware = "2024.44.32",
393393
entity_registry_enabled_default=False,
394394
),
395+
TeslemetryBinarySensorEntityDescription(
396+
key="lights_hazards_active",
397+
streaming_key=Signal.LIGHTS_HAZARDS_ACTIVE,
398+
entity_registry_enabled_default=False,
399+
entity_category=EntityCategory.DIAGNOSTIC,
400+
streaming_firmware = "2025.2.6",
401+
),
402+
TeslemetryBinarySensorEntityDescription(
403+
key="lights_turn_signal",
404+
streaming_key=Signal.LIGHTS_TURN_SIGNAL,
405+
entity_registry_enabled_default=False,
406+
entity_category=EntityCategory.DIAGNOSTIC,
407+
streaming_firmware = "2025.2.6",
408+
),
409+
TeslemetryBinarySensorEntityDescription(
410+
key="lights_high_beams",
411+
streaming_key=Signal.LIGHTS_HIGH_BEAMS,
412+
entity_registry_enabled_default=False,
413+
entity_category=EntityCategory.DIAGNOSTIC,
414+
streaming_firmware = "2025.2.6",
415+
),
416+
TeslemetryBinarySensorEntityDescription(
417+
key="sunroof_installed",
418+
streaming_key=Signal.SUNROOF_INSTALLED,
419+
entity_registry_enabled_default=False,
420+
entity_category=EntityCategory.DIAGNOSTIC,
421+
streaming_firmware = "2025.2.6",
422+
),
423+
TeslemetryBinarySensorEntityDescription(
424+
key="seat_vent_enabled",
425+
streaming_key=Signal.SEAT_VENT_ENABLED,
426+
entity_registry_enabled_default=False,
427+
entity_category=EntityCategory.DIAGNOSTIC,
428+
streaming_firmware = "2025.2.6",
429+
),
430+
TeslemetryBinarySensorEntityDescription(
431+
key="rear_defrost_enabled",
432+
streaming_key=Signal.REAR_DEFROST_ENABLED,
433+
entity_registry_enabled_default=False,
434+
entity_category=EntityCategory.DIAGNOSTIC,
435+
streaming_firmware = "2025.2.6",
436+
),
395437
)
396438

397439
ENERGY_LIVE_DESCRIPTIONS: tuple[BinarySensorEntityDescription, ...] = (
@@ -415,6 +457,7 @@ async def async_setup_entry(
415457
entities = []
416458
for vehicle in entry.runtime_data.vehicles:
417459
for description in VEHICLE_DESCRIPTIONS:
460+
print(not vehicle.api.pre2021, description.streaming_key, vehicle.firmware , description.streaming_firmware,vehicle.firmware >= description.streaming_firmware)
418461
if not vehicle.api.pre2021 and description.streaming_key and vehicle.firmware >= description.streaming_firmware:
419462
entities.append(TeslemetryVehicleStreamingBinarySensorEntity(vehicle, description))
420463
elif description.polling:

custom_components/teslemetry/calendar.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ async def _change(self, event: dict[str,Any]):
250250
if "rrule" in event:
251251
one_time = False
252252
rrule = parse_rrule(event["rrule"])
253-
print(rrule)
254253

255254
if "INTERVAL" in rrule and rrule["INTERVAL"] != 1:
256255
raise ServiceValidationError("Repeat interval must be 1 week")

custom_components/teslemetry/climate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ async def async_added_to_hass(self) -> None:
259259
"""Handle entity which will be added."""
260260
await super().async_added_to_hass()
261261
if (state := await self.async_get_last_state()) is not None:
262-
self._attr_hvac_mode = state.state
262+
self._attr_hvac_mode = HVACMode(state.state) if (state.state and state.state != "unknown") else None
263263
self._attr_current_temperature = state.attributes.get('current_temperature')
264264
self._attr_target_temperature = state.attributes.get('target_temperature')
265265
#self._attr_fan_mode = state.attributes.get('fan_mode')

custom_components/teslemetry/device_tracker.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ def __init__(
8484
description: TeslemetryDeviceTrackerEntityDescription,
8585
) -> None:
8686
"""Initialize the device tracker."""
87-
super().__init__(vehicle, description.key)
8887
self.entity_description = description
88+
super().__init__(vehicle, description.key)
8989

9090
def _async_update_attrs(self) -> None:
9191
"""Update the attributes of the entity."""
@@ -108,11 +108,12 @@ def __init__(
108108
description: TeslemetryDeviceTrackerEntityDescription,
109109
) -> None:
110110
"""Initialize the device tracker."""
111+
self.entity_description = description
111112
keys = [description.streaming_key]
112113
if description.streaming_name_key:
113114
keys.append(description.streaming_name_key)
114115
super().__init__(vehicle, description.key, keys)
115-
self.entity_description = description
116+
116117

117118
async def async_added_to_hass(self) -> None:
118119
"""Handle entity which will be added."""

custom_components/teslemetry/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"iot_class": "cloud_polling",
88
"issue_tracker": "https://github.com/Teslemetry/hass-teslemetry/issues",
99
"loggers": ["tesla_fleet_api", "teslemetry_stream"],
10-
"requirements": ["tesla-fleet-api==1.0.6", "teslemetry-stream==0.6.12"],
10+
"requirements": ["tesla-fleet-api==1.0.7", "teslemetry-stream==0.6.12"],
1111
"version": "3.0.15"
1212
}

custom_components/teslemetry/media_player.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from homeassistant.config_entries import ConfigEntry
1313
from homeassistant.core import HomeAssistant
1414
from homeassistant.helpers.entity_platform import AddEntitiesCallback
15-
from tesla_fleet_api.teslemetry.vehicles import VehicleFleet
15+
from tesla_fleet_api.teslemetry.vehicles import TeslemetryVehicleFleet
1616

1717
from custom_components.teslemetry.helpers import handle_vehicle_command
1818

@@ -59,7 +59,7 @@ async def async_setup_entry(
5959
class TeslemetryMediaEntity(TeslemetryRootEntity, MediaPlayerEntity):
6060
"""Base vehicle media player class."""
6161

62-
api: VehicleFleet
62+
api: TeslemetryVehicleFleet
6363

6464
_attr_device_class = MediaPlayerDeviceClass.SPEAKER
6565
_attr_volume_step = VOLUME_STEP
@@ -122,7 +122,7 @@ def __init__(
122122
| MediaPlayerEntityFeature.VOLUME_SET
123123
)
124124
self.scoped = Scope.VEHICLE_CMDS in scopes
125-
if not scoped:
125+
if not self.scoped:
126126
self._attr_supported_features = MediaPlayerEntityFeature(0)
127127

128128
def _async_update_attrs(self) -> None:

custom_components/teslemetry/sensor.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,15 @@ class TeslemetrySensorEntityDescription(SensorEntityDescription):
11201120
entity_registry_enabled_default=False,
11211121
entity_category=EntityCategory.DIAGNOSTIC,
11221122
),
1123+
TeslemetrySensorEntityDescription(
1124+
key="charge_rate_mile_per_hour",
1125+
streaming_key=Signal.CHARGE_RATE_MILE_PER_HOUR,
1126+
streaming_firmware = "2025.2.6",
1127+
state_class=SensorStateClass.MEASUREMENT,
1128+
native_unit_of_measurement=UnitOfSpeed.MILES_PER_HOUR,
1129+
device_class=SensorDeviceClass.SPEED,
1130+
entity_registry_enabled_default=False,
1131+
),
11231132
)
11241133
@dataclass(frozen=True, kw_only=True)
11251134
class TeslemetryTimeEntityDescription(SensorEntityDescription):

custom_components/teslemetry/translations/en.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,24 @@
190190
},
191191
"located_at_favorite": {
192192
"name": "Located at favorite"
193+
},
194+
"lights_hazards_active": {
195+
"name": "Hazard lights"
196+
},
197+
"lights_turn_signal": {
198+
"name": "Turn signal"
199+
},
200+
"lights_high_beams": {
201+
"name": "High beams"
202+
},
203+
"sunroof_installed": {
204+
"name": "Sunroof installed"
205+
},
206+
"seat_vent_enabled": {
207+
"name": "Seat ventilation enabled"
208+
},
209+
"rear_defrost_enabled": {
210+
"name": "Rear defrost enabled"
193211
}
194212
},
195213
"button": {
@@ -1071,6 +1089,9 @@
10711089
},
10721090
"credit_balance": {
10731091
"name": "Command credits"
1092+
},
1093+
"charge_rate_mile_per_hour": {
1094+
"name": "Charge rate miles per hour"
10741095
}
10751096
},
10761097
"switch": {

0 commit comments

Comments
 (0)