mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Migrate Mazda to new entity naming style (#74939)
This commit is contained in:
parent
d0f71d2e53
commit
53502eb662
@ -222,6 +222,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
class MazdaEntity(CoordinatorEntity):
|
class MazdaEntity(CoordinatorEntity):
|
||||||
"""Defines a base Mazda entity."""
|
"""Defines a base Mazda entity."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(self, client, coordinator, index):
|
def __init__(self, client, coordinator, index):
|
||||||
"""Initialize the Mazda entity."""
|
"""Initialize the Mazda entity."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
|
@ -22,9 +22,6 @@ from .const import DATA_CLIENT, DATA_COORDINATOR, DOMAIN
|
|||||||
class MazdaBinarySensorRequiredKeysMixin:
|
class MazdaBinarySensorRequiredKeysMixin:
|
||||||
"""Mixin for required keys."""
|
"""Mixin for required keys."""
|
||||||
|
|
||||||
# Suffix to be appended to the vehicle name to obtain the binary sensor name
|
|
||||||
name_suffix: str
|
|
||||||
|
|
||||||
# Function to determine the value for this binary sensor, given the coordinator data
|
# Function to determine the value for this binary sensor, given the coordinator data
|
||||||
value_fn: Callable[[dict[str, Any]], bool]
|
value_fn: Callable[[dict[str, Any]], bool]
|
||||||
|
|
||||||
@ -49,49 +46,49 @@ def _plugged_in_supported(data):
|
|||||||
BINARY_SENSOR_ENTITIES = [
|
BINARY_SENSOR_ENTITIES = [
|
||||||
MazdaBinarySensorEntityDescription(
|
MazdaBinarySensorEntityDescription(
|
||||||
key="driver_door",
|
key="driver_door",
|
||||||
name_suffix="Driver Door",
|
name="Driver door",
|
||||||
icon="mdi:car-door",
|
icon="mdi:car-door",
|
||||||
device_class=BinarySensorDeviceClass.DOOR,
|
device_class=BinarySensorDeviceClass.DOOR,
|
||||||
value_fn=lambda data: data["status"]["doors"]["driverDoorOpen"],
|
value_fn=lambda data: data["status"]["doors"]["driverDoorOpen"],
|
||||||
),
|
),
|
||||||
MazdaBinarySensorEntityDescription(
|
MazdaBinarySensorEntityDescription(
|
||||||
key="passenger_door",
|
key="passenger_door",
|
||||||
name_suffix="Passenger Door",
|
name="Passenger door",
|
||||||
icon="mdi:car-door",
|
icon="mdi:car-door",
|
||||||
device_class=BinarySensorDeviceClass.DOOR,
|
device_class=BinarySensorDeviceClass.DOOR,
|
||||||
value_fn=lambda data: data["status"]["doors"]["passengerDoorOpen"],
|
value_fn=lambda data: data["status"]["doors"]["passengerDoorOpen"],
|
||||||
),
|
),
|
||||||
MazdaBinarySensorEntityDescription(
|
MazdaBinarySensorEntityDescription(
|
||||||
key="rear_left_door",
|
key="rear_left_door",
|
||||||
name_suffix="Rear Left Door",
|
name="Rear left door",
|
||||||
icon="mdi:car-door",
|
icon="mdi:car-door",
|
||||||
device_class=BinarySensorDeviceClass.DOOR,
|
device_class=BinarySensorDeviceClass.DOOR,
|
||||||
value_fn=lambda data: data["status"]["doors"]["rearLeftDoorOpen"],
|
value_fn=lambda data: data["status"]["doors"]["rearLeftDoorOpen"],
|
||||||
),
|
),
|
||||||
MazdaBinarySensorEntityDescription(
|
MazdaBinarySensorEntityDescription(
|
||||||
key="rear_right_door",
|
key="rear_right_door",
|
||||||
name_suffix="Rear Right Door",
|
name="Rear right door",
|
||||||
icon="mdi:car-door",
|
icon="mdi:car-door",
|
||||||
device_class=BinarySensorDeviceClass.DOOR,
|
device_class=BinarySensorDeviceClass.DOOR,
|
||||||
value_fn=lambda data: data["status"]["doors"]["rearRightDoorOpen"],
|
value_fn=lambda data: data["status"]["doors"]["rearRightDoorOpen"],
|
||||||
),
|
),
|
||||||
MazdaBinarySensorEntityDescription(
|
MazdaBinarySensorEntityDescription(
|
||||||
key="trunk",
|
key="trunk",
|
||||||
name_suffix="Trunk",
|
name="Trunk",
|
||||||
icon="mdi:car-back",
|
icon="mdi:car-back",
|
||||||
device_class=BinarySensorDeviceClass.DOOR,
|
device_class=BinarySensorDeviceClass.DOOR,
|
||||||
value_fn=lambda data: data["status"]["doors"]["trunkOpen"],
|
value_fn=lambda data: data["status"]["doors"]["trunkOpen"],
|
||||||
),
|
),
|
||||||
MazdaBinarySensorEntityDescription(
|
MazdaBinarySensorEntityDescription(
|
||||||
key="hood",
|
key="hood",
|
||||||
name_suffix="Hood",
|
name="Hood",
|
||||||
icon="mdi:car",
|
icon="mdi:car",
|
||||||
device_class=BinarySensorDeviceClass.DOOR,
|
device_class=BinarySensorDeviceClass.DOOR,
|
||||||
value_fn=lambda data: data["status"]["doors"]["hoodOpen"],
|
value_fn=lambda data: data["status"]["doors"]["hoodOpen"],
|
||||||
),
|
),
|
||||||
MazdaBinarySensorEntityDescription(
|
MazdaBinarySensorEntityDescription(
|
||||||
key="ev_plugged_in",
|
key="ev_plugged_in",
|
||||||
name_suffix="Plugged In",
|
name="Plugged in",
|
||||||
device_class=BinarySensorDeviceClass.PLUG,
|
device_class=BinarySensorDeviceClass.PLUG,
|
||||||
is_supported=_plugged_in_supported,
|
is_supported=_plugged_in_supported,
|
||||||
value_fn=lambda data: data["evStatus"]["chargeInfo"]["pluggedIn"],
|
value_fn=lambda data: data["evStatus"]["chargeInfo"]["pluggedIn"],
|
||||||
@ -126,7 +123,6 @@ class MazdaBinarySensorEntity(MazdaEntity, BinarySensorEntity):
|
|||||||
super().__init__(client, coordinator, index)
|
super().__init__(client, coordinator, index)
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
|
|
||||||
self._attr_name = f"{self.vehicle_name} {description.name_suffix}"
|
|
||||||
self._attr_unique_id = f"{self.vin}_{description.key}"
|
self._attr_unique_id = f"{self.vin}_{description.key}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -61,17 +61,7 @@ async def handle_refresh_vehicle_status(
|
|||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class MazdaButtonRequiredKeysMixin:
|
class MazdaButtonEntityDescription(ButtonEntityDescription):
|
||||||
"""Mixin for required keys."""
|
|
||||||
|
|
||||||
# Suffix to be appended to the vehicle name to obtain the button name
|
|
||||||
name_suffix: str
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class MazdaButtonEntityDescription(
|
|
||||||
ButtonEntityDescription, MazdaButtonRequiredKeysMixin
|
|
||||||
):
|
|
||||||
"""Describes a Mazda button entity."""
|
"""Describes a Mazda button entity."""
|
||||||
|
|
||||||
# Function to determine whether the vehicle supports this button, given the coordinator data
|
# Function to determine whether the vehicle supports this button, given the coordinator data
|
||||||
@ -85,27 +75,27 @@ class MazdaButtonEntityDescription(
|
|||||||
BUTTON_ENTITIES = [
|
BUTTON_ENTITIES = [
|
||||||
MazdaButtonEntityDescription(
|
MazdaButtonEntityDescription(
|
||||||
key="start_engine",
|
key="start_engine",
|
||||||
name_suffix="Start Engine",
|
name="Start engine",
|
||||||
icon="mdi:engine",
|
icon="mdi:engine",
|
||||||
),
|
),
|
||||||
MazdaButtonEntityDescription(
|
MazdaButtonEntityDescription(
|
||||||
key="stop_engine",
|
key="stop_engine",
|
||||||
name_suffix="Stop Engine",
|
name="Stop engine",
|
||||||
icon="mdi:engine-off",
|
icon="mdi:engine-off",
|
||||||
),
|
),
|
||||||
MazdaButtonEntityDescription(
|
MazdaButtonEntityDescription(
|
||||||
key="turn_on_hazard_lights",
|
key="turn_on_hazard_lights",
|
||||||
name_suffix="Turn On Hazard Lights",
|
name="Turn on hazard lights",
|
||||||
icon="mdi:hazard-lights",
|
icon="mdi:hazard-lights",
|
||||||
),
|
),
|
||||||
MazdaButtonEntityDescription(
|
MazdaButtonEntityDescription(
|
||||||
key="turn_off_hazard_lights",
|
key="turn_off_hazard_lights",
|
||||||
name_suffix="Turn Off Hazard Lights",
|
name="Turn off hazard lights",
|
||||||
icon="mdi:hazard-lights",
|
icon="mdi:hazard-lights",
|
||||||
),
|
),
|
||||||
MazdaButtonEntityDescription(
|
MazdaButtonEntityDescription(
|
||||||
key="refresh_vehicle_status",
|
key="refresh_vehicle_status",
|
||||||
name_suffix="Refresh Status",
|
name="Refresh status",
|
||||||
icon="mdi:refresh",
|
icon="mdi:refresh",
|
||||||
async_press=handle_refresh_vehicle_status,
|
async_press=handle_refresh_vehicle_status,
|
||||||
is_supported=lambda data: data["isElectric"],
|
is_supported=lambda data: data["isElectric"],
|
||||||
@ -146,7 +136,6 @@ class MazdaButtonEntity(MazdaEntity, ButtonEntity):
|
|||||||
super().__init__(client, coordinator, index)
|
super().__init__(client, coordinator, index)
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
|
|
||||||
self._attr_name = f"{self.vehicle_name} {description.name_suffix}"
|
|
||||||
self._attr_unique_id = f"{self.vin}_{description.key}"
|
self._attr_unique_id = f"{self.vin}_{description.key}"
|
||||||
|
|
||||||
async def async_press(self) -> None:
|
async def async_press(self) -> None:
|
||||||
|
@ -29,6 +29,7 @@ async def async_setup_entry(
|
|||||||
class MazdaDeviceTracker(MazdaEntity, TrackerEntity):
|
class MazdaDeviceTracker(MazdaEntity, TrackerEntity):
|
||||||
"""Class for the device tracker."""
|
"""Class for the device tracker."""
|
||||||
|
|
||||||
|
_attr_name = "Device tracker"
|
||||||
_attr_icon = "mdi:car"
|
_attr_icon = "mdi:car"
|
||||||
_attr_force_update = False
|
_attr_force_update = False
|
||||||
|
|
||||||
@ -36,7 +37,6 @@ class MazdaDeviceTracker(MazdaEntity, TrackerEntity):
|
|||||||
"""Initialize Mazda device tracker."""
|
"""Initialize Mazda device tracker."""
|
||||||
super().__init__(client, coordinator, index)
|
super().__init__(client, coordinator, index)
|
||||||
|
|
||||||
self._attr_name = f"{self.vehicle_name} Device Tracker"
|
|
||||||
self._attr_unique_id = self.vin
|
self._attr_unique_id = self.vin
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -32,11 +32,12 @@ async def async_setup_entry(
|
|||||||
class MazdaLock(MazdaEntity, LockEntity):
|
class MazdaLock(MazdaEntity, LockEntity):
|
||||||
"""Class for the lock."""
|
"""Class for the lock."""
|
||||||
|
|
||||||
|
_attr_name = "Lock"
|
||||||
|
|
||||||
def __init__(self, client, coordinator, index) -> None:
|
def __init__(self, client, coordinator, index) -> None:
|
||||||
"""Initialize Mazda lock."""
|
"""Initialize Mazda lock."""
|
||||||
super().__init__(client, coordinator, index)
|
super().__init__(client, coordinator, index)
|
||||||
|
|
||||||
self._attr_name = f"{self.vehicle_name} Lock"
|
|
||||||
self._attr_unique_id = self.vin
|
self._attr_unique_id = self.vin
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -32,9 +32,6 @@ from .const import DATA_CLIENT, DATA_COORDINATOR, DOMAIN
|
|||||||
class MazdaSensorRequiredKeysMixin:
|
class MazdaSensorRequiredKeysMixin:
|
||||||
"""Mixin for required keys."""
|
"""Mixin for required keys."""
|
||||||
|
|
||||||
# Suffix to be appended to the vehicle name to obtain the sensor name
|
|
||||||
name_suffix: str
|
|
||||||
|
|
||||||
# Function to determine the value for this sensor, given the coordinator data and the configured unit system
|
# Function to determine the value for this sensor, given the coordinator data and the configured unit system
|
||||||
value: Callable[[dict[str, Any], UnitSystem], StateType]
|
value: Callable[[dict[str, Any], UnitSystem], StateType]
|
||||||
|
|
||||||
@ -159,7 +156,7 @@ def _ev_remaining_range_value(data, unit_system):
|
|||||||
SENSOR_ENTITIES = [
|
SENSOR_ENTITIES = [
|
||||||
MazdaSensorEntityDescription(
|
MazdaSensorEntityDescription(
|
||||||
key="fuel_remaining_percentage",
|
key="fuel_remaining_percentage",
|
||||||
name_suffix="Fuel Remaining Percentage",
|
name="Fuel remaining percentage",
|
||||||
icon="mdi:gas-station",
|
icon="mdi:gas-station",
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
@ -168,7 +165,7 @@ SENSOR_ENTITIES = [
|
|||||||
),
|
),
|
||||||
MazdaSensorEntityDescription(
|
MazdaSensorEntityDescription(
|
||||||
key="fuel_distance_remaining",
|
key="fuel_distance_remaining",
|
||||||
name_suffix="Fuel Distance Remaining",
|
name="Fuel distance remaining",
|
||||||
icon="mdi:gas-station",
|
icon="mdi:gas-station",
|
||||||
unit=_get_distance_unit,
|
unit=_get_distance_unit,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
@ -177,7 +174,7 @@ SENSOR_ENTITIES = [
|
|||||||
),
|
),
|
||||||
MazdaSensorEntityDescription(
|
MazdaSensorEntityDescription(
|
||||||
key="odometer",
|
key="odometer",
|
||||||
name_suffix="Odometer",
|
name="Odometer",
|
||||||
icon="mdi:speedometer",
|
icon="mdi:speedometer",
|
||||||
unit=_get_distance_unit,
|
unit=_get_distance_unit,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
@ -186,7 +183,7 @@ SENSOR_ENTITIES = [
|
|||||||
),
|
),
|
||||||
MazdaSensorEntityDescription(
|
MazdaSensorEntityDescription(
|
||||||
key="front_left_tire_pressure",
|
key="front_left_tire_pressure",
|
||||||
name_suffix="Front Left Tire Pressure",
|
name="Front left tire pressure",
|
||||||
icon="mdi:car-tire-alert",
|
icon="mdi:car-tire-alert",
|
||||||
device_class=SensorDeviceClass.PRESSURE,
|
device_class=SensorDeviceClass.PRESSURE,
|
||||||
native_unit_of_measurement=PRESSURE_PSI,
|
native_unit_of_measurement=PRESSURE_PSI,
|
||||||
@ -196,7 +193,7 @@ SENSOR_ENTITIES = [
|
|||||||
),
|
),
|
||||||
MazdaSensorEntityDescription(
|
MazdaSensorEntityDescription(
|
||||||
key="front_right_tire_pressure",
|
key="front_right_tire_pressure",
|
||||||
name_suffix="Front Right Tire Pressure",
|
name="Front right tire pressure",
|
||||||
icon="mdi:car-tire-alert",
|
icon="mdi:car-tire-alert",
|
||||||
device_class=SensorDeviceClass.PRESSURE,
|
device_class=SensorDeviceClass.PRESSURE,
|
||||||
native_unit_of_measurement=PRESSURE_PSI,
|
native_unit_of_measurement=PRESSURE_PSI,
|
||||||
@ -206,7 +203,7 @@ SENSOR_ENTITIES = [
|
|||||||
),
|
),
|
||||||
MazdaSensorEntityDescription(
|
MazdaSensorEntityDescription(
|
||||||
key="rear_left_tire_pressure",
|
key="rear_left_tire_pressure",
|
||||||
name_suffix="Rear Left Tire Pressure",
|
name="Rear left tire pressure",
|
||||||
icon="mdi:car-tire-alert",
|
icon="mdi:car-tire-alert",
|
||||||
device_class=SensorDeviceClass.PRESSURE,
|
device_class=SensorDeviceClass.PRESSURE,
|
||||||
native_unit_of_measurement=PRESSURE_PSI,
|
native_unit_of_measurement=PRESSURE_PSI,
|
||||||
@ -216,7 +213,7 @@ SENSOR_ENTITIES = [
|
|||||||
),
|
),
|
||||||
MazdaSensorEntityDescription(
|
MazdaSensorEntityDescription(
|
||||||
key="rear_right_tire_pressure",
|
key="rear_right_tire_pressure",
|
||||||
name_suffix="Rear Right Tire Pressure",
|
name="Rear right tire pressure",
|
||||||
icon="mdi:car-tire-alert",
|
icon="mdi:car-tire-alert",
|
||||||
device_class=SensorDeviceClass.PRESSURE,
|
device_class=SensorDeviceClass.PRESSURE,
|
||||||
native_unit_of_measurement=PRESSURE_PSI,
|
native_unit_of_measurement=PRESSURE_PSI,
|
||||||
@ -226,7 +223,7 @@ SENSOR_ENTITIES = [
|
|||||||
),
|
),
|
||||||
MazdaSensorEntityDescription(
|
MazdaSensorEntityDescription(
|
||||||
key="ev_charge_level",
|
key="ev_charge_level",
|
||||||
name_suffix="Charge Level",
|
name="Charge level",
|
||||||
device_class=SensorDeviceClass.BATTERY,
|
device_class=SensorDeviceClass.BATTERY,
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
@ -235,7 +232,7 @@ SENSOR_ENTITIES = [
|
|||||||
),
|
),
|
||||||
MazdaSensorEntityDescription(
|
MazdaSensorEntityDescription(
|
||||||
key="ev_remaining_range",
|
key="ev_remaining_range",
|
||||||
name_suffix="Remaining Range",
|
name="Remaining range",
|
||||||
icon="mdi:ev-station",
|
icon="mdi:ev-station",
|
||||||
unit=_get_distance_unit,
|
unit=_get_distance_unit,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
@ -276,7 +273,6 @@ class MazdaSensorEntity(MazdaEntity, SensorEntity):
|
|||||||
super().__init__(client, coordinator, index)
|
super().__init__(client, coordinator, index)
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
|
|
||||||
self._attr_name = f"{self.vehicle_name} {description.name_suffix}"
|
|
||||||
self._attr_unique_id = f"{self.vin}_{description.key}"
|
self._attr_unique_id = f"{self.vin}_{description.key}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -30,6 +30,7 @@ async def async_setup_entry(
|
|||||||
class MazdaChargingSwitch(MazdaEntity, SwitchEntity):
|
class MazdaChargingSwitch(MazdaEntity, SwitchEntity):
|
||||||
"""Class for the charging switch."""
|
"""Class for the charging switch."""
|
||||||
|
|
||||||
|
_attr_name = "Charging"
|
||||||
_attr_icon = "mdi:ev-station"
|
_attr_icon = "mdi:ev-station"
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@ -41,7 +42,6 @@ class MazdaChargingSwitch(MazdaEntity, SwitchEntity):
|
|||||||
"""Initialize Mazda charging switch."""
|
"""Initialize Mazda charging switch."""
|
||||||
super().__init__(client, coordinator, index)
|
super().__init__(client, coordinator, index)
|
||||||
|
|
||||||
self._attr_name = f"{self.vehicle_name} Charging"
|
|
||||||
self._attr_unique_id = self.vin
|
self._attr_unique_id = self.vin
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -16,7 +16,7 @@ async def test_binary_sensors(hass):
|
|||||||
# Driver Door
|
# Driver Door
|
||||||
state = hass.states.get("binary_sensor.my_mazda3_driver_door")
|
state = hass.states.get("binary_sensor.my_mazda3_driver_door")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Driver Door"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Driver door"
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:car-door"
|
assert state.attributes.get(ATTR_ICON) == "mdi:car-door"
|
||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == BinarySensorDeviceClass.DOOR
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == BinarySensorDeviceClass.DOOR
|
||||||
assert state.state == "off"
|
assert state.state == "off"
|
||||||
@ -27,7 +27,7 @@ async def test_binary_sensors(hass):
|
|||||||
# Passenger Door
|
# Passenger Door
|
||||||
state = hass.states.get("binary_sensor.my_mazda3_passenger_door")
|
state = hass.states.get("binary_sensor.my_mazda3_passenger_door")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Passenger Door"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Passenger door"
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:car-door"
|
assert state.attributes.get(ATTR_ICON) == "mdi:car-door"
|
||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == BinarySensorDeviceClass.DOOR
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == BinarySensorDeviceClass.DOOR
|
||||||
assert state.state == "on"
|
assert state.state == "on"
|
||||||
@ -38,7 +38,7 @@ async def test_binary_sensors(hass):
|
|||||||
# Rear Left Door
|
# Rear Left Door
|
||||||
state = hass.states.get("binary_sensor.my_mazda3_rear_left_door")
|
state = hass.states.get("binary_sensor.my_mazda3_rear_left_door")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Rear Left Door"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Rear left door"
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:car-door"
|
assert state.attributes.get(ATTR_ICON) == "mdi:car-door"
|
||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == BinarySensorDeviceClass.DOOR
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == BinarySensorDeviceClass.DOOR
|
||||||
assert state.state == "off"
|
assert state.state == "off"
|
||||||
@ -49,7 +49,7 @@ async def test_binary_sensors(hass):
|
|||||||
# Rear Right Door
|
# Rear Right Door
|
||||||
state = hass.states.get("binary_sensor.my_mazda3_rear_right_door")
|
state = hass.states.get("binary_sensor.my_mazda3_rear_right_door")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Rear Right Door"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Rear right door"
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:car-door"
|
assert state.attributes.get(ATTR_ICON) == "mdi:car-door"
|
||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == BinarySensorDeviceClass.DOOR
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == BinarySensorDeviceClass.DOOR
|
||||||
assert state.state == "off"
|
assert state.state == "off"
|
||||||
@ -90,7 +90,7 @@ async def test_electric_vehicle_binary_sensors(hass):
|
|||||||
# Plugged In
|
# Plugged In
|
||||||
state = hass.states.get("binary_sensor.my_mazda3_plugged_in")
|
state = hass.states.get("binary_sensor.my_mazda3_plugged_in")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Plugged In"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Plugged in"
|
||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == BinarySensorDeviceClass.PLUG
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == BinarySensorDeviceClass.PLUG
|
||||||
assert state.state == "on"
|
assert state.state == "on"
|
||||||
entry = entity_registry.async_get("binary_sensor.my_mazda3_plugged_in")
|
entry = entity_registry.async_get("binary_sensor.my_mazda3_plugged_in")
|
||||||
|
@ -22,7 +22,7 @@ async def test_button_setup_non_electric_vehicle(hass) -> None:
|
|||||||
assert entry.unique_id == "JM000000000000000_start_engine"
|
assert entry.unique_id == "JM000000000000000_start_engine"
|
||||||
state = hass.states.get("button.my_mazda3_start_engine")
|
state = hass.states.get("button.my_mazda3_start_engine")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Start Engine"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Start engine"
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:engine"
|
assert state.attributes.get(ATTR_ICON) == "mdi:engine"
|
||||||
|
|
||||||
entry = entity_registry.async_get("button.my_mazda3_stop_engine")
|
entry = entity_registry.async_get("button.my_mazda3_stop_engine")
|
||||||
@ -30,7 +30,7 @@ async def test_button_setup_non_electric_vehicle(hass) -> None:
|
|||||||
assert entry.unique_id == "JM000000000000000_stop_engine"
|
assert entry.unique_id == "JM000000000000000_stop_engine"
|
||||||
state = hass.states.get("button.my_mazda3_stop_engine")
|
state = hass.states.get("button.my_mazda3_stop_engine")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Stop Engine"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Stop engine"
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:engine-off"
|
assert state.attributes.get(ATTR_ICON) == "mdi:engine-off"
|
||||||
|
|
||||||
entry = entity_registry.async_get("button.my_mazda3_turn_on_hazard_lights")
|
entry = entity_registry.async_get("button.my_mazda3_turn_on_hazard_lights")
|
||||||
@ -38,7 +38,7 @@ async def test_button_setup_non_electric_vehicle(hass) -> None:
|
|||||||
assert entry.unique_id == "JM000000000000000_turn_on_hazard_lights"
|
assert entry.unique_id == "JM000000000000000_turn_on_hazard_lights"
|
||||||
state = hass.states.get("button.my_mazda3_turn_on_hazard_lights")
|
state = hass.states.get("button.my_mazda3_turn_on_hazard_lights")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Turn On Hazard Lights"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Turn on hazard lights"
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:hazard-lights"
|
assert state.attributes.get(ATTR_ICON) == "mdi:hazard-lights"
|
||||||
|
|
||||||
entry = entity_registry.async_get("button.my_mazda3_turn_off_hazard_lights")
|
entry = entity_registry.async_get("button.my_mazda3_turn_off_hazard_lights")
|
||||||
@ -47,7 +47,7 @@ async def test_button_setup_non_electric_vehicle(hass) -> None:
|
|||||||
state = hass.states.get("button.my_mazda3_turn_off_hazard_lights")
|
state = hass.states.get("button.my_mazda3_turn_off_hazard_lights")
|
||||||
assert state
|
assert state
|
||||||
assert (
|
assert (
|
||||||
state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Turn Off Hazard Lights"
|
state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Turn off hazard lights"
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:hazard-lights"
|
assert state.attributes.get(ATTR_ICON) == "mdi:hazard-lights"
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ async def test_button_setup_electric_vehicle(hass) -> None:
|
|||||||
assert entry.unique_id == "JM000000000000000_start_engine"
|
assert entry.unique_id == "JM000000000000000_start_engine"
|
||||||
state = hass.states.get("button.my_mazda3_start_engine")
|
state = hass.states.get("button.my_mazda3_start_engine")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Start Engine"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Start engine"
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:engine"
|
assert state.attributes.get(ATTR_ICON) == "mdi:engine"
|
||||||
|
|
||||||
entry = entity_registry.async_get("button.my_mazda3_stop_engine")
|
entry = entity_registry.async_get("button.my_mazda3_stop_engine")
|
||||||
@ -77,7 +77,7 @@ async def test_button_setup_electric_vehicle(hass) -> None:
|
|||||||
assert entry.unique_id == "JM000000000000000_stop_engine"
|
assert entry.unique_id == "JM000000000000000_stop_engine"
|
||||||
state = hass.states.get("button.my_mazda3_stop_engine")
|
state = hass.states.get("button.my_mazda3_stop_engine")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Stop Engine"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Stop engine"
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:engine-off"
|
assert state.attributes.get(ATTR_ICON) == "mdi:engine-off"
|
||||||
|
|
||||||
entry = entity_registry.async_get("button.my_mazda3_turn_on_hazard_lights")
|
entry = entity_registry.async_get("button.my_mazda3_turn_on_hazard_lights")
|
||||||
@ -85,7 +85,7 @@ async def test_button_setup_electric_vehicle(hass) -> None:
|
|||||||
assert entry.unique_id == "JM000000000000000_turn_on_hazard_lights"
|
assert entry.unique_id == "JM000000000000000_turn_on_hazard_lights"
|
||||||
state = hass.states.get("button.my_mazda3_turn_on_hazard_lights")
|
state = hass.states.get("button.my_mazda3_turn_on_hazard_lights")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Turn On Hazard Lights"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Turn on hazard lights"
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:hazard-lights"
|
assert state.attributes.get(ATTR_ICON) == "mdi:hazard-lights"
|
||||||
|
|
||||||
entry = entity_registry.async_get("button.my_mazda3_turn_off_hazard_lights")
|
entry = entity_registry.async_get("button.my_mazda3_turn_off_hazard_lights")
|
||||||
@ -94,7 +94,7 @@ async def test_button_setup_electric_vehicle(hass) -> None:
|
|||||||
state = hass.states.get("button.my_mazda3_turn_off_hazard_lights")
|
state = hass.states.get("button.my_mazda3_turn_off_hazard_lights")
|
||||||
assert state
|
assert state
|
||||||
assert (
|
assert (
|
||||||
state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Turn Off Hazard Lights"
|
state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Turn off hazard lights"
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:hazard-lights"
|
assert state.attributes.get(ATTR_ICON) == "mdi:hazard-lights"
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ async def test_button_setup_electric_vehicle(hass) -> None:
|
|||||||
assert entry.unique_id == "JM000000000000000_refresh_vehicle_status"
|
assert entry.unique_id == "JM000000000000000_refresh_vehicle_status"
|
||||||
state = hass.states.get("button.my_mazda3_refresh_status")
|
state = hass.states.get("button.my_mazda3_refresh_status")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Refresh Status"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Refresh status"
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:refresh"
|
assert state.attributes.get(ATTR_ICON) == "mdi:refresh"
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ async def test_device_tracker(hass):
|
|||||||
|
|
||||||
state = hass.states.get("device_tracker.my_mazda3_device_tracker")
|
state = hass.states.get("device_tracker.my_mazda3_device_tracker")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Device Tracker"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Device tracker"
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:car"
|
assert state.attributes.get(ATTR_ICON) == "mdi:car"
|
||||||
assert state.attributes.get(ATTR_LATITUDE) == 1.234567
|
assert state.attributes.get(ATTR_LATITUDE) == 1.234567
|
||||||
assert state.attributes.get(ATTR_LONGITUDE) == -2.345678
|
assert state.attributes.get(ATTR_LONGITUDE) == -2.345678
|
||||||
|
@ -32,7 +32,7 @@ async def test_sensors(hass):
|
|||||||
assert state
|
assert state
|
||||||
assert (
|
assert (
|
||||||
state.attributes.get(ATTR_FRIENDLY_NAME)
|
state.attributes.get(ATTR_FRIENDLY_NAME)
|
||||||
== "My Mazda3 Fuel Remaining Percentage"
|
== "My Mazda3 Fuel remaining percentage"
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:gas-station"
|
assert state.attributes.get(ATTR_ICON) == "mdi:gas-station"
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
||||||
@ -46,7 +46,7 @@ async def test_sensors(hass):
|
|||||||
state = hass.states.get("sensor.my_mazda3_fuel_distance_remaining")
|
state = hass.states.get("sensor.my_mazda3_fuel_distance_remaining")
|
||||||
assert state
|
assert state
|
||||||
assert (
|
assert (
|
||||||
state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Fuel Distance Remaining"
|
state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Fuel distance remaining"
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:gas-station"
|
assert state.attributes.get(ATTR_ICON) == "mdi:gas-station"
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == LENGTH_KILOMETERS
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == LENGTH_KILOMETERS
|
||||||
@ -72,7 +72,7 @@ async def test_sensors(hass):
|
|||||||
state = hass.states.get("sensor.my_mazda3_front_left_tire_pressure")
|
state = hass.states.get("sensor.my_mazda3_front_left_tire_pressure")
|
||||||
assert state
|
assert state
|
||||||
assert (
|
assert (
|
||||||
state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Front Left Tire Pressure"
|
state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Front left tire pressure"
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:car-tire-alert"
|
assert state.attributes.get(ATTR_ICON) == "mdi:car-tire-alert"
|
||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PRESSURE
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PRESSURE
|
||||||
@ -88,7 +88,7 @@ async def test_sensors(hass):
|
|||||||
assert state
|
assert state
|
||||||
assert (
|
assert (
|
||||||
state.attributes.get(ATTR_FRIENDLY_NAME)
|
state.attributes.get(ATTR_FRIENDLY_NAME)
|
||||||
== "My Mazda3 Front Right Tire Pressure"
|
== "My Mazda3 Front right tire pressure"
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:car-tire-alert"
|
assert state.attributes.get(ATTR_ICON) == "mdi:car-tire-alert"
|
||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PRESSURE
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PRESSURE
|
||||||
@ -103,7 +103,7 @@ async def test_sensors(hass):
|
|||||||
state = hass.states.get("sensor.my_mazda3_rear_left_tire_pressure")
|
state = hass.states.get("sensor.my_mazda3_rear_left_tire_pressure")
|
||||||
assert state
|
assert state
|
||||||
assert (
|
assert (
|
||||||
state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Rear Left Tire Pressure"
|
state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Rear left tire pressure"
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:car-tire-alert"
|
assert state.attributes.get(ATTR_ICON) == "mdi:car-tire-alert"
|
||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PRESSURE
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PRESSURE
|
||||||
@ -118,7 +118,7 @@ async def test_sensors(hass):
|
|||||||
state = hass.states.get("sensor.my_mazda3_rear_right_tire_pressure")
|
state = hass.states.get("sensor.my_mazda3_rear_right_tire_pressure")
|
||||||
assert state
|
assert state
|
||||||
assert (
|
assert (
|
||||||
state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Rear Right Tire Pressure"
|
state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Rear right tire pressure"
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:car-tire-alert"
|
assert state.attributes.get(ATTR_ICON) == "mdi:car-tire-alert"
|
||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PRESSURE
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PRESSURE
|
||||||
@ -167,7 +167,7 @@ async def test_electric_vehicle_sensors(hass):
|
|||||||
# Charge Level
|
# Charge Level
|
||||||
state = hass.states.get("sensor.my_mazda3_charge_level")
|
state = hass.states.get("sensor.my_mazda3_charge_level")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Charge Level"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Charge level"
|
||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.BATTERY
|
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.BATTERY
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == PERCENTAGE
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
||||||
@ -179,7 +179,7 @@ async def test_electric_vehicle_sensors(hass):
|
|||||||
# Remaining Range
|
# Remaining Range
|
||||||
state = hass.states.get("sensor.my_mazda3_remaining_range")
|
state = hass.states.get("sensor.my_mazda3_remaining_range")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Remaining Range"
|
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Mazda3 Remaining range"
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:ev-station"
|
assert state.attributes.get(ATTR_ICON) == "mdi:ev-station"
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == LENGTH_KILOMETERS
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == LENGTH_KILOMETERS
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user