mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Add Remote Engine Start status to Renault integration (#67028)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
eb80abf89e
commit
419e683526
@ -153,4 +153,9 @@ COORDINATORS: tuple[RenaultCoordinatorDescription, ...] = (
|
||||
key="lock_status",
|
||||
update_method=lambda x: x.get_lock_status,
|
||||
),
|
||||
RenaultCoordinatorDescription(
|
||||
endpoint="res-state",
|
||||
key="res_state",
|
||||
update_method=lambda x: x.get_res_state,
|
||||
),
|
||||
)
|
||||
|
@ -12,6 +12,7 @@ from renault_api.kamereon.models import (
|
||||
KamereonVehicleCockpitData,
|
||||
KamereonVehicleHvacStatusData,
|
||||
KamereonVehicleLocationData,
|
||||
KamereonVehicleResStateData,
|
||||
)
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
@ -333,4 +334,19 @@ SENSOR_TYPES: tuple[RenaultSensorEntityDescription, ...] = (
|
||||
name="Location Last Activity",
|
||||
value_lambda=_get_utc_value,
|
||||
),
|
||||
RenaultSensorEntityDescription(
|
||||
key="res_state",
|
||||
coordinator="res_state",
|
||||
data_key="details",
|
||||
entity_class=RenaultSensor[KamereonVehicleResStateData],
|
||||
name="Remote Engine Start",
|
||||
),
|
||||
RenaultSensorEntityDescription(
|
||||
key="res_state_code",
|
||||
coordinator="res_state",
|
||||
data_key="code",
|
||||
entity_class=RenaultSensor[KamereonVehicleResStateData],
|
||||
entity_registry_enabled_default=False,
|
||||
name="Remote Engine Start Code",
|
||||
),
|
||||
)
|
||||
|
@ -101,6 +101,11 @@ def _get_fixtures(vehicle_type: str) -> MappingProxyType:
|
||||
if "lock_status" in mock_vehicle["endpoints"]
|
||||
else load_fixture("renault/no_data.json")
|
||||
).get_attributes(schemas.KamereonVehicleLockStatusDataSchema),
|
||||
"res_state": schemas.KamereonVehicleDataResponseSchema.loads(
|
||||
load_fixture(f"renault/{mock_vehicle['endpoints']['res_state']}")
|
||||
if "res_state" in mock_vehicle["endpoints"]
|
||||
else load_fixture("renault/no_data.json")
|
||||
).get_attributes(schemas.KamereonVehicleResStateDataSchema),
|
||||
}
|
||||
|
||||
|
||||
@ -127,6 +132,9 @@ def patch_fixtures_with_data(vehicle_type: str):
|
||||
), patch(
|
||||
"renault_api.renault_vehicle.RenaultVehicle.get_lock_status",
|
||||
return_value=mock_fixtures["lock_status"],
|
||||
), patch(
|
||||
"renault_api.renault_vehicle.RenaultVehicle.get_res_state",
|
||||
return_value=mock_fixtures["res_state"],
|
||||
):
|
||||
yield
|
||||
|
||||
@ -154,6 +162,9 @@ def patch_fixtures_with_no_data():
|
||||
), patch(
|
||||
"renault_api.renault_vehicle.RenaultVehicle.get_lock_status",
|
||||
return_value=mock_fixtures["lock_status"],
|
||||
), patch(
|
||||
"renault_api.renault_vehicle.RenaultVehicle.get_res_state",
|
||||
return_value=mock_fixtures["res_state"],
|
||||
):
|
||||
yield
|
||||
|
||||
@ -179,6 +190,9 @@ def _patch_fixtures_with_side_effect(side_effect: Any):
|
||||
), patch(
|
||||
"renault_api.renault_vehicle.RenaultVehicle.get_lock_status",
|
||||
side_effect=side_effect,
|
||||
), patch(
|
||||
"renault_api.renault_vehicle.RenaultVehicle.get_res_state",
|
||||
side_effect=side_effect,
|
||||
):
|
||||
yield
|
||||
|
||||
|
@ -229,6 +229,17 @@ MOCK_VEHICLES = {
|
||||
ATTR_STATE: "plugged",
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_plug_state",
|
||||
},
|
||||
{
|
||||
ATTR_ENTITY_ID: "sensor.reg_number_remote_engine_start",
|
||||
ATTR_STATE: STATE_UNKNOWN,
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_res_state",
|
||||
},
|
||||
{
|
||||
ATTR_DEFAULT_DISABLED: True,
|
||||
ATTR_ENTITY_ID: "sensor.reg_number_remote_engine_start_code",
|
||||
ATTR_STATE: STATE_UNKNOWN,
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_res_state_code",
|
||||
},
|
||||
],
|
||||
},
|
||||
"zoe_50": {
|
||||
@ -246,6 +257,7 @@ MOCK_VEHICLES = {
|
||||
"hvac_status": "hvac_status.2.json",
|
||||
"location": "location.json",
|
||||
"lock_status": "lock_status.1.json",
|
||||
"res_state": "res_state.1.json",
|
||||
},
|
||||
Platform.BINARY_SENSOR: [
|
||||
{
|
||||
@ -441,6 +453,17 @@ MOCK_VEHICLES = {
|
||||
ATTR_STATE: "2020-02-18T16:58:38+00:00",
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_location_last_activity",
|
||||
},
|
||||
{
|
||||
ATTR_ENTITY_ID: "sensor.reg_number_remote_engine_start",
|
||||
ATTR_STATE: "Stopped, ready for RES",
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_res_state",
|
||||
},
|
||||
{
|
||||
ATTR_DEFAULT_DISABLED: True,
|
||||
ATTR_ENTITY_ID: "sensor.reg_number_remote_engine_start_code",
|
||||
ATTR_STATE: "10",
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_res_state_code",
|
||||
},
|
||||
],
|
||||
},
|
||||
"captur_phev": {
|
||||
@ -457,6 +480,7 @@ MOCK_VEHICLES = {
|
||||
"cockpit": "cockpit_fuel.json",
|
||||
"location": "location.json",
|
||||
"lock_status": "lock_status.1.json",
|
||||
"res_state": "res_state.1.json",
|
||||
},
|
||||
Platform.BINARY_SENSOR: [
|
||||
{
|
||||
@ -641,6 +665,17 @@ MOCK_VEHICLES = {
|
||||
ATTR_STATE: "2020-02-18T16:58:38+00:00",
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_location_last_activity",
|
||||
},
|
||||
{
|
||||
ATTR_ENTITY_ID: "sensor.reg_number_remote_engine_start",
|
||||
ATTR_STATE: "Stopped, ready for RES",
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_res_state",
|
||||
},
|
||||
{
|
||||
ATTR_DEFAULT_DISABLED: True,
|
||||
ATTR_ENTITY_ID: "sensor.reg_number_remote_engine_start_code",
|
||||
ATTR_STATE: "10",
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_res_state_code",
|
||||
},
|
||||
],
|
||||
},
|
||||
"captur_fuel": {
|
||||
@ -655,6 +690,7 @@ MOCK_VEHICLES = {
|
||||
"cockpit": "cockpit_fuel.json",
|
||||
"location": "location.json",
|
||||
"lock_status": "lock_status.1.json",
|
||||
"res_state": "res_state.1.json",
|
||||
},
|
||||
Platform.BINARY_SENSOR: [
|
||||
{
|
||||
@ -743,6 +779,17 @@ MOCK_VEHICLES = {
|
||||
ATTR_STATE: "2020-02-18T16:58:38+00:00",
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_location_last_activity",
|
||||
},
|
||||
{
|
||||
ATTR_ENTITY_ID: "sensor.reg_number_remote_engine_start",
|
||||
ATTR_STATE: "Stopped, ready for RES",
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_res_state",
|
||||
},
|
||||
{
|
||||
ATTR_DEFAULT_DISABLED: True,
|
||||
ATTR_ENTITY_ID: "sensor.reg_number_remote_engine_start_code",
|
||||
ATTR_STATE: "10",
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_res_state_code",
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
10
tests/components/renault/fixtures/res_state.1.json
Normal file
10
tests/components/renault/fixtures/res_state.1.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"data": {
|
||||
"type": "ResState",
|
||||
"id": "VF1AAAAA555777999",
|
||||
"attributes": {
|
||||
"details": "Stopped, ready for RES",
|
||||
"code": "10"
|
||||
}
|
||||
}
|
||||
}
|
@ -157,6 +157,7 @@ VEHICLE_DATA = {
|
||||
"externalTemperature": 8.0,
|
||||
"hvacStatus": "off",
|
||||
},
|
||||
"res_state": {},
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user