diff --git a/.github/workflows/hassfest.yaml b/.github/workflows/hassfest.yaml new file mode 100644 index 0000000..d203eda --- /dev/null +++ b/.github/workflows/hassfest.yaml @@ -0,0 +1,14 @@ +name: Validate with hassfest + +on: + push: + pull_request: + schedule: + - cron: '0 0 * * *' + +jobs: + validate: + runs-on: "ubuntu-latest" + steps: + - uses: "actions/checkout@v4" + - uses: "home-assistant/actions/hassfest@master" diff --git a/.github/workflows/rebase_dependencies.yml b/.github/workflows/rebase_dependencies.yml deleted file mode 100644 index 5afe074..0000000 --- a/.github/workflows/rebase_dependencies.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Automatic Rebase -on: - push: - branches: - - master -jobs: - rebase: - name: Rebase `dependencies` with `master` - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # otherwise, you will fail to push refs to dest repo - ref: dependencies - - run: | - git config user.name github-actions - git config user.email github-actions@github.com - git rebase origin/master - git push origin dependencies --force \ No newline at end of file diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml new file mode 100644 index 0000000..89090db --- /dev/null +++ b/.github/workflows/validate.yaml @@ -0,0 +1,19 @@ +name: Validate + +on: + push: + pull_request: + schedule: + - cron: "0 0 * * *" + workflow_dispatch: + +permissions: {} + +jobs: + validate-hacs: + runs-on: "ubuntu-latest" + steps: + - name: HACS validation + uses: "hacs/action@main" + with: + category: "integration" diff --git a/README.md b/README.md index 6bbd20f..2594a6d 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ is required, you need to obtain it in the 'Govee Home' app on your mobile device A lot of effort is going into that integration. So if you can afford it and want to support us: -Buy Me A Coffee +Buy Me A Coffee Thank you! @@ -21,7 +21,7 @@ Thank you! We think so. It is used often, and the support thread is active. -![usage statistics per version](https://raw.githubusercontent.com/LaggAt/actions/main/output/goveestats_installations.png) +![usage statistics per version](https://raw.githubusercontent.com/TheOneOgre/actions/main/output/goveestats_installations.png) Usage Data is taken from Home Assistant analytics, and plotted over time by us. You need to enable analytics if you want to show here. @@ -29,7 +29,7 @@ Usage Data is taken from Home Assistant analytics, and plotted over time by us. This graph uses the same library to do simple checks. If you see round dots on the right of the graph (= today), probably there is an issue. -![Govee API running?](https://raw.githubusercontent.com/LaggAt/actions/main/output/govee-api-up.png) +![Govee API running?](https://raw.githubusercontent.com/TheOneOgre/actions/main/output/govee-api-up.png) ## Pulling or assuming state @@ -53,7 +53,7 @@ We can have state from two sources: 'API' and 'HISTORY'. History for example mea So let's say we have an issue, that the ON/OFF state from API is wrong, we always get OFF. (This happended, and this is why I developed that feature). If we disable the power state we get from API we could work around this, and thats exactly what we do: 1. 'API' or 'History': state from which source do we want to disable? In our example the API state is wrong, as we could see in logs, so we choose 'API' -2. Look up the attribute you want to disable in GoveeDevice data class. Don't worry, you don't need to understand any of the code here. [Here is that data class (click)](https://github.com/LaggAt/python-govee-api/blob/master/govee_api_laggat/govee_dtos.py). In our Example we will find 'power_state' +2. Look up the attribute you want to disable in GoveeDevice data class. Don't worry, you don't need to understand any of the code here. [Here is that data class (click)](https://github.com/TheOneOgre/python-govee-api/blob/master/govee_api_laggat/govee_dtos.py). In our Example we will find 'power_state' 3. Next, in Home Assistant we open Configuration - Integrations and click on the options on the Govee integration. Here is an example how this config option could look: ![DISABLE state updates option](https://community-assets.home-assistant.io/original/3X/6/c/6cffe0de8b100ef4efc0e460482ff659b8f9444c.png) diff --git a/custom_components/govee/__init__.py b/custom_components/govee/__init__.py index b92ceaa..0662236 100644 --- a/custom_components/govee/__init__.py +++ b/custom_components/govee/__init__.py @@ -68,8 +68,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): await async_unload_entry(hass, entry) raise PlatformNotReady() - for component in PLATFORMS: - await hass.config_entries.async_forward_entry_setup(entry, component) + try: + await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) + except ImportError as exc: + logging.error("Platform not found ({}).".format(exc)) + return False return True diff --git a/custom_components/govee/light.py b/custom_components/govee/light.py index 95231ec..efec2af 100644 --- a/custom_components/govee/light.py +++ b/custom_components/govee/light.py @@ -3,6 +3,7 @@ from datetime import timedelta, datetime import logging +from homeassistant.util.color import value_to_brightness from propcache import cached_property from govee_api_laggat import Govee, GoveeDevice, GoveeError @@ -27,7 +28,6 @@ COLOR_TEMP_KELVIN_MAX, ) - _LOGGER = logging.getLogger(__name__) @@ -156,6 +156,18 @@ def _state(self): """Lights internal state.""" return self._device # self._hub.state(self._device) + @property + def color_mode(self) -> ColorMode: + """Get color mode.""" + current = list(self._device.color) + if self._device.color_temp > 0: + return ColorMode.COLOR_TEMP + if list([0, 0, 0]) != current: + return ColorMode.HS + if self._device.brightness > 0: + return ColorMode.BRIGHTNESS + return ColorMode.ONOFF + @cached_property def supported_color_modes(self) -> set[ColorMode]: """Get supported color modes.""" @@ -289,23 +301,22 @@ def rgb_color(self): @property def brightness(self): """Return the brightness value.""" - # govee is reporting 0 to 254 - home assistant uses 1 to 255 - return self._device.brightness + 1 + return value_to_brightness((0, 254), self._device.brightness) @property - def color_temp(self): + def color_temp_kelvin(self): """Return the color_temp of the light.""" return self._device.color_temp @property def min_color_temp_kelvin(self): """Return the coldest color_temp that this light supports.""" - return COLOR_TEMP_KELVIN_MAX + return COLOR_TEMP_KELVIN_MIN @property def max_color_temp_kelvin(self): """Return the warmest color_temp that this light supports.""" - return COLOR_TEMP_KELVIN_MIN + return COLOR_TEMP_KELVIN_MAX @property def extra_state_attributes(self): diff --git a/custom_components/govee/manifest.json b/custom_components/govee/manifest.json index dd3ee4f..7c63738 100644 --- a/custom_components/govee/manifest.json +++ b/custom_components/govee/manifest.json @@ -1,15 +1,15 @@ { "domain": "govee", "name": "Govee", - "codeowners": ["@LaggAt"], + "codeowners": ["@TheOneOgre"], "config_flow": true, "dependencies": [], - "documentation": "https://github.com/LaggAt/hacs-govee/blob/master/README.md", + "documentation": "https://github.com/TheOneOgre/govee-cloud/blob/master/README.md", "homekit": {}, "iot_class": "cloud_polling", - "issue_tracker": "https://github.com/LaggAt/hacs-govee/issues", + "issue_tracker": "https://github.com/TheOneOgre/govee-cloud/issues", "requirements": ["govee-api-laggat==0.2.2", "dacite==1.8.0"], "ssdp": [], - "version": "2025.1.1", + "version": "2025.6.1", "zeroconf": [] } diff --git a/custom_components/govee/strings.json b/custom_components/govee/strings.json index 8838a75..f9a00bc 100644 --- a/custom_components/govee/strings.json +++ b/custom_components/govee/strings.json @@ -15,7 +15,7 @@ "delay": "Poll Interval" }, "title": "", - "description": "Get your API Key from the Govee Home App. For Details see https://github.com/LaggAt/hacs-govee/blob/master/README.md" + "description": "Get your API Key from the Govee Home App. For Details see https://github.com/TheOneOgre/govee-cloud/blob/master/README.md" } } }, @@ -35,7 +35,7 @@ "disable_attribute_updates": "DISABLE state updates. Space to disable. Read the README above!" }, "title": "Options", - "description": "Configure the Govee integration. For Details see https://github.com/LaggAt/hacs-govee/blob/master/README.md" + "description": "Configure the Govee integration. For Details see https://github.com/TheOneOgre/govee-cloud/blob/master/README.md" } } } diff --git a/custom_components/govee/translations/cs.json b/custom_components/govee/translations/cs.json new file mode 100644 index 0000000..4ba678b --- /dev/null +++ b/custom_components/govee/translations/cs.json @@ -0,0 +1,41 @@ +{ + "title": "Govee", + "config": { + "abort": { + "already_configured": "Je povolena pouze jedna konfigurace." + }, + "error": { + "cannot_connect": "Nelze se připojit. Je API-Klíč v pořádku a internetové připojení funkční?", + "unknown": "Neznámá chyba." + }, + "step": { + "user": { + "data": { + "api_key": "API klíč", + "delay": "Interval obnovy" + }, + "description": "API Klíč získáte v Govee Home Aplikaci. Detailní postup najdete zde https://github.com/LaggAt/hacs-govee/blob/master/README.md" + } + } + }, + "options": { + "error": { + "cannot_connect": "Nelze se připojit. Je API-Klíč v pořádku a internetové připojení funkční?", + "unknown": "Neznámá chyba.", + "disabled_attribute_updates_wrong": "Špatný formát, přečtěte si README." + }, + "step": { + "user": { + "data": { + "api_key": "API klíč (vyžaduje restart)", + "delay": "Interval obnovy (vyžaduje restart)", + "use_assumed_state": "Použít 'předpokládaný stav' (dvě tlačítka). Výchozí: Ano", + "offline_is_off": "Když je světlo offline, zobrazit jako vypnuté (výchozí nezmění stav). Výchozí: Ne", + "disable_attribute_updates": "ZAKÁZAT aktualizace stavu. Přečtěte si README!" + }, + "title": "Nastavení", + "description": "Nastavení Govee integrace. Pro více informací jděte na https://github.com/LaggAt/hacs-govee/blob/master/README.md" + } + } + } +} diff --git a/custom_components/govee/translations/de.json b/custom_components/govee/translations/de.json index 899a6ff..a8f82cd 100644 --- a/custom_components/govee/translations/de.json +++ b/custom_components/govee/translations/de.json @@ -14,7 +14,7 @@ "api_key": "API Key", "delay": "Abfrage-Intervall" }, - "description": "Den API Key bekommen Sie in der Govee Home App. Details dazu hier: https://github.com/LaggAt/hacs-govee/blob/master/README.md" + "description": "Den API Key bekommen Sie in der Govee Home App. Details dazu hier: https://github.com/TheOneOgre/govee-cloud/blob/master/README.md" } } }, @@ -34,8 +34,8 @@ "disable_attribute_updates": "Status updates verhindern. Leertaste zum ausschalten. Bitte das README oben dazu lesen." }, "title": "Einstellungen", - "description": "Einstellen der Govee Integration. Details dazu hier: https://github.com/LaggAt/hacs-govee/blob/master/README.md" + "description": "Einstellen der Govee Integration. Details dazu hier: https://github.com/TheOneOgre/govee-cloud/blob/master/README.md" } } } -} \ No newline at end of file +} diff --git a/custom_components/govee/translations/en.json b/custom_components/govee/translations/en.json index 35503b7..5f974ed 100644 --- a/custom_components/govee/translations/en.json +++ b/custom_components/govee/translations/en.json @@ -14,7 +14,7 @@ "api_key": "API Key", "delay": "Poll Interval" }, - "description": "Get your API Key from the Govee Home App. For Details see https://github.com/LaggAt/hacs-govee/blob/master/README.md" + "description": "Get your API Key from the Govee Home App. For Details see https://github.com/TheOneOgre/govee-cloud/blob/master/README.md" } } }, @@ -34,7 +34,7 @@ "disable_attribute_updates": "DISABLE state updates. Space to disable. Read the README above!" }, "title": "Options", - "description": "Configure the Govee integration. For Details see https://github.com/LaggAt/hacs-govee/blob/master/README.md" + "description": "Configure the Govee integration. For Details see https://github.com/TheOneOgre/govee-cloud/blob/master/README.md" } } } diff --git a/custom_components/govee/translations/fr.json b/custom_components/govee/translations/fr.json index dd7f3a4..a4bc13f 100644 --- a/custom_components/govee/translations/fr.json +++ b/custom_components/govee/translations/fr.json @@ -14,7 +14,7 @@ "api_key": "clé d'API", "delay": "Intervalle d'interrogation" }, - "description": "Obtenez votre clé API à partir de l'application Govee Home. Pour plus de détails, visitez https://github.com/LaggAt/hacs-govee/blob/master/README.md" + "description": "Obtenez votre clé API à partir de l'application Govee Home. Pour plus de détails, visitez https://github.com/TheOneOgre/govee-cloud/blob/master/README.md" } } }, @@ -34,7 +34,7 @@ "disable_attribute_updates": "DÉSACTIVER les mises à jour d'état. Espace pour désactiver. Lisez le 'lisez-moi' ci-dessus !" }, "title": "Options", - "description": "Configurez l'intégration Govee. Pour plus de détails, visitez https://github.com/LaggAt/hacs-govee/blob/master/README.md" + "description": "Configurez l'intégration Govee. Pour plus de détails, visitez https://github.com/TheOneOgre/govee-cloud/blob/master/README.md" } } } diff --git a/custom_components/govee/translations/pt-BR.json b/custom_components/govee/translations/pt-BR.json index 44809f9..60dd8d5 100644 --- a/custom_components/govee/translations/pt-BR.json +++ b/custom_components/govee/translations/pt-BR.json @@ -14,7 +14,7 @@ "api_key": "Chave de API", "delay": "Intervalo de escaneamento" }, - "description": "Obtenha sua chave de API do aplicativo Govee Home. Para detalhes consulte https://github.com/LaggAt/hacs-govee/blob/master/README.md" + "description": "Obtenha sua chave de API do aplicativo Govee Home. Para detalhes consulte https://github.com/TheOneOgre/govee-cloud/blob/master/README.md" } } }, @@ -34,7 +34,7 @@ "disable_attribute_updates": "DESATIVAR atualizações de estado. Espaço para desativar. Leia o README acima!" }, "title": "Opções", - "description": "Configure a integração do Govee. Para detalhes consulte https://github.com/LaggAt/hacs-govee/blob/master/README.md" + "description": "Configure a integração do Govee. Para detalhes consulte https://github.com/TheOneOgre/govee-cloud/blob/master/README.md" } } } diff --git a/hacs.json b/hacs.json index 6aae722..a822b5e 100644 --- a/hacs.json +++ b/hacs.json @@ -1,4 +1,4 @@ { "name": "govee", - "homeassistant": "2023.11.2" + "homeassistant": "2025.6.1" } diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index 84e05d4..a5d8c44 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -1,4 +1,4 @@ -"""Test the Govee config flow.""" +"""Test the Govee config flow""" from homeassistant import config_entries, setup from custom_components.govee.const import DOMAIN from homeassistant.const import CONF_API_KEY, CONF_DELAY