Skip to content

Commit

Permalink
* bump weconnect to 0.32.1
Browse files Browse the repository at this point in the history
* added service for setting max charge speed for AC
* added target temp in farenheit
  • Loading branch information
mitch-dc committed Jan 18, 2022
1 parent 0cef65c commit df6bcf7
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 5 deletions.
52 changes: 49 additions & 3 deletions custom_components/volkswagen_we_connect_id/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,61 @@ async def volkswagen_id_set_target_soc(call: ServiceCall) -> None:
target_soc,
)

# Register our service with Home Assistant.
@callback
async def volkswagen_id_set_ac_charge_speed(call: ServiceCall) -> None:

vin = call.data["vin"]
if "maximum_reduced" in call.data:
await hass.async_add_executor_job(
set_ac_charging_speed,
vin,
api,
call.data["maximum_reduced"],
)

# Register our services with Home Assistant.
hass.services.async_register(
DOMAIN, "volkswagen_id_set_climatisation", volkswagen_id_set_climatisation
)

# Register our service with Home Assistant.
hass.services.async_register(
DOMAIN, "volkswagen_id_set_target_soc", volkswagen_id_set_target_soc
)
hass.services.async_register(
DOMAIN, "volkswagen_id_set_ac_charge_speed", volkswagen_id_set_ac_charge_speed
)

return True


def set_ac_charging_speed(
callDataVIN, api: weconnect.WeConnect, charging_speed: float
) -> bool:
"""Set charging speed in your volkswagen."""

api.login()
api.update()

for vin, vehicle in api.vehicles.items():
if vin == callDataVIN:
if (
charging_speed
!= vehicle.domains["charging"][
"chargingSettings"
].maxChargeCurrentAC.value
):
try:
vehicle.domains["charging"][
"chargingSettings"
].maxChargeCurrentAC.value = charging_speed
_LOGGER.info("Sended charging speed call to the car")
except Exception as exc:
_LOGGER.error(
exc.args[0]
+ " - Restart/start the car to reset the rate_limit."
)
return False

api.update()

return True

Expand Down
2 changes: 1 addition & 1 deletion custom_components/volkswagen_we_connect_id/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Volkswagen We Connect ID",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/volkswagen_we_connect_id",
"requirements": ["weconnect==0.30.4", "ascii_magic==1.6"],
"requirements": ["weconnect==0.32.1", "ascii_magic==1.6"],
"ssdp": [],
"zeroconf": [],
"homekit": {},
Expand Down
10 changes: 9 additions & 1 deletion custom_components/volkswagen_we_connect_id/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
POWER_KILO_WATT,
SPEED_KILOMETERS_PER_HOUR,
TEMP_CELSIUS,
TEMP_FAHRENHEIT,
TIME_MINUTES,
)
from homeassistant.helpers.typing import StateType
Expand All @@ -37,12 +38,19 @@
CLIMASETTINGS_SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key="targetTemperature_C",
name="Target Temperature",
name="Target Temperature C",
device_class=DEVICE_CLASS_TEMPERATURE,
native_unit_of_measurement=TEMP_CELSIUS,
),
SensorEntityDescription(
key="targetTemperature_F",
name="Target Temperature F",
device_class=DEVICE_CLASS_TEMPERATURE,
native_unit_of_measurement=TEMP_FAHRENHEIT,
),
)


CHARGESTATUS_SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key="chargingState",
Expand Down

0 comments on commit df6bcf7

Please sign in to comment.