Skip to content

Commit

Permalink
Merge pull request #1 from DvinPROG/add-other-changes
Browse files Browse the repository at this point in the history
Add-other-changes
  • Loading branch information
DvinPROG committed Dec 13, 2023
2 parents 797a5d4 + 75b3e8b commit 2a980a1
Show file tree
Hide file tree
Showing 42 changed files with 3,124 additions and 1,634 deletions.
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ updates:
interval: daily
labels:
- "dependencies"
ignore:
- dependency-name: "homeassistant"
- package-ecosystem: github-actions
directory: "/"
schedule:
Expand Down
6 changes: 3 additions & 3 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ categories:
labels:
- "feature"
- "performance"
- title: "🈵 Translations"
labels:
- "translation"
- title: "🐛 Bug Fixes"
labels:
- "bug"
- title: "🈵 Translations"
labels:
- "translation"
- title: "📄 Documentation"
labels:
- "documentation"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/home-assistant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ on:
pull_request:

env:
DEFAULT_PYTHON: 3.9
DEFAULT_PYTHON: "3.11"

jobs:
hacs:
runs-on: ubuntu-latest
name: HACS
steps:
- name: Check out the repository
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"

- name: HACS validation
uses: "hacs/[email protected]"
Expand All @@ -27,7 +27,7 @@ jobs:
name: Hassfest
steps:
- name: Check out the repository
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"

- name: Hassfest validation
uses: "home-assistant/actions/hassfest@master"
18 changes: 9 additions & 9 deletions .github/workflows/linting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ on:
- master
pull_request:

env:
PYTHON_VERSION: "3.11"

jobs:
pre-commit:
name: Pre-commit
strategy:
matrix:
python-version: [3.9]
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Poetry
uses: abatilo/actions-poetry@v2.1.6
uses: abatilo/actions-poetry@v2.3.0
with:
poetry-version: 1.2.0
poetry-version: 1.3.2

- name: Install dependencies
run: poetry install
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/manage-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Run Labeler
uses: crazy-max/ghaction-github-labeler@v4.0.0
uses: crazy-max/ghaction-github-labeler@v5.0.0
18 changes: 9 additions & 9 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ name: Publish new release
on:
workflow_dispatch:

env:
PYTHON_VERSION: "3.11"

jobs:
publish:
name: Update manifest and publish
strategy:
matrix:
python-version: [3.9]
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Poetry
uses: abatilo/actions-poetry@v2.1.6
uses: abatilo/actions-poetry@v2.3.0
with:
poetry-version: 1.2.0
poetry-version: 1.3.2

- name: Install dependencies
run: poetry install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Run release-drafter
uses: release-drafter/release-drafter@v5.21.0
uses: release-drafter/release-drafter@v5.25.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-json
Expand Down Expand Up @@ -43,20 +43,20 @@ repos:
pass_filenames: false
always_run: true
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.2.1
rev: v2.7.1
hooks:
- id: prettier
exclude: ^custom_components/google_home/manifest\.json$
- repo: https://github.com/cdce8p/python-typing-update
rev: v0.3.3
rev: v0.5.1
hooks:
# Run `python-typing-update` hook manually from time to time
# to update python typing syntax.
# Will require manual work, before submitting changes!
- id: python-typing-update
stages: [manual]
args:
- --py38-plus
- --py310-plus
- --force
- --keep-updates
files: ^.+\.py$
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ When writing unittests please follow the good practises like:
## Pre-commit

With Poetry installed, run `poetry install` in the repo root.
It will create a virualenv with all required packages.
It will create a virtualenv with all required packages.

After that you can run [pre-commit](https://pre-commit.com/) with settings included in the
repository to have code style and linting checks.
Expand Down
50 changes: 38 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,16 @@ service: google_home.delete_alarm
data:
entity_id: sensor.kitchen_alarms
timer_id: alarm/47dc1fa0-5ec0-2cc7-9ead-a94b85e22769
skip_refresh: true
```

#### Key Descriptions

| Key | Example | Description |
| ----------- | -------------------------------------------- | --------------------------------------------- |
| `entity_id` | `sensor.kitchen_alarms` | Entity name of a Google Home alarms sensor. |
| `alarm_id` | `alarm/6ed06a56-8a58-c6e3-a7d4-03f92c9d8a51` | ID of an alarm. See alarms description above. |
| Key | Example | Description |
| -------------- | -------------------------------------------- | ----------------------------------------------- |
| `entity_id` | `sensor.kitchen_alarms` | Entity name of a Google Home alarms sensor. |
| `alarm_id` | `alarm/6ed06a56-8a58-c6e3-a7d4-03f92c9d8a51` | ID of an alarm. See alarms description above. |
| `skip_refresh` | `true` | Boolean to skip refreshing Google Home devices. |

### Delete timer

Expand All @@ -174,14 +176,16 @@ service: google_home.delete_timer
data:
entity_id: sensor.kitchen_timers
timer_id: timer/47dc1fa0-5ec0-2cc7-9ead-a94b85e22769
skip_refresh: true
```

#### Key Descriptions

| Key | Example | Description |
| ----------- | -------------------------------------------- | -------------------------------------------- |
| `entity_id` | `sensor.kitchen_timers` | Entity name of a Google Home timers sensor. |
| `timer_id` | `timer/6ed06a56-8a58-c6e3-a7d4-03f92c9d8a51` | ID of a timer. See timers description above. |
| Key | Example | Description |
| -------------- | -------------------------------------------- | ----------------------------------------------- |
| `entity_id` | `sensor.kitchen_timers` | Entity name of a Google Home timers sensor. |
| `timer_id` | `timer/6ed06a56-8a58-c6e3-a7d4-03f92c9d8a51` | ID of a timer. See timers description above. |
| `skip_refresh` | `true` | Boolean to skip refreshing Google Home devices. |

### Reboot device

Expand All @@ -201,11 +205,21 @@ data:
| ----------- | ----------------------- | ------------------------------------------- |
| `entity_id` | `sensor.kitchen_device` | Entity name of a Google Home device sensor. |

### Refresh devices

Note: Resets the timer for automatic polling to refresh devices.

#### Example

```yaml
service: google_home.refresh_devices
```

## Getting Started

### Prerequisites

Use Home Assistant v2022.6.0 or above.
Use Home Assistant v2023.2.0 or above.

### Google Account security

Expand All @@ -218,6 +232,16 @@ Your second account would not have access to anything other than Google Home, so
gets compromised, it's not as severe as losing your main google account.
See more discussion [here](https://github.com/leikoilja/ha-google-home/issues/124#issuecomment-921773489)

### Master token

Due to authentication issues with google credentials alone it may be required to get the master token separately and provide it during the setup process. This can be done using [this script](https://gist.github.com/rithvikvibhu/952f83ea656c6782fbd0f1645059055d) or [glocaltokens](https://github.com/leikoilja/glocaltokens#quickstart) package.

Since there are several issues getting the token reliable on different environments, you can use a docker container which was created solely for this use: <https://hub.docker.com/r/breph/ha-google-home_get-token>. If you choose to use this container, run the following command:

```
$ docker run --rm -it breph/ha-google-home_get-token
```

### HACS Installation

You can find it in the default HACS repo. Just search `Google Home`.
Expand Down Expand Up @@ -404,14 +428,16 @@ Currently the integration supports the following languages:
- Danish
- Dutch
- English
- French
- German (Germany)
- Italian (Italy)
- Norwegian (bokmål and nynorsk)
- Polish
- Portuguese (Portugal)
- Portuguese (Brazil)
- Spanish (Spain)
- Portuguese (Portugal)
- Russian
- Slovak
- Spanish (Spain)
- Ukrainian

If you want to translate the project to your own language, follow the [Localization guide](LOCALIZATION.md).
Expand All @@ -430,7 +456,7 @@ If you want to translate the project to your own language, follow the [Localizat
[integration_blueprint]: https://github.com/custom-components/integration_blueprint
[releases-shield]: https://img.shields.io/github/release/leikoilja/ha-google-home.svg?style=for-the-badge
[releases]: https://github.com/leikoilja/ha-google-home/releases
[workflow-shield]: https://img.shields.io/github/workflow/status/leikoilja/ha-google-home/Linting?style=for-the-badge
[workflow-shield]: https://img.shields.io/github/actions/workflow/status/leikoilja/ha-google-home/linting.yaml?branch=master&style=for-the-badge
[workflow]: https://github.com/leikoilja/ha-google-home/actions
[installs-shield]: https://img.shields.io/endpoint?style=for-the-badge&url=https%3A%2F%2Frunkit.io%2Fkapji%2Fgoogle-home-installs-for-shield-io%2F3.0.0
[installs]: https://analytics.home-assistant.io/custom_integrations.json
9 changes: 5 additions & 4 deletions custom_components/google_home/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
STARTUP_MESSAGE,
UPDATE_INTERVAL,
)
from .models import GoogleHomeDevice

_LOGGER: logging.Logger = logging.getLogger(__package__)

Expand Down Expand Up @@ -75,7 +76,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
DATA_COORDINATOR: coordinator,
}

hass.config_entries.async_setup_platforms(entry, PLATFORMS)
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

entry.add_update_listener(async_update_entry)
return True
Expand All @@ -94,9 +95,9 @@ async def async_update_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Update config entry."""
_LOGGER.debug("Updating entry...")
update_interval: int = entry.options.get(CONF_UPDATE_INTERVAL, UPDATE_INTERVAL)
coordinator: DataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id][
DATA_COORDINATOR
]
coordinator: DataUpdateCoordinator[list[GoogleHomeDevice]] = hass.data[DOMAIN][
entry.entry_id
][DATA_COORDINATOR]
coordinator.update_interval = timedelta(seconds=update_interval)
_LOGGER.debug(
"Coordinator update interval is: %s", timedelta(seconds=update_interval)
Expand Down
Loading

0 comments on commit 2a980a1

Please sign in to comment.