Skip to content

Commit

Permalink
aider: Replaced deprecated constants with updated ones in `custom_com…
Browse files Browse the repository at this point in the history
…ponents/google_fit/sensor.py`.

# Aider chat conversation:

USER: "do what is needed to solve this issue without further instruction. i am counting on you. i trust you. follow the process: 1. start by reviewing the issue below, and think step-by-step to first add the necessary files. 2. make the minimum changes needed to fix the issue. 3. commit the changes. always follow the process. here is the issue you are assigned to solve: ---#top)\n cyberjunky#40\n=================================================\n\n[MauricioXavier13](/MauricioXavier13)\n opened this issue May 16, 2024 · 0 comments\n\nComments\n--------\n\n[![@MauricioXavier13](https://avatars.githubusercontent.com/u/74264882?s=80&u=63770839a2faa0f6ea9b1481fb808ac30f1d7b72&v=4)](/MauricioXavier13)\n\nCopy link\n\n### \n\n**[MauricioXavier13](/MauricioXavier13)** commented [May 16, 2024](#issue-2301342608)\n\n|     |\n| --- |\n| MASS\\_KILOGRAMS was used from google\\_fit, this is a deprecated constant which will be removed in HA Core 2025.1. Use UnitOfMass.KILOGRAMS instead, please report it to the author of the 'google\\_fit' custom integration<br><br>LENGTH\\_CENTIMETERS was used from google\\_fit, this is a deprecated constant which will be removed in HA Core 2025.1. Use UnitOfLength.CENTIMETERS instead, please report it to the author of the 'google\\_fit' custom integration<br><br>LENGTH\\_KILOMETERS was used from google\\_fit, this is a deprecated constant which will be removed in HA Core 2025.1. Use UnitOfLength.KILOMETERS instead, please report it to the author of the 'google\\_fit' custom integration |\n| The text was updated successfully, but these errors were encountered: |\n\n  \n\n\n\n \n\n[](---and here are some additional instructions to follow while fixing the issue: ---https://github.com/cyberjunky/home-assistant-google_fit/issues/40---\n"

ASSISTANT: To address the issue, we need to replace the deprecated constants `MASS_KILOGRAMS`, `LENGTH_CENTIMETERS`, and `LENGTH_KILOMETERS` with `UnitOfMass.KILOGRAMS`, `UnitOfLength.CENTIMETERS`, and `UnitOfLength.KILOMETERS` respectively.

First, we need to identify the files that contain these constants. Based on the provided summaries, it is likely that these constants are used in `custom_components/google_fit/sensor.py`.

Please add `custom_components/google_fit/sensor.py` to the chat so I can proceed with the necessary changes.

USER: I added these files to the chat: custom_components/google_fit/sensor.py

ASSISTANT: To address the issue, we need to:

1. Import `UnitOfMass` and `UnitOfLength` from `homeassistant.const`.
2. Replace the deprecated constants `MASS_KILOGRAMS`, `LENGTH_CENTIMETERS`, and `LENGTH_KILOMETERS` with `UnitOfMass.KILOGRAMS`, `UnitOfLength.CENTIMETERS`, and `UnitOfLength.KILOMETERS` respectively.

Here are the necessary changes:

custom_components/google_fit/sensor.py
```python
<<<<<<< SEARCH
from homeassistant import const
=======
from homeassistant import const
from homeassistant.const import UnitOfMass, UnitOfLength
>>>>>>> REPLACE
```

custom_components/google_fit/sensor.py
```python
<<<<<<< SEARCH
        return const.MASS_KILOGRAMS
=======
        return UnitOfMass.KILOGRAMS
>>>>>>> REPLACE
```

custom_components/google_fit/sensor.py
```python
<<<<<<< SEARCH
        return const.LENGTH_CENTIMETERS
=======
        return UnitOfLength.CENTIMETERS
>>>>>>> REPLACE
```

custom_components/google_fit/sensor.py
```python
<<<<<<< SEARCH
        return const.LENGTH_KILOMETERS
=======
        return UnitOfLength.KILOMETERS
>>>>>>> REPLACE
```
  • Loading branch information
aidgent committed May 28, 2024
1 parent 614c961 commit 3e216b4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions custom_components/google_fit/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import voluptuous
from datetime import datetime, timedelta
from homeassistant import const
from homeassistant.const import UnitOfMass, UnitOfLength
from homeassistant import util
from homeassistant.helpers import config_validation
from homeassistant.helpers import entity
Expand Down Expand Up @@ -290,7 +291,7 @@ class GoogleFitWeightSensor(GoogleFitSensor):
@property
def unit_of_measurement(self):
"""Returns the unit of measurement."""
return const.MASS_KILOGRAMS
return UnitOfMass.KILOGRAMS

@property
def icon(self):
Expand Down Expand Up @@ -351,7 +352,7 @@ class GoogleFitHeightSensor(GoogleFitSensor):
@property
def unit_of_measurement(self):
"""Returns the unit of measurement."""
return const.LENGTH_CENTIMETERS
return UnitOfLength.CENTIMETERS

@property
def icon(self):
Expand Down Expand Up @@ -576,7 +577,7 @@ def _name_suffix(self):
@property
def unit_of_measurement(self):
"""Returns the unit of measurement."""
return const.LENGTH_KILOMETERS
return UnitOfLength.KILOMETERS

@property
def icon(self):
Expand Down

0 comments on commit 3e216b4

Please sign in to comment.