Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Merge 'upstream/main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
prairiesnpr committed Jun 13, 2023
2 parents a2210fa + b0cc6e6 commit eca2a39
Show file tree
Hide file tree
Showing 17 changed files with 392 additions and 200 deletions.
1 change: 1 addition & 0 deletions core
Submodule core added at 5cdb65
6 changes: 3 additions & 3 deletions custom_components/husqvarna_automower/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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."""
Expand All @@ -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."""
Expand Down
9 changes: 4 additions & 5 deletions custom_components/husqvarna_automower/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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."""
Expand Down
38 changes: 19 additions & 19 deletions custom_components/husqvarna_automower/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down Expand Up @@ -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",
}
4 changes: 2 additions & 2 deletions custom_components/husqvarna_automower/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down Expand Up @@ -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",
)
Expand Down
7 changes: 3 additions & 4 deletions custom_components/husqvarna_automower/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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."""
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions custom_components/husqvarna_automower/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -53,15 +53,15 @@ 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."""
command_type = "settings"
string = {
"data": {
"type": "settings",
"attributes": {"headlight": {"mode": option}},
"attributes": {"headlight": {"mode": option.upper()}},
}
}
payload = json.dumps(string)
Expand Down
31 changes: 14 additions & 17 deletions custom_components/husqvarna_automower/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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(
Expand All @@ -225,29 +225,27 @@ 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(),
available_fn=lambda data: True,
),
AutomowerSensorEntityDescription(
key="cuttingHeight",
name="Cutting height",
translation_key="cutting_height",
entity_registry_enabled_default=True,
icon="mdi:grass",
state_class=SensorStateClass.MEASUREMENT,
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions custom_components/husqvarna_automower/translations/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -72,14 +71,14 @@
}
},
"vacuum": {
"quirk": {
"mower": {
"state": {
"cleaning": "Slår græs"
}
}
},
"camera": {
"quirk": {
"mower": {
"state": {
"cleaning": "Slår græs"
}
Expand Down
Loading

0 comments on commit eca2a39

Please sign in to comment.