diff --git a/core b/core new file mode 160000 index 0000000..5cdb651 --- /dev/null +++ b/core @@ -0,0 +1 @@ +Subproject commit 5cdb65100f4c5811fcc5ab1313091be877628575 diff --git a/custom_components/husqvarna_automower/binary_sensor.py b/custom_components/husqvarna_automower/binary_sensor.py index 08b1226..0de79c6 100644 --- a/custom_components/husqvarna_automower/binary_sensor.py +++ b/custom_components/husqvarna_automower/binary_sensor.py @@ -39,7 +39,7 @@ class AutomowerBatteryChargingBinarySensor(BinarySensorEntity, AutomowerEntity): _attr_entity_registry_enabled_default = False _attr_device_class = BinarySensorDeviceClass.BATTERY_CHARGING - _attr_name = "Battery charging" + _attr_translation_key = "battery_charging" def __init__(self, session, idx): """Initialize AutomowerBatteryChargingBinarySensor.""" @@ -59,7 +59,7 @@ class AutomowerLeavingDockBinarySensor(BinarySensorEntity, AutomowerEntity): """Defining the AutomowerProblemSensor Entity.""" _attr_entity_registry_enabled_default = False - _attr_name = "Leaving dock" + _attr_translation_key = "leaving_dock" def __init__(self, session, idx) -> None: """Initialize AutomowerLeavingDockBinarySensor.""" @@ -80,7 +80,7 @@ class AutomowerErrorBinarySensor(BinarySensorEntity, AutomowerEntity): _attr_entity_registry_enabled_default: bool = False _attr_device_class: BinarySensorDeviceClass = BinarySensorDeviceClass.PROBLEM - _attr_name = "Error" + _attr_translation_key = "error" def __init__(self, session, idx): """Initialize AutomowerErrorBinarySensor.""" diff --git a/custom_components/husqvarna_automower/camera.py b/custom_components/husqvarna_automower/camera.py index 44cbba6..3dabbdf 100644 --- a/custom_components/husqvarna_automower/camera.py +++ b/custom_components/husqvarna_automower/camera.py @@ -9,7 +9,7 @@ import numpy as np from geopy.distance import distance, geodesic -from homeassistant.components.camera import SUPPORT_ON_OFF, Camera +from homeassistant.components.camera import Camera, CameraEntityFeature from homeassistant.config_entries import ConfigEntry from homeassistant.const import Platform from homeassistant.core import HomeAssistant @@ -61,8 +61,7 @@ class AutomowerCamera(HusqvarnaAutomowerStateMixin, Camera, AutomowerEntity): """Representation of the AutomowerCamera element.""" _attr_frame_interval: float = 300 - _attr_name = "Map" - _attr_translation_key = "quirk" + _attr_translation_key = "mower_cam" def __init__(self, session, idx, entry) -> None: """Initialize AutomowerCamera.""" @@ -126,7 +125,7 @@ def __init__(self, session, idx, entry) -> None: @property def model(self) -> str: """Return the mower model.""" - return self._model + return self.model_name async def async_camera_image( self, width: Optional[int] = None, height: Optional[int] = None @@ -210,7 +209,7 @@ def turn_off(self): @property def supported_features(self) -> int: """Show supported features.""" - return SUPPORT_ON_OFF + return CameraEntityFeature.ON_OFF def _find_image_scale(self): """Find the scale ration in m/px and center of image.""" diff --git a/custom_components/husqvarna_automower/const.py b/custom_components/husqvarna_automower/const.py index 2bd7f54..ac01107 100644 --- a/custom_components/husqvarna_automower/const.py +++ b/custom_components/husqvarna_automower/const.py @@ -225,7 +225,7 @@ } # Headlight modes -HEADLIGHTMODES = ["ALWAYS_ON", "ALWAYS_OFF", "EVENING_ONLY", "EVENING_AND_NIGHT"] +HEADLIGHTMODES = ["always_on", "always_off", "evening_only", "evening_and_night"] # Weekdays WEEKDAYS = ( @@ -278,28 +278,28 @@ ) MWR_STATE_TO_STATUS = { - "UNKNOWN": "Unknown", - "NOT_APPLICABLE": "Not applicable", - "PAUSED": "Paused", - "WAIT_UPDATING": "Updating", - "WAIT_POWER_UP": "Powering up", - "OFF": "Off", - "STOPPED": "Stopped", + "UNKNOWN": "unknown", + "NOT_APPLICABLE": "not_applicable", + "PAUSED": "paused", + "WAIT_UPDATING": "updating", + "WAIT_POWER_UP": "powering_up", + "OFF": "off", + "STOPPED": "stopped", } MWR_ACTIVITY_TO_STATUS = { - "UNKNOWN": "Unknown", - "NOT_APPLICABLE": "Not applicable", - "MOWING": "Mowing", - "GOING_HOME": "Going to charging station", - "LEAVING": "Leaving charging station", - "PARKED_IN_CS": "Parked", - "STOPPED_IN_GARDEN": "Stopped", + "UNKNOWN": "unknown", + "NOT_APPLICABLE": "not_applicable", + "MOWING": "mowing", + "GOING_HOME": "going_to_charging_station", + "LEAVING": "leaving_charging_station", + "PARKED_IN_CS": "parked", + "STOPPED_IN_GARDEN": "stopped", } MWR_RES_REASON_TO_STATUS = { - "PARK_OVERRIDE": "Park override", - "SENSOR": "Weather timer", - "DAILY_LIMIT": "Daily limit", - "NOT_APPLICABLE": "Parked until further notice", + "PARK_OVERRIDE": "park_override", + "SENSOR": "weather_timer", + "DAILY_LIMIT": "daily_limit", + "NOT_APPLICABLE": "parked_until_further_notice", } diff --git a/custom_components/husqvarna_automower/entity.py b/custom_components/husqvarna_automower/entity.py index 9a39af0..07199b6 100644 --- a/custom_components/husqvarna_automower/entity.py +++ b/custom_components/husqvarna_automower/entity.py @@ -29,7 +29,7 @@ def __init__(self, coordinator, idx) -> None: mower_attributes = self.get_mower_attributes() self.mower_id = self.mower["id"] self.mower_name = mower_attributes["system"]["name"] - self._model = mower_attributes["system"]["model"] + self.model_name = mower_attributes["system"]["model"] self._available = self.get_mower_attributes()["metadata"]["connected"] @@ -67,7 +67,7 @@ def device_info(self) -> DeviceInfo: identifiers={(DOMAIN, self.mower_id)}, name=self.mower_name, manufacturer="Husqvarna", - model=self._model, + model=self.model_name, configuration_url=HUSQVARNA_URL, suggested_area="Garden", ) diff --git a/custom_components/husqvarna_automower/number.py b/custom_components/husqvarna_automower/number.py index c8e45a2..2a1e58a 100644 --- a/custom_components/husqvarna_automower/number.py +++ b/custom_components/husqvarna_automower/number.py @@ -42,14 +42,14 @@ async def async_setup_entry( NUMBER_SENSOR_TYPES: tuple[NumberEntityDescription, ...] = ( NumberEntityDescription( key="Park", - name="Park for", + translation_key="park_for", icon="mdi:clock-outline", entity_registry_enabled_default=True, native_unit_of_measurement=TIME_MINUTES, ), NumberEntityDescription( key="Start", - name="Mow for", + translation_key="mow_for", icon="mdi:clock-outline", entity_registry_enabled_default=True, native_unit_of_measurement=TIME_MINUTES, @@ -64,7 +64,7 @@ class AutomowerNumber(NumberEntity, AutomowerEntity): _attr_icon = "mdi:grass" _attr_native_min_value = 1 _attr_native_max_value = 9 - _attr_name = "Cutting height" + _attr_translation_key = "cutting_height" def __init__(self, session, idx): """Initialize AutomowerNumber.""" @@ -112,7 +112,6 @@ def __init__(self, session, idx, description: NumberEntityDescription): super().__init__(session, idx) self.description = description self.entity_description = description - self._attr_name = description.name self._attr_unique_id = f"{self.mower_id}_{description.key}" @property diff --git a/custom_components/husqvarna_automower/select.py b/custom_components/husqvarna_automower/select.py index 5e9a945..20e8ead 100644 --- a/custom_components/husqvarna_automower/select.py +++ b/custom_components/husqvarna_automower/select.py @@ -36,7 +36,7 @@ class AutomowerSelect(SelectEntity, AutomowerEntity): _attr_options = HEADLIGHTMODES _attr_icon = "mdi:car-light-high" _attr_entity_category = EntityCategory.CONFIG - _attr_name = "Headlight mode" + _attr_translation_key = "headlight_mode" def __init__(self, session, idx): """Initialize AutomowerSelect.""" @@ -53,7 +53,7 @@ def available(self) -> bool: def current_option(self) -> str: """Return a the current option for the entity.""" mower_attributes = AutomowerEntity.get_mower_attributes(self) - return mower_attributes["headlight"]["mode"] + return mower_attributes["headlight"]["mode"].lower() async def async_select_option(self, option: str) -> None: """Change the selected option.""" @@ -61,7 +61,7 @@ async def async_select_option(self, option: str) -> None: string = { "data": { "type": "settings", - "attributes": {"headlight": {"mode": option}}, + "attributes": {"headlight": {"mode": option.upper()}}, } } payload = json.dumps(string) diff --git a/custom_components/husqvarna_automower/sensor.py b/custom_components/husqvarna_automower/sensor.py index 828c643..093aea4 100644 --- a/custom_components/husqvarna_automower/sensor.py +++ b/custom_components/husqvarna_automower/sensor.py @@ -94,7 +94,7 @@ def problem_list() -> list: SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( AutomowerSensorEntityDescription( key="cuttingBladeUsageTime", - name="Cutting blade usage time", + translation_key="cutting_blade_usage_time", icon="mdi:clock-outline", entity_registry_enabled_default=True, entity_category=EntityCategory.DIAGNOSTIC, @@ -106,7 +106,7 @@ def problem_list() -> list: ), AutomowerSensorEntityDescription( key="totalChargingTime", - name="Total charging time", + translation_key="total_charging_time", icon="mdi:clock-outline", entity_registry_enabled_default=True, entity_category=EntityCategory.DIAGNOSTIC, @@ -118,7 +118,7 @@ def problem_list() -> list: ), AutomowerSensorEntityDescription( key="totalCuttingTime", - name="Total cutting time", + translation_key="total_cutting_time", icon="mdi:clock-outline", entity_registry_enabled_default=False, entity_category=EntityCategory.DIAGNOSTIC, @@ -130,7 +130,7 @@ def problem_list() -> list: ), AutomowerSensorEntityDescription( key="totalRunningTime", - name="Total running time", + translation_key="total_running_time", icon="mdi:clock-outline", entity_registry_enabled_default=True, entity_category=EntityCategory.DIAGNOSTIC, @@ -142,7 +142,7 @@ def problem_list() -> list: ), AutomowerSensorEntityDescription( key="totalSearchingTime", - name="Total searching time", + translation_key="total_searching_time", icon="mdi:clock-outline", entity_registry_enabled_default=False, entity_category=EntityCategory.DIAGNOSTIC, @@ -154,7 +154,7 @@ def problem_list() -> list: ), AutomowerSensorEntityDescription( key="numberOfChargingCycles", - name="Number of charging cycles", + translation_key="number_of_charging_cycles", icon="mdi:battery-sync-outline", entity_registry_enabled_default=True, entity_category=EntityCategory.DIAGNOSTIC, @@ -164,7 +164,7 @@ def problem_list() -> list: ), AutomowerSensorEntityDescription( key="numberOfCollisions", - name="Number of collisions", + translation_key="number_of_collisions", icon="mdi:counter", entity_registry_enabled_default=False, entity_category=EntityCategory.DIAGNOSTIC, @@ -174,7 +174,7 @@ def problem_list() -> list: ), AutomowerSensorEntityDescription( key="totalSearchingTime_percentage", - name="Searching time percent", + translation_key="searching_time_percent", icon="mdi:percent", entity_registry_enabled_default=True, entity_category=EntityCategory.DIAGNOSTIC, @@ -188,7 +188,7 @@ def problem_list() -> list: ), AutomowerSensorEntityDescription( key="totalCuttingTime_percentage", - name="Cutting time percent", + translation_key="cutting_time_percent", icon="mdi:percent", entity_registry_enabled_default=True, entity_category=EntityCategory.DIAGNOSTIC, @@ -202,7 +202,7 @@ def problem_list() -> list: ), AutomowerSensorEntityDescription( key="battery_level", - name="Battery level", + translation_key="battery_level", entity_registry_enabled_default=True, state_class=SensorStateClass.MEASUREMENT, device_class=SensorDeviceClass.BATTERY, @@ -215,7 +215,7 @@ def problem_list() -> list: ), AutomowerSensorEntityDescription( key="next_start", - name="Next start", + translation_key="next_start", entity_registry_enabled_default=True, device_class=SensorDeviceClass.TIMESTAMP, value_fn=lambda data: AutomowerEntity.datetime_object( @@ -225,21 +225,19 @@ def problem_list() -> list: ), AutomowerSensorEntityDescription( key="mode", - name="Mode", + translation_key="mode_list", entity_registry_enabled_default=False, device_class=SensorDeviceClass.ENUM, options=["main_area", "secondary_area", "home", "demo", "unknown"], - translation_key="mode_list", value_fn=lambda data: data["mower"]["mode"].lower(), available_fn=lambda data: True, ), AutomowerSensorEntityDescription( key="problem_sensor", - name="Problem Sensor", + translation_key="problem_list", entity_registry_enabled_default=False, device_class=SensorDeviceClass.ENUM, options=problem_list(), - translation_key="problem_list", value_fn=lambda data: None if get_problem(data) is None else get_problem(data).lower(), @@ -247,7 +245,7 @@ def problem_list() -> list: ), AutomowerSensorEntityDescription( key="cuttingHeight", - name="Cutting height", + translation_key="cutting_height", entity_registry_enabled_default=True, icon="mdi:grass", state_class=SensorStateClass.MEASUREMENT, @@ -365,7 +363,6 @@ def __init__( """Set up AutomowerSensors.""" super().__init__(session, idx) self.entity_description = description - self._attr_name = description.name self._attr_unique_id = f"{self.mower_id}_{description.key}" @property diff --git a/custom_components/husqvarna_automower/translations/da.json b/custom_components/husqvarna_automower/translations/da.json index 28378db..dba8f64 100644 --- a/custom_components/husqvarna_automower/translations/da.json +++ b/custom_components/husqvarna_automower/translations/da.json @@ -27,7 +27,6 @@ "gps_bottom_right": "GPS koordinater for det nederste højre hjørne af billedet", "mower_img_path": "Filsti til billede af plæneklipper", "map_img_path": "Filsti til billede af kortet" - }, "description": "Kamera indstillinger", "title": "Husqvarna Automower indstillinger" @@ -72,14 +71,14 @@ } }, "vacuum": { - "quirk": { + "mower": { "state": { "cleaning": "Slår græs" } } }, "camera": { - "quirk": { + "mower": { "state": { "cleaning": "Slår græs" } diff --git a/custom_components/husqvarna_automower/translations/de.json b/custom_components/husqvarna_automower/translations/de.json index 185fcd4..7dcbbe5 100644 --- a/custom_components/husqvarna_automower/translations/de.json +++ b/custom_components/husqvarna_automower/translations/de.json @@ -17,48 +17,59 @@ "can_reach_server": "Husqvarna Token Server erreichbar" } }, - "entity": { - "sensor": { - "problem_list": { - "state": { - "off": "Aus", - "unknown": "Unbekannt", - "stopped": "Angehalten", - "stopped_in_garden": "Im Garten angehalten", - "not_applicable": "Nicht anwendbar", - "none": "Nichts", - "week_schedule": "Wochenplaner", - "park_override": "Parken erzwungen", - "sensor": "Wetter timer", - "daily_limit": "Tägliches limit", - "fota": "FOTA", - "frost": "Frost", - "parked_until_further_notice": "Bis auf weiters geparkt" - } - }, - "mode_list":{ - "state": { - "main_area": "Hauptbereich", - "secondary_area": "Zweitbereich", - "home": "In der Ladestation", - "demo": "Demo", - "unknown": "Unbekannt" - } - } - }, + "entity": { + "select": { + "headlight_mode": { + "name": "Schweinwerfer Zeitplan", + "state": { + "always_on": "Immer an", + "always_off": "Immer aus", + "evening_only": "Nur abends", + "evening_and_night": "Abends und nachts" + } + } + }, + "sensor": { + "problem_list": { + "state": { + "off": "Aus", + "unknown": "Unbekannt", + "stopped": "Angehalten", + "stopped_in_garden": "Im Garten angehalten", + "not_applicable": "Nicht anwendbar", + "none": "Nichts", + "week_schedule": "Wochenplaner", + "park_override": "Parken erzwungen", + "sensor": "Wetter timer", + "daily_limit": "Tägliches limit", + "fota": "FOTA", + "frost": "Frost", + "parked_until_further_notice": "Bis auf weiters geparkt" + } + }, + "mode_list": { + "state": { + "main_area": "Hauptbereich", + "secondary_area": "Zweitbereich", + "home": "In der Ladestation", + "demo": "Demo", + "unknown": "Unbekannt" + } + } + }, "vacuum": { - "quirk": { + "mower": { "state": { "cleaning": "Mähen" } } }, "camera": { - "quirk": { + "mower": { "state": { "cleaning": "Mähen" } } } - } + } } diff --git a/custom_components/husqvarna_automower/translations/en.json b/custom_components/husqvarna_automower/translations/en.json index 84a6c91..59e9158 100644 --- a/custom_components/husqvarna_automower/translations/en.json +++ b/custom_components/husqvarna_automower/translations/en.json @@ -1,18 +1,18 @@ { - "config": { - "step": { - "reauth_confirm": { - "description": "The Husqvarna Automower integration needs to re-authenticate your account.", - "title": "Reauthenticate Integration" - } - }, - "abort": { - "missing_configuration": "The component is not configured. Please follow the documentation.", - "reauth_successful": "The reauthentication was successful", - "single_instance_allowed": "Only a single configuration of Husqvarna Automower is allowed." - } - }, - "options": { + "config": { + "step": { + "reauth_confirm": { + "description": "The Husqvarna Automower integration needs to re-authenticate with Husqvarna", + "title": "Reauthenticate Integration" + } + }, + "abort": { + "missing_configuration": "The component is not configured. Please follow the documentation.", + "reauth_successful": "The reauthentication was successful", + "single_instance_allowed": "Only a single configuration of Husqvarna Automower is allowed." + } + }, + "options": { "step": { "select": { "menu_options": { @@ -60,61 +60,94 @@ "need_one_mower": "Need at least one mower for a zone." } }, - "system_health": { - "info": { - "can_reach_server": "Reach Husqvarna Token Server" - } - }, - "application_credentials": { - "description": "Create an account on [Husqvarna developers portal]({oauth_creds_url}). Connect The Authentication API and Automower Connect API. As redirect-URI set https://my.home-assistant.io/redirect/oauth. If you haven't set up My HomeAssistant already. Enter this URL for your instance {redirect_uri}" - }, - "entity": { - "sensor": { - "problem_list": { - "state": { - "off": "Off", - "unknown": "Unknown", - "stopped": "Stopped", - "stopped_in_garden": "Stopped in garden", - "not_applicable": "Not applicable", - "none": "None", - "week_schedule": "Week schedule", - "park_override": "Park override", - "sensor": "Weather timer", - "daily_limit": "Daily limit", - "fota": "Fota", - "frost": "Frost" - } - }, - "mode_list": { - "state": { - "main_area": "Main area", - "secondary_area": "Secondary area", - "home": "Home", - "demo": "Demo", - "unknown": "Unknown" - } - } + "system_health": { + "info": { + "can_reach_server": "Reach Husqvarna Token server" + } + }, + "application_credentials": { + "description": "Create an account on [Husqvarna developers portal]({oauth_creds_url}). Connect The Authentication API and Automower Connect API. As redirect-URI set https://my.home-assistant.io/redirect/oauth. If you haven't set up My HomeAssistant already. Enter this URL for your instance {redirect_uri}" + }, + "entity": { + "sensor": { + "problem_list": { + "state": { + "off": "Off", + "unknown": "Unknown", + "stopped": "Stopped", + "stopped_in_garden": "Stopped in garden", + "not_applicable": "Not applicable", + "none": "None", + "week_schedule": "Week schedule", + "park_override": "Park override", + "sensor": "Weather timer", + "daily_limit": "Daily limit", + "fota": "Fota", + "frost": "Frost", + "parked_until_further_notice": "Parked until further notice" + } + }, + "mode_list": { + "state": { + "main_area": "Main area", + "secondary_area": "Secondary area", + "home": "Home", + "demo": "Demo", + "unknown": "Unknown" + } + } }, "vacuum": { - "quirk": { + "mower": { "state": { "cleaning": "Mowing" + }, + "state_attributes": { + "status": { + "name": "Status", + "state": { + "cleaning": "Mowing", + "off": "Off", + "unknown": "Unknown", + "stopped": "Stopped", + "not_applicable": "Not applicable", + "paused": "Paused", + "going_to_charging_station": "Going to charging station", + "leaving_charging_station": "Leaving charging station", + "parked": "Parked", + "park_override": "Park override", + "daily_limit": "Daily limit", + "fota": "Fota", + "updating": "Updating", + "powering_up": "Powering up", + "weather_timer": "Weather timer", + "parked_until_further_notice": "Parked until further notice" + } + }, + "action": { + "name": "Action", + "state": { + "force_mow": "Force mowing", + "not_active": "Not active", + "unknown": "Unknown" + } + } } } }, "camera": { - "quirk": { + "mower_cam": { + "name": "Map", "state": { - "cleaning": "Mowing", - "docked": "Docked", - "error": "Error", - "idle": "[%key:common::state::idle%]", - "off": "[%key:common::state::off%]", - "on": "[%key:common::state::on%]", - "paused": "[%key:common::state::paused%]", - "returning": "Returning to dock" - } + "cleaning": "Mowing", + "docked": "Docked", + "error": "Error", + "idle": "Idle", + "off": "Off", + "on": "On", + "paused": "Paused", + "returning": "Returning to dock" + } } } }, diff --git a/custom_components/husqvarna_automower/translations/es.json b/custom_components/husqvarna_automower/translations/es.json index c768ac5..92c8ec7 100644 --- a/custom_components/husqvarna_automower/translations/es.json +++ b/custom_components/husqvarna_automower/translations/es.json @@ -27,7 +27,6 @@ "gps_bottom_right": "Coordenadas GPS Coordinates de la esquina inferior derecha de la imagen", "mower_img_path": "Ruta a la localizacion de la imagen del cortacesped", "map_img_path": "Ruta a la localizacion de la imagen del mapa" - }, "description": "Ajustes de la cámara", "title": "Opciones de Husqvarna Automower" @@ -60,7 +59,7 @@ "frost": "Hielo" } }, - "mode_list":{ + "mode_list": { "state": { "main_area": "Área principal", "secondary_area": "Area secundaria", @@ -71,14 +70,14 @@ } }, "vacuum": { - "quirk": { + "mower": { "state": { "cleaning": "Segando" } } }, "camera": { - "quirk": { + "mower": { "state": { "cleaning": "Segando" } diff --git a/custom_components/husqvarna_automower/translations/et.json b/custom_components/husqvarna_automower/translations/et.json index d095ac5..7638da3 100644 --- a/custom_components/husqvarna_automower/translations/et.json +++ b/custom_components/husqvarna_automower/translations/et.json @@ -42,57 +42,57 @@ "application_credentials": { "description": "Loo konto [Husqvarna developers portal]({oauth_creds_url}). Ühenda Authentication API ja Automower Connect API. Sea ümbersuunamise URI https://my.home-assistant.io/redirect/oauth. Kui sa pole veel seadistanud My HomeAssistant asukohta, sisesta see URL oma asukohaks {redirect_uri}" }, - "entity": { - "sensor": { - "problem_list": { - "state": { - "off": "Väljas", - "unknown": "Teadmata", - "stopped": "Peatunud", - "stopped_in_garden": "Peatunud aias", - "not_applicable": "Pole kohalduv", - "none": "Puudub", - "week_schedule": "Nädala ajakava", - "park_override": "Parkimise tühistamine", - "sensor": "Ilmataimer", - "daily_limit": "Päevane limiit", - "fota": "Püsivara uuendamine", - "frost": "Härmatis", + "entity": { + "sensor": { + "problem_list": { + "state": { + "off": "Väljas", + "unknown": "Teadmata", + "stopped": "Peatunud", + "stopped_in_garden": "Peatunud aias", + "not_applicable": "Pole kohalduv", + "none": "Puudub", + "week_schedule": "Nädala ajakava", + "park_override": "Parkimise tühistamine", + "sensor": "Ilmataimer", + "daily_limit": "Päevane limiit", + "fota": "Püsivara uuendamine", + "frost": "Härmatis", "parked_until_further_notice": "Pargitud kuni edasise korralduseni" - } - }, - "mode_list": { - "state": { + } + }, + "mode_list": { + "state": { "main_area": "Peamine niiduala", "secondary_area": "Teisene niiduala", "home": "Laadimisjaam", "demo": "Demo", "unknown": "Teadmata" } - } - }, + } + }, "vacuum": { - "quirk": { + "mower": { "state": { "cleaning": "Niidab" } } }, "camera": { - "quirk": { + "mower": { "state": { "cleaning": "Niidab", - "docked": "Dokitud", - "error": "Viga", - "idle": "[%key:common::state::idle%]", - "off": "[%key:common::state::off%]", - "on": "[%key:common::state::on%]", - "paused": "[%key:common::state::paused%]", - "returning": "Läheb laadimisjaama" + "docked": "Dokitud", + "error": "Viga", + "idle": "[%key:common::state::idle%]", + "off": "[%key:common::state::off%]", + "on": "[%key:common::state::on%]", + "paused": "[%key:common::state::paused%]", + "returning": "Läheb laadimisjaama" } } } - }, + }, "issues": { "wrong_scope": { "title": "Sinu juurdepääsutõendi kehtivusala on vale", diff --git a/custom_components/husqvarna_automower/translations/fr.json b/custom_components/husqvarna_automower/translations/fr.json index 0e7884c..5350341 100644 --- a/custom_components/husqvarna_automower/translations/fr.json +++ b/custom_components/husqvarna_automower/translations/fr.json @@ -18,18 +18,18 @@ }, "entity": { "vacuum": { - "quirk": { + "mower": { "state": { "cleaning": "Tonte" } } }, "camera": { - "quirk": { + "mower": { "state": { "cleaning": "Tonte" } } } } -} \ No newline at end of file +} diff --git a/custom_components/husqvarna_automower/translations/no.json b/custom_components/husqvarna_automower/translations/no.json index bd84a14..524d6af 100644 --- a/custom_components/husqvarna_automower/translations/no.json +++ b/custom_components/husqvarna_automower/translations/no.json @@ -27,7 +27,6 @@ "gps_bottom_right": "GPS koordinater for det nedre høyre hjørne av bildet", "mower_img_path": "Filsti til bilde af robotklipper", "map_img_path": "Filsti til bilde af kartet" - }, "description": "Kamera instillinger", "title": "Husqvarna Automower instillinger" @@ -44,14 +43,14 @@ }, "entity": { "vacuum": { - "quirk": { + "mower": { "state": { "cleaning": "Klipper" } } }, "camera": { - "quirk": { + "mower": { "state": { "cleaning": "Klipper" } diff --git a/custom_components/husqvarna_automower/translations/sv.json b/custom_components/husqvarna_automower/translations/sv.json index dd4a9b7..26f9fb3 100644 --- a/custom_components/husqvarna_automower/translations/sv.json +++ b/custom_components/husqvarna_automower/translations/sv.json @@ -27,7 +27,6 @@ "gps_bottom_right": "GPS-koordinater för det nedre högra bildhörnet", "mower_img_path": "Sökväg till bild på gräsklipparen", "map_img_path": "Sökväg till kartbilden" - }, "description": "Kamerainställningar", "title": "Husqvarna Automower-inställningar" @@ -40,22 +39,166 @@ } }, "application_credentials": { - "description": "Skapa ett konto på [Husqvarna developers portal]({oauth_creds_url}). Anslut Authentication API and Automower Connect API. Som redirect-URI anges https://my.home-assistant.io/redirect/oauth. Om du inte har konfigurerat My HomeAssistant, ange istället denna URL: {redirect_uri}" + "description": "Skapa ett konto på [Husqvarna developers portal]({oauth_creds_url}). Anslut Authentication API and Automower Connect API. Som redirect-URI anges https://my.home-assistant.io/redirect/oauth. Om du inte har konfigurerat My HomeAssistant, ange istället denna URL: {redirect_uri}" }, "entity": { + "binary_sensor": { + "battery_charging": { + "name": "Batteriladdning" + }, + "leaving_dock": { + "name": "Lämnar laddningsstationen" + }, + "error": { + "name": "Fel" + } + }, + "number": { + "cutting_height": { + "name": "Klipphöjd" + }, + "mow_for": { + "name": "Klipp i" + }, + "park_for": { + "name": "Parkera i" + } + }, + "select": { + "headlight_mode": { + "name": "Strålkastare", + "state": { + "always_on": "Alltid på", + "always_off": "Alltid av", + "evening_only": "Endast kväll", + "evening_and_night": "Kväll och natt" + } + } + }, + "sensor": { + "cutting_height": { + "name": "Klipphöjd" + }, + "number_of_charging_cycles": { + "name": "Antal laddningscykler" + }, + "number_of_collisions": { + "name": "Antal kollisioner" + }, + "cutting_blade_usage_time": { + "name": "Knivblad använda" + }, + "total_charging_time": { + "name": "Total laddningstid" + }, + "total_cutting_time": { + "name": "Total klipptid" + }, + "total_running_time": { + "name": "Total drifttid" + }, + "total_searching_time": { + "name": "Total söktid" + }, + "searching_time_percent": { + "name": "Söktid andel" + }, + "cutting_time_percent": { + "name": "Klipptid andel" + }, + "battery_level": { + "name": "Batterinivå" + }, + "next_start": { + "name": "Nästa start" + }, + "problem_list": { + "name": "Problem", + "state": { + "off": "Från", + "unknown": "Okänt", + "stopped": "Stoppad", + "stopped_in_garden": "Stoppad i trädgårdenn", + "not_applicable": "Ej tillämpligt", + "none": "Inget", + "week_schedule": "Veckoschema", + "park_override": "Parkering åsidosatt", + "sensor": "Vädertimer", + "daily_limit": "Daglig begränsning", + "fota": "Fota", + "frost": "Frost", + "parked_until_further_notice": "Parkerad tills vidare" + } + }, + "mode_list": { + "name": "Driftläge", + "state": { + "main_area": "Huvudyta", + "secondary_area": "Sekundär yta", + "home": "Hem", + "demo": "Demo", + "unknown": "Okänt" + } + } + }, "vacuum": { - "quirk": { + "mower": { "state": { "cleaning": "Klipper" + }, + "state_attributes": { + "status": { + "name": "Status", + "state": { + "cleaning": "Klipper", + "off": "Från", + "unknown": "Okänd", + "stopped": "Stoppad", + "not_applicable": "Ej tillämpligt", + "paused": "Pausad", + "going_to_charging_station": "På väg till laddningsstation", + "leaving_charging_station": "Lämnar laddningsstation", + "parked": "Parkerad", + "park_override": "Parkering åsidosatt", + "daily_limit": "Daglig begränsning", + "fota": "Fota", + "updating": "Updaterar", + "powering_up": "Startar", + "weather_timer": "Vädertimer", + "parked_until_further_notice": "Parkerad tills vidare" + } + }, + "action": { + "name": "Aktion", + "state": { + "force_mow": "Forcera klippning", + "not_active": "Inaktiv", + "unknown": "Okänd" + } + } } } }, "camera": { - "quirk": { + "mower_cam": { + "name": "Karta", "state": { - "cleaning": "Klipper" + "cleaning": "Klipper", + "docked": "Dockad", + "error": "Fel", + "idle": "Inaktiv", + "off": "Från", + "on": "Till", + "paused": "Pausad", + "returning": "Återvänder till dockan" } } } + }, + "issues": { + "wrong_scope": { + "title": "Felaktigt scope för token", + "description": "Ändra scope för att kunna använda websocket och omedelbara uppdateringar av status för klipparen. Läs mer här: https://developer.husqvarnagroup.cloud/apis/automower-connect-api#websocket" + } } -} \ No newline at end of file +} diff --git a/custom_components/husqvarna_automower/vacuum.py b/custom_components/husqvarna_automower/vacuum.py index 079df89..7debebf 100644 --- a/custom_components/husqvarna_automower/vacuum.py +++ b/custom_components/husqvarna_automower/vacuum.py @@ -136,7 +136,8 @@ def error(self) -> str: """Define an error message if the vacuum is in STATE_ERROR.""" if self.state == STATE_ERROR: mower_attributes = AutomowerEntity.get_mower_attributes(self) - return ERRORCODES.get(mower_attributes["mower"]["errorCode"]) + errorcode = mower_attributes["mower"]["errorCode"] + return ERRORCODES.get(errorcode, f"error_{errorcode}") return None @@ -145,10 +146,9 @@ class HusqvarnaAutomowerEntity( ): """Defining each mower Entity.""" - _attr_device_class = f"{DOMAIN}__mower" _attr_icon = "mdi:robot-mower" _attr_supported_features = SUPPORT_STATE_SERVICES - _attr_translation_key = "quirk" + _attr_translation_key = "mower" def __init__(self, session, idx): """Set up HusqvarnaAutomowerEntity.""" @@ -187,6 +187,16 @@ def __get_status(self) -> str: return MWR_ACTIVITY_TO_STATUS.get(mower_attributes["mower"]["activity"]) if mower_attributes["mower"]["activity"] == "CHARGING": return f"Charging{next_start_short}" + if mower_attributes["mower"]["activity"] == "LEAVING": + return "leaving_charging_station" + if mower_attributes["mower"]["activity"] == "PARKED_IN_CS": + return "parked" + if mower_attributes["mower"]["activity"] == "STOPPED_IN_GARDEN": + return "stopped" + if mower_attributes["mower"]["state"] == "WAIT_UPDATING": + return "updating" + if mower_attributes["mower"]["state"] == "WAIT_POWER_UP": + return "powering_up" if mower_attributes["mower"]["state"] == "RESTRICTED": if ( mower_attributes["planner"]["restrictedReason"] @@ -205,9 +215,11 @@ def __get_status(self) -> str: def extra_state_attributes(self) -> dict: """Return the specific state attributes of this mower.""" mower_attributes = AutomowerEntity.get_mower_attributes(self) + action = mower_attributes["planner"]["override"]["action"] + action = action.lower() if action is not None else action return { ATTR_STATUS: self.__get_status(), - "action": mower_attributes["planner"]["override"]["action"], + "action": action, } async def async_start(self) -> None: