Skip to content

Commit

Permalink
* Upped the polling time
Browse files Browse the repository at this point in the history
* Changed ID car check
* Bumped weconnect to 0.37
* Added new sensors
* Fixed bug where changing target temp started climate control
  • Loading branch information
mitch-dc committed Feb 25, 2022
1 parent 8fdfa04 commit 28255f6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
12 changes: 6 additions & 6 deletions custom_components/volkswagen_we_connect_id/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from datetime import timedelta
import logging
from tarfile import SUPPORTED_TYPES

from weconnect import weconnect
from weconnect.elements.control_operation import ControlOperation
Expand All @@ -23,6 +24,8 @@

_LOGGER = logging.getLogger(__name__)

SUPPORTED_VEHICLES = ["ID.3", "ID.4", "ID.5"]


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Volkswagen We Connect ID from a config entry."""
Expand All @@ -45,10 +48,7 @@ async def async_update_data():
vehicles = []

for vin, vehicle in _we_connect.vehicles.items():
car_type = get_object_value(
vehicle.domains["fuelStatus"]["rangeStatus"].carType
)
if car_type == RangeStatus.CarType.ELECTRIC.value:
if vehicle.model.value in SUPPORTED_VEHICLES:
vehicles.append(vehicle)

hass.data[DOMAIN][entry.entry_id + "_vehicles"] = vehicles
Expand All @@ -59,7 +59,7 @@ async def async_update_data():
_LOGGER,
name=DOMAIN,
update_method=async_update_data,
update_interval=timedelta(seconds=10),
update_interval=timedelta(seconds=30),
)

hass.data.setdefault(DOMAIN, {})
Expand Down Expand Up @@ -264,7 +264,7 @@ def set_climatisation(
try:
vehicle.domains["climatisation"][
"climatisationSettings"
].targetTemperature_C.value = target_temperature
].targetTemperature_C.value = float(target_temperature)
_LOGGER.info("Sended target temperature call to the car")
except Exception as exc:
_LOGGER.error("Failed to send request to car - %s", exc)
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://github.com/mitch-dc/volkswagen_we_connect_id",
"requirements": ["weconnect==0.37.0.dev4", "ascii_magic==1.6"],
"requirements": ["weconnect==0.37.0", "ascii_magic==1.6"],
"ssdp": [],
"zeroconf": [],
"homekit": {},
Expand Down
14 changes: 6 additions & 8 deletions custom_components/volkswagen_we_connect_id/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,16 @@ def __init__(
@property
def value(self) -> float:
"""Return the current value."""
targetTemp = self.data.domains["climatisation"][
"climatisationSettings"
].targetTemperature_C.value

return float(
get_object_value(
self.data.domains["climatisation"][
"climatisationSettings"
].targetTemperature_C.value,
)
)
return float(targetTemp)

async def async_set_value(self, value: float) -> None:
"""Update the current value."""
if value > 10:
self._attr_value = value
await self.hass.async_add_executor_job(
set_climatisation, self.data.vin.value, self._we_connect, "start", value
set_climatisation, self.data.vin.value, self._we_connect, "none", value
)

0 comments on commit 28255f6

Please sign in to comment.