diff --git a/README.md b/README.md index 88ae7c0..95e0b75 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ If you find any bugs or would like to request a feature, please open an issue. This integration has been tested with the following vehicles: * Nissan Leaf Tekna (2022) - UK [@dan-r] * Nissan Qashqai (2021) - EU +* Nissan Ariya - EU ### North America The API used in North America is completely separate to Europe and it appears that Nissan USA are [a lot more hostile](https://tobis.dk/blog/the-farce-of-nissanconnect-north-america/) towards third-party access. Any future US support would rely on library support (such as [dartnissanconnectna](https://gitlab.com/tobiaswkjeldsen/dartnissanconnectna)) or someone in North America maintaining that side of things. If you're interested, get in touch! @@ -74,3 +75,4 @@ This integration exposes the following entities. Please note that entities will * Update Data * Flash Lights * Honk Horn + * Start Charge diff --git a/custom_components/nissan_connect/button.py b/custom_components/nissan_connect/button.py index 86ee9bb..d86e86f 100644 --- a/custom_components/nissan_connect/button.py +++ b/custom_components/nissan_connect/button.py @@ -24,7 +24,8 @@ async def async_setup_entry(hass, config, async_add_entities): HornLightsButtons(coordinator, data[vehicle], "flash_lights", "mdi:car-light-high", "lights"), HornLightsButtons(coordinator, data[vehicle], "honk_horn", "mdi:bullhorn", "horn_lights") ] - + if Feature.CHARGING_START in data[vehicle].features: + entities.append(ChargeControlButtons(coordinator, data[vehicle], "charge_start", "mdi:play", "start")) async_add_entities(entities, update_before_add=True) @@ -59,3 +60,18 @@ def icon(self): def press(self): self.vehicle.control_horn_lights('start', self._action) + +class ChargeControlButtons(KamereonEntity, ButtonEntity): + def __init__(self, coordinator, vehicle, translation_key, icon, action): + self._attr_translation_key = translation_key + self._icon = icon + self._action = action + KamereonEntity.__init__(self, coordinator, vehicle) + + @property + def icon(self): + return self._icon + + def press(self): + self.vehicle.control_charging(self._action) + diff --git a/custom_components/nissan_connect/kamereon.py b/custom_components/nissan_connect/kamereon.py index 24244a5..eebd0d4 100644 --- a/custom_components/nissan_connect/kamereon.py +++ b/custom_components/nissan_connect/kamereon.py @@ -1228,10 +1228,10 @@ def fetch_trip_histories(self, period: Period=None, start: datetime.date=None, e if period is None: period = Period.DAILY if start is None and end is None and period == Period.MONTHLY: - end = datetime.date.today() + end = datetime.datetime.utcnow().date() start = end.replace(day=1) elif start is None: - start = datetime.date.today() + start = datetime.datetime.utcnow().date() if end is None: end = start resp = self._get( diff --git a/custom_components/nissan_connect/translations/de.json b/custom_components/nissan_connect/translations/de.json index e5a188d..0fe0a01 100644 --- a/custom_components/nissan_connect/translations/de.json +++ b/custom_components/nissan_connect/translations/de.json @@ -73,6 +73,9 @@ }, "update_data": { "name": "Daten aktualisieren" + }, + "charge_start": { + "name": "Starten Sie den Ladevorgang" } }, "climate": { diff --git a/custom_components/nissan_connect/translations/en.json b/custom_components/nissan_connect/translations/en.json index 196c461..5ab62a1 100644 --- a/custom_components/nissan_connect/translations/en.json +++ b/custom_components/nissan_connect/translations/en.json @@ -73,6 +73,9 @@ }, "update_data": { "name": "Update Data" + }, + "charge_start": { + "name": "Start Charge" } }, "climate": { diff --git a/custom_components/nissan_connect/translations/fr.json b/custom_components/nissan_connect/translations/fr.json index 98624ca..41352d8 100644 --- a/custom_components/nissan_connect/translations/fr.json +++ b/custom_components/nissan_connect/translations/fr.json @@ -73,6 +73,9 @@ }, "update_data": { "name": "Mettre à jour les données" + }, + "charge_start": { + "name": "Démarrer la recharge" } }, "climate": { diff --git a/custom_components/nissan_connect/translations/it.json b/custom_components/nissan_connect/translations/it.json index 85c92e0..d6c06a9 100644 --- a/custom_components/nissan_connect/translations/it.json +++ b/custom_components/nissan_connect/translations/it.json @@ -73,6 +73,9 @@ }, "update_data": { "name": "Aggiorna dati" + }, + "charge_start": { + "name": "Avvia carica" } }, "climate": {