Skip to content

Commit

Permalink
Add more sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
Bre77 committed Dec 16, 2024
1 parent 3d660b9 commit 35f32be
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 2 deletions.
91 changes: 91 additions & 0 deletions custom_components/teslemetry/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,97 @@ class TeslemetrySensorEntityDescription(SensorEntityDescription):
streaming_key=Signal.EFFICIENCY_PACKAGE,
entity_registry_enabled_default=False,
),
TeslemetrySensorEntityDescription(
key="estimated_hours_to_charge_termination",
streaming_key=Signal.ESTIMATED_HOURS_TO_CHARGE_TERMINATION,
device_class=SensorDeviceClass.DURATION,
native_unit_of_measurement=UnitOfTime.HOURS,
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
),
TeslemetrySensorEntityDescription(
key="drive_state_expected_energy_percent_at_trip_arrival",
streaming_key=Signal.EXPECTED_ENERGY_PERCENT_AT_TRIP_ARRIVAL,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=PERCENTAGE,
device_class=SensorDeviceClass.BATTERY,
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
suggested_display_precision=1,
),
TeslemetrySensorEntityDescription(
key="homelink_device_count",
streaming_key=Signal.HOMELINK_DEVICE_COUNT,
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
),
TeslemetrySensorEntityDescription(
key="powershare_hours_left",
streaming_key=Signal.POWERSHARE_HOURS_LEFT,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfTime.HOURS,
device_class=SensorDeviceClass.DURATION,
entity_category=EntityCategory.DIAGNOSTIC,
suggested_display_precision=2,
entity_registry_enabled_default=False,
),
TeslemetrySensorEntityDescription(
key="powershare_instantaneous_power_kw",
streaming_key=Signal.POWERSHARE_INSTANTANEOUS_POWER_KW,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfPower.KILO_WATT,
device_class=SensorDeviceClass.POWER,
entity_category=EntityCategory.DIAGNOSTIC,
suggested_display_precision=2,
entity_registry_enabled_default=False,
),
TeslemetrySensorEntityDescription(
key="powershare_status",
streaming_key=Signal.POWERSHARE_STATUS,
entity_category=EntityCategory.DIAGNOSTIC,
options=[
"Unknown",
"Inactive",
"Handshaking",
"Init",
"Enabled",
"EnabledReconnectingSoon",
"Stopped"
],
streaming_value_fn=lambda x: str(x).replace("PowerShareState",""),
entity_registry_enabled_default=False,
),
TeslemetrySensorEntityDescription(
key="powershare_stop_reason",
streaming_key=Signal.POWERSHARE_STOP_REASON,
entity_category=EntityCategory.DIAGNOSTIC,
options=[
"Unknown",
"None",
"SOCTooLow",
"Retry",
"Fault",
"User",
"Reconnecting",
"Authentication"
],
streaming_value_fn=lambda x: str(x).replace("PowershareStopReasonStatus",""),
entity_registry_enabled_default=False,
),
TeslemetrySensorEntityDescription(
key="powershare_type",
streaming_key=Signal.POWERSHARE_TYPE,
entity_category=EntityCategory.DIAGNOSTIC,
options=[
"Unknown",
"None",
"Load",
"Home"
],
streaming_value_fn=lambda x: str(x).replace("PowershareTypeStatus",""),
entity_registry_enabled_default=False,
),
)

@dataclass(frozen=True, kw_only=True)
Expand Down
28 changes: 26 additions & 2 deletions custom_components/teslemetry/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -864,10 +864,34 @@
"name": "Grid exported"
},
"center_display": {
"name": "Center Display"
"name": "Center display"
},
"efficiency_package": {
"name": "Efficiency Package"
"name": "Efficiency package"
},
"estimated_hours_to_charge_termination": {
"name": "Estimated hours to charge termination"
},
"drive_state_expected_energy_percent_at_trip_arrival": {
"name": "Expected energy percent at trip arrival"
},
"homelink_device_count": {
"name": "Homelink device count"
},
"powershare_hours_left": {
"name": "Powershare hours left"
},
"powershare_instantaneous_power_kw": {
"name": "Powershare instantaneous power"
},
"powershare_status": {
"name": "Powershare status"
},
"powershare_stop_reason": {
"name": "Powershare stop reason"
},
"powershare_type": {
"name": "Powershare type"
}
},
"switch": {
Expand Down

0 comments on commit 35f32be

Please sign in to comment.