Add entity translations to Starlink (#96181)

pull/96195/head
Joost Lekkerkerker 2023-07-09 21:43:18 +02:00 committed by GitHub
parent 89259865fb
commit 3f907dea80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 76 additions and 19 deletions

View File

@ -60,64 +60,63 @@ class StarlinkBinarySensorEntity(StarlinkEntity, BinarySensorEntity):
BINARY_SENSORS = [
StarlinkBinarySensorEntityDescription(
key="update",
name="Update available",
device_class=BinarySensorDeviceClass.UPDATE,
value_fn=lambda data: data.alert["alert_install_pending"],
),
StarlinkBinarySensorEntityDescription(
key="roaming",
name="Roaming mode",
translation_key="roaming",
value_fn=lambda data: data.alert["alert_roaming"],
),
StarlinkBinarySensorEntityDescription(
key="currently_obstructed",
name="Obstructed",
translation_key="currently_obstructed",
device_class=BinarySensorDeviceClass.PROBLEM,
value_fn=lambda data: data.status["currently_obstructed"],
),
StarlinkBinarySensorEntityDescription(
key="heating",
name="Heating",
translation_key="heating",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data.alert["alert_is_heating"],
),
StarlinkBinarySensorEntityDescription(
key="power_save_idle",
name="Idle",
translation_key="power_save_idle",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data.alert["alert_is_power_save_idle"],
),
StarlinkBinarySensorEntityDescription(
key="mast_near_vertical",
name="Mast near vertical",
translation_key="mast_near_vertical",
device_class=BinarySensorDeviceClass.PROBLEM,
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data.alert["alert_mast_not_near_vertical"],
),
StarlinkBinarySensorEntityDescription(
key="motors_stuck",
name="Motors stuck",
translation_key="motors_stuck",
device_class=BinarySensorDeviceClass.PROBLEM,
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data.alert["alert_motors_stuck"],
),
StarlinkBinarySensorEntityDescription(
key="slow_ethernet",
name="Ethernet speeds",
translation_key="slow_ethernet",
device_class=BinarySensorDeviceClass.PROBLEM,
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data.alert["alert_slow_ethernet_speeds"],
),
StarlinkBinarySensorEntityDescription(
key="thermal_throttle",
name="Thermal throttle",
translation_key="thermal_throttle",
device_class=BinarySensorDeviceClass.PROBLEM,
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data.alert["alert_thermal_throttle"],
),
StarlinkBinarySensorEntityDescription(
key="unexpected_location",
name="Unexpected location",
translation_key="unexpected_location",
device_class=BinarySensorDeviceClass.PROBLEM,
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda data: data.alert["alert_unexpected_location"],

View File

@ -58,7 +58,6 @@ class StarlinkButtonEntity(StarlinkEntity, ButtonEntity):
BUTTONS = [
StarlinkButtonEntityDescription(
key="reboot",
name="Reboot",
device_class=ButtonDeviceClass.RESTART,
entity_category=EntityCategory.DIAGNOSTIC,
press_fn=lambda coordinator: coordinator.async_reboot_starlink(),

View File

@ -68,7 +68,7 @@ class StarlinkSensorEntity(StarlinkEntity, SensorEntity):
SENSORS: tuple[StarlinkSensorEntityDescription, ...] = (
StarlinkSensorEntityDescription(
key="ping",
name="Ping",
translation_key="ping",
icon="mdi:speedometer",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfTime.MILLISECONDS,
@ -77,7 +77,7 @@ SENSORS: tuple[StarlinkSensorEntityDescription, ...] = (
),
StarlinkSensorEntityDescription(
key="azimuth",
name="Azimuth",
translation_key="azimuth",
icon="mdi:compass",
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
@ -88,7 +88,7 @@ SENSORS: tuple[StarlinkSensorEntityDescription, ...] = (
),
StarlinkSensorEntityDescription(
key="elevation",
name="Elevation",
translation_key="elevation",
icon="mdi:compass",
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
@ -99,7 +99,7 @@ SENSORS: tuple[StarlinkSensorEntityDescription, ...] = (
),
StarlinkSensorEntityDescription(
key="uplink_throughput",
name="Uplink throughput",
translation_key="uplink_throughput",
icon="mdi:upload",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.DATA_RATE,
@ -109,7 +109,7 @@ SENSORS: tuple[StarlinkSensorEntityDescription, ...] = (
),
StarlinkSensorEntityDescription(
key="downlink_throughput",
name="Downlink throughput",
translation_key="downlink_throughput",
icon="mdi:download",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.DATA_RATE,
@ -119,7 +119,7 @@ SENSORS: tuple[StarlinkSensorEntityDescription, ...] = (
),
StarlinkSensorEntityDescription(
key="last_boot_time",
name="Last boot time",
translation_key="last_boot_time",
icon="mdi:clock",
device_class=SensorDeviceClass.TIMESTAMP,
entity_category=EntityCategory.DIAGNOSTIC,
@ -127,7 +127,7 @@ SENSORS: tuple[StarlinkSensorEntityDescription, ...] = (
),
StarlinkSensorEntityDescription(
key="ping_drop_rate",
name="Ping Drop Rate",
translation_key="ping_drop_rate",
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=PERCENTAGE,
value_fn=lambda data: data.status["pop_ping_drop_rate"],

View File

@ -13,5 +13,64 @@
}
}
}
},
"entity": {
"binary_sensor": {
"roaming_mode": {
"name": "Roaming mode"
},
"currently_obstructed": {
"name": "Obstructed"
},
"heating": {
"name": "Heating"
},
"power_save_idle": {
"name": "Idle"
},
"mast_near_vertical": {
"name": "Mast near vertical"
},
"motors_stuck": {
"name": "Motors stuck"
},
"slow_ethernet": {
"name": "Ethernet speeds"
},
"thermal_throttle": {
"name": "Thermal throttle"
},
"unexpected_location": {
"name": "Unexpected location"
}
},
"sensor": {
"ping": {
"name": "Ping"
},
"azimuth": {
"name": "Azimuth"
},
"elevation": {
"name": "Elevation"
},
"uplink_throughput": {
"name": "Uplink throughput"
},
"downlink_throughput": {
"name": "Downlink throughput"
},
"last_boot_time": {
"name": "Last boot time"
},
"ping_drop_rate": {
"name": "Ping drop rate"
}
},
"switch": {
"stowed": {
"name": "Stowed"
}
}
}
}

View File

@ -69,7 +69,7 @@ class StarlinkSwitchEntity(StarlinkEntity, SwitchEntity):
SWITCHES = [
StarlinkSwitchEntityDescription(
key="stowed",
name="Stowed",
translation_key="stowed",
device_class=SwitchDeviceClass.SWITCH,
value_fn=lambda data: data.status["state"] == "STOWED",
turn_on_fn=lambda coordinator: coordinator.async_stow_starlink(True),