Bump subarulink to 0.7.11 (#117743)

pull/118171/head
G-Two 2024-05-26 06:56:43 -04:00 committed by GitHub
parent 66119c9d47
commit 189cf88537
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 55 additions and 244 deletions

View File

@ -6,5 +6,5 @@
"documentation": "https://www.home-assistant.io/integrations/subaru",
"iot_class": "cloud_polling",
"loggers": ["stdiomask", "subarulink"],
"requirements": ["subarulink==0.7.9"]
"requirements": ["subarulink==0.7.11"]
}

View File

@ -3,7 +3,7 @@
from __future__ import annotations
import logging
from typing import Any, cast
from typing import Any
import subarulink.const as sc
@ -23,11 +23,7 @@ from homeassistant.helpers.update_coordinator import (
DataUpdateCoordinator,
)
from homeassistant.util.unit_conversion import DistanceConverter, VolumeConverter
from homeassistant.util.unit_system import (
LENGTH_UNITS,
PRESSURE_UNITS,
US_CUSTOMARY_SYSTEM,
)
from homeassistant.util.unit_system import METRIC_SYSTEM
from . import get_device_info
from .const import (
@ -58,7 +54,7 @@ SAFETY_SENSORS = [
key=sc.ODOMETER,
translation_key="odometer",
device_class=SensorDeviceClass.DISTANCE,
native_unit_of_measurement=UnitOfLength.KILOMETERS,
native_unit_of_measurement=UnitOfLength.MILES,
state_class=SensorStateClass.TOTAL_INCREASING,
),
]
@ -68,42 +64,42 @@ API_GEN_2_SENSORS = [
SensorEntityDescription(
key=sc.AVG_FUEL_CONSUMPTION,
translation_key="average_fuel_consumption",
native_unit_of_measurement=FUEL_CONSUMPTION_LITERS_PER_HUNDRED_KILOMETERS,
native_unit_of_measurement=FUEL_CONSUMPTION_MILES_PER_GALLON,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key=sc.DIST_TO_EMPTY,
translation_key="range",
device_class=SensorDeviceClass.DISTANCE,
native_unit_of_measurement=UnitOfLength.KILOMETERS,
native_unit_of_measurement=UnitOfLength.MILES,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key=sc.TIRE_PRESSURE_FL,
translation_key="tire_pressure_front_left",
device_class=SensorDeviceClass.PRESSURE,
native_unit_of_measurement=UnitOfPressure.HPA,
native_unit_of_measurement=UnitOfPressure.PSI,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key=sc.TIRE_PRESSURE_FR,
translation_key="tire_pressure_front_right",
device_class=SensorDeviceClass.PRESSURE,
native_unit_of_measurement=UnitOfPressure.HPA,
native_unit_of_measurement=UnitOfPressure.PSI,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key=sc.TIRE_PRESSURE_RL,
translation_key="tire_pressure_rear_left",
device_class=SensorDeviceClass.PRESSURE,
native_unit_of_measurement=UnitOfPressure.HPA,
native_unit_of_measurement=UnitOfPressure.PSI,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key=sc.TIRE_PRESSURE_RR,
translation_key="tire_pressure_rear_right",
device_class=SensorDeviceClass.PRESSURE,
native_unit_of_measurement=UnitOfPressure.HPA,
native_unit_of_measurement=UnitOfPressure.PSI,
state_class=SensorStateClass.MEASUREMENT,
),
]
@ -207,30 +203,13 @@ class SubaruSensor(
@property
def native_value(self) -> int | float | None:
"""Return the state of the sensor."""
vehicle_data = self.coordinator.data[self.vin]
current_value = vehicle_data[VEHICLE_STATUS].get(self.entity_description.key)
unit = self.entity_description.native_unit_of_measurement
unit_system = self.hass.config.units
if current_value is None:
return None
if unit in LENGTH_UNITS:
return round(unit_system.length(current_value, cast(str, unit)), 1)
if unit in PRESSURE_UNITS and unit_system == US_CUSTOMARY_SYSTEM:
return round(
unit_system.pressure(current_value, cast(str, unit)),
1,
)
current_value = self.coordinator.data[self.vin][VEHICLE_STATUS].get(
self.entity_description.key
)
if (
unit
in [
FUEL_CONSUMPTION_LITERS_PER_HUNDRED_KILOMETERS,
FUEL_CONSUMPTION_MILES_PER_GALLON,
]
and unit_system == US_CUSTOMARY_SYSTEM
self.entity_description.key == sc.AVG_FUEL_CONSUMPTION
and self.hass.config.units == METRIC_SYSTEM
):
return round((100.0 * L_PER_GAL) / (KM_PER_MI * current_value), 1)
@ -239,23 +218,12 @@ class SubaruSensor(
@property
def native_unit_of_measurement(self) -> str | None:
"""Return the unit_of_measurement of the device."""
unit = self.entity_description.native_unit_of_measurement
if unit in LENGTH_UNITS:
return self.hass.config.units.length_unit
if unit in PRESSURE_UNITS:
if self.hass.config.units == US_CUSTOMARY_SYSTEM:
return self.hass.config.units.pressure_unit
if unit in [
FUEL_CONSUMPTION_LITERS_PER_HUNDRED_KILOMETERS,
FUEL_CONSUMPTION_MILES_PER_GALLON,
]:
if self.hass.config.units == US_CUSTOMARY_SYSTEM:
return FUEL_CONSUMPTION_MILES_PER_GALLON
return unit
if (
self.entity_description.key == sc.AVG_FUEL_CONSUMPTION
and self.hass.config.units == METRIC_SYSTEM
):
return FUEL_CONSUMPTION_LITERS_PER_HUNDRED_KILOMETERS
return self.entity_description.native_unit_of_measurement
@property
def available(self) -> bool:

View File

@ -2650,7 +2650,7 @@ streamlabswater==1.0.1
stringcase==1.2.0
# homeassistant.components.subaru
subarulink==0.7.9
subarulink==0.7.11
# homeassistant.components.solarlog
sunwatcher==0.2.1

View File

@ -2063,7 +2063,7 @@ streamlabswater==1.0.1
stringcase==1.2.0
# homeassistant.components.subaru
subarulink==0.7.9
subarulink==0.7.11
# homeassistant.components.solarlog
sunwatcher==0.2.1

View File

@ -62,19 +62,13 @@ MOCK_DATETIME = datetime.fromtimestamp(1595560000, UTC)
VEHICLE_STATUS_EV = {
VEHICLE_STATUS: {
"AVG_FUEL_CONSUMPTION": 2.3,
"DISTANCE_TO_EMPTY_FUEL": 707,
"DOOR_BOOT_LOCK_STATUS": "UNKNOWN",
"AVG_FUEL_CONSUMPTION": 51.1,
"DISTANCE_TO_EMPTY_FUEL": 170,
"DOOR_BOOT_POSITION": "CLOSED",
"DOOR_ENGINE_HOOD_LOCK_STATUS": "UNKNOWN",
"DOOR_ENGINE_HOOD_POSITION": "CLOSED",
"DOOR_FRONT_LEFT_LOCK_STATUS": "UNKNOWN",
"DOOR_FRONT_LEFT_POSITION": "CLOSED",
"DOOR_FRONT_RIGHT_LOCK_STATUS": "UNKNOWN",
"DOOR_FRONT_RIGHT_POSITION": "CLOSED",
"DOOR_REAR_LEFT_LOCK_STATUS": "UNKNOWN",
"DOOR_REAR_LEFT_POSITION": "CLOSED",
"DOOR_REAR_RIGHT_LOCK_STATUS": "UNKNOWN",
"DOOR_REAR_RIGHT_POSITION": "CLOSED",
"EV_CHARGER_STATE_TYPE": "CHARGING",
"EV_CHARGE_SETTING_AMPERE_TYPE": "MAXIMUM",
@ -85,37 +79,12 @@ VEHICLE_STATUS_EV = {
"EV_STATE_OF_CHARGE_PERCENT": 20,
"EV_TIME_TO_FULLY_CHARGED_UTC": MOCK_DATETIME,
"ODOMETER": 1234,
"POSITION_HEADING_DEGREE": 150,
"POSITION_SPEED_KMPH": "0",
"POSITION_TIMESTAMP": 1595560000.0,
"SEAT_BELT_STATUS_FRONT_LEFT": "BELTED",
"SEAT_BELT_STATUS_FRONT_MIDDLE": "NOT_EQUIPPED",
"SEAT_BELT_STATUS_FRONT_RIGHT": "BELTED",
"SEAT_BELT_STATUS_SECOND_LEFT": "UNKNOWN",
"SEAT_BELT_STATUS_SECOND_MIDDLE": "UNKNOWN",
"SEAT_BELT_STATUS_SECOND_RIGHT": "UNKNOWN",
"SEAT_BELT_STATUS_THIRD_LEFT": "UNKNOWN",
"SEAT_BELT_STATUS_THIRD_MIDDLE": "UNKNOWN",
"SEAT_BELT_STATUS_THIRD_RIGHT": "UNKNOWN",
"SEAT_OCCUPATION_STATUS_FRONT_LEFT": "UNKNOWN",
"SEAT_OCCUPATION_STATUS_FRONT_MIDDLE": "NOT_EQUIPPED",
"SEAT_OCCUPATION_STATUS_FRONT_RIGHT": "UNKNOWN",
"SEAT_OCCUPATION_STATUS_SECOND_LEFT": "UNKNOWN",
"SEAT_OCCUPATION_STATUS_SECOND_MIDDLE": "UNKNOWN",
"SEAT_OCCUPATION_STATUS_SECOND_RIGHT": "UNKNOWN",
"SEAT_OCCUPATION_STATUS_THIRD_LEFT": "UNKNOWN",
"SEAT_OCCUPATION_STATUS_THIRD_MIDDLE": "UNKNOWN",
"SEAT_OCCUPATION_STATUS_THIRD_RIGHT": "UNKNOWN",
"TIMESTAMP": 1595560000.0,
"TRANSMISSION_MODE": "UNKNOWN",
"TYRE_PRESSURE_FRONT_LEFT": 0,
"TYRE_PRESSURE_FRONT_RIGHT": 2550,
"TYRE_PRESSURE_REAR_LEFT": 2450,
"TYRE_PRESSURE_FRONT_LEFT": 0.0,
"TYRE_PRESSURE_FRONT_RIGHT": 31.9,
"TYRE_PRESSURE_REAR_LEFT": 32.6,
"TYRE_PRESSURE_REAR_RIGHT": None,
"TYRE_STATUS_FRONT_LEFT": "UNKNOWN",
"TYRE_STATUS_FRONT_RIGHT": "UNKNOWN",
"TYRE_STATUS_REAR_LEFT": "UNKNOWN",
"TYRE_STATUS_REAR_RIGHT": "UNKNOWN",
"VEHICLE_STATE_TYPE": "IGNITION_OFF",
"WINDOW_BACK_STATUS": "UNKNOWN",
"WINDOW_FRONT_LEFT_STATUS": "VENTED",
@ -123,7 +92,6 @@ VEHICLE_STATUS_EV = {
"WINDOW_REAR_LEFT_STATUS": "UNKNOWN",
"WINDOW_REAR_RIGHT_STATUS": "UNKNOWN",
"WINDOW_SUNROOF_STATUS": "UNKNOWN",
"HEADING": 170,
"LATITUDE": 40.0,
"LONGITUDE": -100.0,
}
@ -132,53 +100,22 @@ VEHICLE_STATUS_EV = {
VEHICLE_STATUS_G3 = {
VEHICLE_STATUS: {
"AVG_FUEL_CONSUMPTION": 2.3,
"DISTANCE_TO_EMPTY_FUEL": 707,
"DOOR_BOOT_LOCK_STATUS": "UNKNOWN",
"AVG_FUEL_CONSUMPTION": 51.1,
"DISTANCE_TO_EMPTY_FUEL": 170,
"DOOR_BOOT_POSITION": "CLOSED",
"DOOR_ENGINE_HOOD_LOCK_STATUS": "UNKNOWN",
"DOOR_ENGINE_HOOD_POSITION": "CLOSED",
"DOOR_FRONT_LEFT_LOCK_STATUS": "UNKNOWN",
"DOOR_FRONT_LEFT_POSITION": "CLOSED",
"DOOR_FRONT_RIGHT_LOCK_STATUS": "UNKNOWN",
"DOOR_FRONT_RIGHT_POSITION": "CLOSED",
"DOOR_REAR_LEFT_LOCK_STATUS": "UNKNOWN",
"DOOR_REAR_LEFT_POSITION": "CLOSED",
"DOOR_REAR_RIGHT_LOCK_STATUS": "UNKNOWN",
"DOOR_REAR_RIGHT_POSITION": "CLOSED",
"REMAINING_FUEL_PERCENT": 77,
"ODOMETER": 1234,
"POSITION_HEADING_DEGREE": 150,
"POSITION_SPEED_KMPH": "0",
"POSITION_TIMESTAMP": 1595560000.0,
"SEAT_BELT_STATUS_FRONT_LEFT": "BELTED",
"SEAT_BELT_STATUS_FRONT_MIDDLE": "NOT_EQUIPPED",
"SEAT_BELT_STATUS_FRONT_RIGHT": "BELTED",
"SEAT_BELT_STATUS_SECOND_LEFT": "UNKNOWN",
"SEAT_BELT_STATUS_SECOND_MIDDLE": "UNKNOWN",
"SEAT_BELT_STATUS_SECOND_RIGHT": "UNKNOWN",
"SEAT_BELT_STATUS_THIRD_LEFT": "UNKNOWN",
"SEAT_BELT_STATUS_THIRD_MIDDLE": "UNKNOWN",
"SEAT_BELT_STATUS_THIRD_RIGHT": "UNKNOWN",
"SEAT_OCCUPATION_STATUS_FRONT_LEFT": "UNKNOWN",
"SEAT_OCCUPATION_STATUS_FRONT_MIDDLE": "NOT_EQUIPPED",
"SEAT_OCCUPATION_STATUS_FRONT_RIGHT": "UNKNOWN",
"SEAT_OCCUPATION_STATUS_SECOND_LEFT": "UNKNOWN",
"SEAT_OCCUPATION_STATUS_SECOND_MIDDLE": "UNKNOWN",
"SEAT_OCCUPATION_STATUS_SECOND_RIGHT": "UNKNOWN",
"SEAT_OCCUPATION_STATUS_THIRD_LEFT": "UNKNOWN",
"SEAT_OCCUPATION_STATUS_THIRD_MIDDLE": "UNKNOWN",
"SEAT_OCCUPATION_STATUS_THIRD_RIGHT": "UNKNOWN",
"TIMESTAMP": 1595560000.0,
"TRANSMISSION_MODE": "UNKNOWN",
"TYRE_PRESSURE_FRONT_LEFT": 2550,
"TYRE_PRESSURE_FRONT_RIGHT": 2550,
"TYRE_PRESSURE_REAR_LEFT": 2450,
"TYRE_PRESSURE_FRONT_LEFT": 0.0,
"TYRE_PRESSURE_FRONT_RIGHT": 31.9,
"TYRE_PRESSURE_REAR_LEFT": 32.6,
"TYRE_PRESSURE_REAR_RIGHT": None,
"TYRE_STATUS_FRONT_LEFT": "UNKNOWN",
"TYRE_STATUS_FRONT_RIGHT": "UNKNOWN",
"TYRE_STATUS_REAR_LEFT": "UNKNOWN",
"TYRE_STATUS_REAR_RIGHT": "UNKNOWN",
"VEHICLE_STATE_TYPE": "IGNITION_OFF",
"WINDOW_BACK_STATUS": "UNKNOWN",
"WINDOW_FRONT_LEFT_STATUS": "VENTED",
@ -186,15 +123,14 @@ VEHICLE_STATUS_G3 = {
"WINDOW_REAR_LEFT_STATUS": "UNKNOWN",
"WINDOW_REAR_RIGHT_STATUS": "UNKNOWN",
"WINDOW_SUNROOF_STATUS": "UNKNOWN",
"HEADING": 170,
"LATITUDE": 40.0,
"LONGITUDE": -100.0,
}
}
EXPECTED_STATE_EV_IMPERIAL = {
"AVG_FUEL_CONSUMPTION": "102.3",
"DISTANCE_TO_EMPTY_FUEL": "439.3",
"AVG_FUEL_CONSUMPTION": "51.1",
"DISTANCE_TO_EMPTY_FUEL": "170",
"EV_CHARGER_STATE_TYPE": "CHARGING",
"EV_CHARGE_SETTING_AMPERE_TYPE": "MAXIMUM",
"EV_CHARGE_VOLT_TYPE": "CHARGE_LEVEL_1",
@ -203,45 +139,37 @@ EXPECTED_STATE_EV_IMPERIAL = {
"EV_STATE_OF_CHARGE_MODE": "EV_MODE",
"EV_STATE_OF_CHARGE_PERCENT": "20",
"EV_TIME_TO_FULLY_CHARGED_UTC": "2020-07-24T03:06:40+00:00",
"ODOMETER": "766.8",
"POSITION_HEADING_DEGREE": "150",
"POSITION_SPEED_KMPH": "0",
"POSITION_TIMESTAMP": 1595560000.0,
"ODOMETER": "1234",
"TIMESTAMP": 1595560000.0,
"TRANSMISSION_MODE": "UNKNOWN",
"TYRE_PRESSURE_FRONT_LEFT": "0.0",
"TYRE_PRESSURE_FRONT_RIGHT": "37.0",
"TYRE_PRESSURE_REAR_LEFT": "35.5",
"TYRE_PRESSURE_FRONT_RIGHT": "31.9",
"TYRE_PRESSURE_REAR_LEFT": "32.6",
"TYRE_PRESSURE_REAR_RIGHT": "unknown",
"VEHICLE_STATE_TYPE": "IGNITION_OFF",
"HEADING": 170,
"LATITUDE": 40.0,
"LONGITUDE": -100.0,
}
EXPECTED_STATE_EV_METRIC = {
"AVG_FUEL_CONSUMPTION": "2.3",
"DISTANCE_TO_EMPTY_FUEL": "707",
"AVG_FUEL_CONSUMPTION": "4.6",
"DISTANCE_TO_EMPTY_FUEL": "274",
"EV_CHARGER_STATE_TYPE": "CHARGING",
"EV_CHARGE_SETTING_AMPERE_TYPE": "MAXIMUM",
"EV_CHARGE_VOLT_TYPE": "CHARGE_LEVEL_1",
"EV_DISTANCE_TO_EMPTY": "1.6",
"EV_DISTANCE_TO_EMPTY": "2",
"EV_IS_PLUGGED_IN": "UNLOCKED_CONNECTED",
"EV_STATE_OF_CHARGE_MODE": "EV_MODE",
"EV_STATE_OF_CHARGE_PERCENT": "20",
"EV_TIME_TO_FULLY_CHARGED_UTC": "2020-07-24T03:06:40+00:00",
"ODOMETER": "1234",
"POSITION_HEADING_DEGREE": "150",
"POSITION_SPEED_KMPH": "0",
"POSITION_TIMESTAMP": 1595560000.0,
"ODOMETER": "1986",
"TIMESTAMP": 1595560000.0,
"TRANSMISSION_MODE": "UNKNOWN",
"TYRE_PRESSURE_FRONT_LEFT": "0",
"TYRE_PRESSURE_FRONT_RIGHT": "2550",
"TYRE_PRESSURE_REAR_LEFT": "2450",
"TYRE_PRESSURE_FRONT_LEFT": "0.0",
"TYRE_PRESSURE_FRONT_RIGHT": "219.9",
"TYRE_PRESSURE_REAR_LEFT": "224.8",
"TYRE_PRESSURE_REAR_RIGHT": "unknown",
"VEHICLE_STATE_TYPE": "IGNITION_OFF",
"HEADING": 170,
"LATITUDE": 40.0,
"LONGITUDE": -100.0,
}
@ -259,9 +187,6 @@ EXPECTED_STATE_EV_UNAVAILABLE = {
"EV_STATE_OF_CHARGE_PERCENT": "unavailable",
"EV_TIME_TO_FULLY_CHARGED_UTC": "unavailable",
"ODOMETER": "unavailable",
"POSITION_HEADING_DEGREE": "unavailable",
"POSITION_SPEED_KMPH": "unavailable",
"POSITION_TIMESTAMP": "unavailable",
"TIMESTAMP": "unavailable",
"TRANSMISSION_MODE": "unavailable",
"TYRE_PRESSURE_FRONT_LEFT": "unavailable",
@ -269,7 +194,6 @@ EXPECTED_STATE_EV_UNAVAILABLE = {
"TYRE_PRESSURE_REAR_LEFT": "unavailable",
"TYRE_PRESSURE_REAR_RIGHT": "unavailable",
"VEHICLE_STATE_TYPE": "unavailable",
"HEADING": "unavailable",
"LATITUDE": "unavailable",
"LONGITUDE": "unavailable",
}

View File

@ -11,19 +11,13 @@
'data': list([
dict({
'vehicle_status': dict({
'AVG_FUEL_CONSUMPTION': 2.3,
'DISTANCE_TO_EMPTY_FUEL': 707,
'DOOR_BOOT_LOCK_STATUS': 'UNKNOWN',
'AVG_FUEL_CONSUMPTION': 51.1,
'DISTANCE_TO_EMPTY_FUEL': 170,
'DOOR_BOOT_POSITION': 'CLOSED',
'DOOR_ENGINE_HOOD_LOCK_STATUS': 'UNKNOWN',
'DOOR_ENGINE_HOOD_POSITION': 'CLOSED',
'DOOR_FRONT_LEFT_LOCK_STATUS': 'UNKNOWN',
'DOOR_FRONT_LEFT_POSITION': 'CLOSED',
'DOOR_FRONT_RIGHT_LOCK_STATUS': 'UNKNOWN',
'DOOR_FRONT_RIGHT_POSITION': 'CLOSED',
'DOOR_REAR_LEFT_LOCK_STATUS': 'UNKNOWN',
'DOOR_REAR_LEFT_POSITION': 'CLOSED',
'DOOR_REAR_RIGHT_LOCK_STATUS': 'UNKNOWN',
'DOOR_REAR_RIGHT_POSITION': 'CLOSED',
'EV_CHARGER_STATE_TYPE': 'CHARGING',
'EV_CHARGE_SETTING_AMPERE_TYPE': 'MAXIMUM',
@ -33,41 +27,15 @@
'EV_STATE_OF_CHARGE_MODE': 'EV_MODE',
'EV_STATE_OF_CHARGE_PERCENT': 20,
'EV_TIME_TO_FULLY_CHARGED_UTC': '2020-07-24T03:06:40+00:00',
'HEADING': 170,
'LATITUDE': '**REDACTED**',
'LONGITUDE': '**REDACTED**',
'ODOMETER': '**REDACTED**',
'POSITION_HEADING_DEGREE': 150,
'POSITION_SPEED_KMPH': '0',
'POSITION_TIMESTAMP': 1595560000.0,
'SEAT_BELT_STATUS_FRONT_LEFT': 'BELTED',
'SEAT_BELT_STATUS_FRONT_MIDDLE': 'NOT_EQUIPPED',
'SEAT_BELT_STATUS_FRONT_RIGHT': 'BELTED',
'SEAT_BELT_STATUS_SECOND_LEFT': 'UNKNOWN',
'SEAT_BELT_STATUS_SECOND_MIDDLE': 'UNKNOWN',
'SEAT_BELT_STATUS_SECOND_RIGHT': 'UNKNOWN',
'SEAT_BELT_STATUS_THIRD_LEFT': 'UNKNOWN',
'SEAT_BELT_STATUS_THIRD_MIDDLE': 'UNKNOWN',
'SEAT_BELT_STATUS_THIRD_RIGHT': 'UNKNOWN',
'SEAT_OCCUPATION_STATUS_FRONT_LEFT': 'UNKNOWN',
'SEAT_OCCUPATION_STATUS_FRONT_MIDDLE': 'NOT_EQUIPPED',
'SEAT_OCCUPATION_STATUS_FRONT_RIGHT': 'UNKNOWN',
'SEAT_OCCUPATION_STATUS_SECOND_LEFT': 'UNKNOWN',
'SEAT_OCCUPATION_STATUS_SECOND_MIDDLE': 'UNKNOWN',
'SEAT_OCCUPATION_STATUS_SECOND_RIGHT': 'UNKNOWN',
'SEAT_OCCUPATION_STATUS_THIRD_LEFT': 'UNKNOWN',
'SEAT_OCCUPATION_STATUS_THIRD_MIDDLE': 'UNKNOWN',
'SEAT_OCCUPATION_STATUS_THIRD_RIGHT': 'UNKNOWN',
'TIMESTAMP': 1595560000.0,
'TRANSMISSION_MODE': 'UNKNOWN',
'TYRE_PRESSURE_FRONT_LEFT': 0,
'TYRE_PRESSURE_FRONT_RIGHT': 2550,
'TYRE_PRESSURE_REAR_LEFT': 2450,
'TYRE_PRESSURE_FRONT_LEFT': 0.0,
'TYRE_PRESSURE_FRONT_RIGHT': 31.9,
'TYRE_PRESSURE_REAR_LEFT': 32.6,
'TYRE_PRESSURE_REAR_RIGHT': None,
'TYRE_STATUS_FRONT_LEFT': 'UNKNOWN',
'TYRE_STATUS_FRONT_RIGHT': 'UNKNOWN',
'TYRE_STATUS_REAR_LEFT': 'UNKNOWN',
'TYRE_STATUS_REAR_RIGHT': 'UNKNOWN',
'VEHICLE_STATE_TYPE': 'IGNITION_OFF',
'WINDOW_BACK_STATUS': 'UNKNOWN',
'WINDOW_FRONT_LEFT_STATUS': 'VENTED',
@ -94,19 +62,13 @@
}),
'data': dict({
'vehicle_status': dict({
'AVG_FUEL_CONSUMPTION': 2.3,
'DISTANCE_TO_EMPTY_FUEL': 707,
'DOOR_BOOT_LOCK_STATUS': 'UNKNOWN',
'AVG_FUEL_CONSUMPTION': 51.1,
'DISTANCE_TO_EMPTY_FUEL': 170,
'DOOR_BOOT_POSITION': 'CLOSED',
'DOOR_ENGINE_HOOD_LOCK_STATUS': 'UNKNOWN',
'DOOR_ENGINE_HOOD_POSITION': 'CLOSED',
'DOOR_FRONT_LEFT_LOCK_STATUS': 'UNKNOWN',
'DOOR_FRONT_LEFT_POSITION': 'CLOSED',
'DOOR_FRONT_RIGHT_LOCK_STATUS': 'UNKNOWN',
'DOOR_FRONT_RIGHT_POSITION': 'CLOSED',
'DOOR_REAR_LEFT_LOCK_STATUS': 'UNKNOWN',
'DOOR_REAR_LEFT_POSITION': 'CLOSED',
'DOOR_REAR_RIGHT_LOCK_STATUS': 'UNKNOWN',
'DOOR_REAR_RIGHT_POSITION': 'CLOSED',
'EV_CHARGER_STATE_TYPE': 'CHARGING',
'EV_CHARGE_SETTING_AMPERE_TYPE': 'MAXIMUM',
@ -116,41 +78,15 @@
'EV_STATE_OF_CHARGE_MODE': 'EV_MODE',
'EV_STATE_OF_CHARGE_PERCENT': 20,
'EV_TIME_TO_FULLY_CHARGED_UTC': '2020-07-24T03:06:40+00:00',
'HEADING': 170,
'LATITUDE': '**REDACTED**',
'LONGITUDE': '**REDACTED**',
'ODOMETER': '**REDACTED**',
'POSITION_HEADING_DEGREE': 150,
'POSITION_SPEED_KMPH': '0',
'POSITION_TIMESTAMP': 1595560000.0,
'SEAT_BELT_STATUS_FRONT_LEFT': 'BELTED',
'SEAT_BELT_STATUS_FRONT_MIDDLE': 'NOT_EQUIPPED',
'SEAT_BELT_STATUS_FRONT_RIGHT': 'BELTED',
'SEAT_BELT_STATUS_SECOND_LEFT': 'UNKNOWN',
'SEAT_BELT_STATUS_SECOND_MIDDLE': 'UNKNOWN',
'SEAT_BELT_STATUS_SECOND_RIGHT': 'UNKNOWN',
'SEAT_BELT_STATUS_THIRD_LEFT': 'UNKNOWN',
'SEAT_BELT_STATUS_THIRD_MIDDLE': 'UNKNOWN',
'SEAT_BELT_STATUS_THIRD_RIGHT': 'UNKNOWN',
'SEAT_OCCUPATION_STATUS_FRONT_LEFT': 'UNKNOWN',
'SEAT_OCCUPATION_STATUS_FRONT_MIDDLE': 'NOT_EQUIPPED',
'SEAT_OCCUPATION_STATUS_FRONT_RIGHT': 'UNKNOWN',
'SEAT_OCCUPATION_STATUS_SECOND_LEFT': 'UNKNOWN',
'SEAT_OCCUPATION_STATUS_SECOND_MIDDLE': 'UNKNOWN',
'SEAT_OCCUPATION_STATUS_SECOND_RIGHT': 'UNKNOWN',
'SEAT_OCCUPATION_STATUS_THIRD_LEFT': 'UNKNOWN',
'SEAT_OCCUPATION_STATUS_THIRD_MIDDLE': 'UNKNOWN',
'SEAT_OCCUPATION_STATUS_THIRD_RIGHT': 'UNKNOWN',
'TIMESTAMP': 1595560000.0,
'TRANSMISSION_MODE': 'UNKNOWN',
'TYRE_PRESSURE_FRONT_LEFT': 0,
'TYRE_PRESSURE_FRONT_RIGHT': 2550,
'TYRE_PRESSURE_REAR_LEFT': 2450,
'TYRE_PRESSURE_FRONT_LEFT': 0.0,
'TYRE_PRESSURE_FRONT_RIGHT': 31.9,
'TYRE_PRESSURE_REAR_LEFT': 32.6,
'TYRE_PRESSURE_REAR_RIGHT': None,
'TYRE_STATUS_FRONT_LEFT': 'UNKNOWN',
'TYRE_STATUS_FRONT_RIGHT': 'UNKNOWN',
'TYRE_STATUS_REAR_LEFT': 'UNKNOWN',
'TYRE_STATUS_REAR_RIGHT': 'UNKNOWN',
'VEHICLE_STATE_TYPE': 'IGNITION_OFF',
'WINDOW_BACK_STATUS': 'UNKNOWN',
'WINDOW_FRONT_LEFT_STATUS': 'VENTED',

View File

@ -14,14 +14,11 @@ from homeassistant.components.subaru.sensor import (
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from .api_responses import (
EXPECTED_STATE_EV_IMPERIAL,
EXPECTED_STATE_EV_METRIC,
EXPECTED_STATE_EV_UNAVAILABLE,
TEST_VIN_2_EV,
VEHICLE_STATUS_EV,
)
from .conftest import (
MOCK_API_FETCH,
@ -31,20 +28,6 @@ from .conftest import (
)
async def test_sensors_ev_imperial(hass: HomeAssistant, ev_entry) -> None:
"""Test sensors supporting imperial units."""
hass.config.units = US_CUSTOMARY_SYSTEM
with (
patch(MOCK_API_FETCH),
patch(MOCK_API_GET_DATA, return_value=VEHICLE_STATUS_EV),
):
advance_time_to_next_fetch(hass)
await hass.async_block_till_done()
_assert_data(hass, EXPECTED_STATE_EV_IMPERIAL)
async def test_sensors_ev_metric(hass: HomeAssistant, ev_entry) -> None:
"""Test sensors supporting metric units."""
_assert_data(hass, EXPECTED_STATE_EV_METRIC)