diff --git a/.devcontainer/configuration.yaml b/.devcontainer/configuration.yaml index 75ece4b..7b12af9 100644 --- a/.devcontainer/configuration.yaml +++ b/.devcontainer/configuration.yaml @@ -1,4 +1,46 @@ -default_config: +http: + server_port: 9123 + +# default_config: +# no default config, be more specific and select from https://www.home-assistant.io/integrations/default_config/ +automation: +# cloud: +config: +counter: +dhcp: +frontend: +history: +image: +input_boolean: +input_datetime: +input_number: +input_select: +input_text: +logbook: +map: +media_source: +mobile_app: +person: +scene: +script: +ssdp: +sun: +system_health: +tag: +timer: +updater: +zeroconf: +zone: + +#group: !include groups.yaml +#automation: !include automations.yaml +#script: !include scripts.yaml +#scene: !include scenes.yaml + +group: !include groups.yaml +automation: !include automations.yaml +script: !include scripts.yaml +scene: !include scenes.yaml # enable remote python debugger debugpy: @@ -10,3 +52,15 @@ logger: homeassistant.components.govee: debug custom_components.govee: debug govee_api_laggat: debug + custom_components.hacs: warning + homeassistant.components.discovery: debug + homeassistant.components.zeroconf: debug + homeassistant.components.ssdp: debug + homeassistant.components.dhcp: debug + + +device_tracker: + - platform: bluetooth_le_tracker + # avoid some log spam + interval_seconds: 60 + track_new_devices: true diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e660adc..568eb92 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,12 +1,23 @@ // See https://aka.ms/vscode-remote/devcontainer.json for format details. { - "image": "ludeeus/container:integration-debian", + // for development container on remote pi we need to clone source into the remote container, instead of bind: + "workspaceFolder": "/workspaces/hacs-govee", + "workspaceMount": "source=/usr/share/hassio/share/dev/hacs-govee,target=/workspaces/hacs-govee,type=bind,consistency=delegated", + // "remoteEnv": { + // "WS_PATH": "..", + // }, + // "containerEnv": { + // "WS_PATH": "/usr/share/hassio/share/dev/hacs-govee", + // }, + "image": "ludeeus/container:python-base-debian", + //"vsch.local.folder": "/usr/share/hassio/share/dev/hacs-govee", + //"dockerFile": "Dockerfile", "name": "Govee integration development", "context": "..", - "appPort": [ - "9123:8123" - ], - "postCreateCommand": "container install && python3 -m pip install --upgrade pip && pip3 install -r /workspaces/hacs-govee/requirements_test.txt", + // "appPort": [ + // "9123:8123" + // ], + "postCreateCommand": "/bin/echo ------------ postCreateCommand apt-get ------------ && apt-get update && apt-get -y install bash bluetooth bluez bluez-tools build-essential ca-certificates cython gcc git iputils-ping libatomic1 libavcodec-dev libc-dev libffi-dev libjpeg-dev libpcap-dev libssl-dev make nano openssh-client procps python3 python3-dev python3-dev python3-pip python3-setuptools rfkill unzip wget wget zlib1g-dev && /bin/echo ------------ postCreateCommand python/pip ------------ && /usr/local/bin/python3 -m pip install --upgrade pip && /usr/local/bin/pip3 install black colorlog debugpy pexpect pygatt pylint PyNaCl==1.3.0 && /usr/local/bin/pip3 install -r /workspaces/hacs-govee/requirements_test.txt && /bin/echo ------------ postCreateCommand container install ------------ && mkdir -p /src/ludeeus && cd /src/ludeeus && git clone https://github.com/ludeeus/container && cp -r ./container/rootfs/common/* / && chmod +x /usr/bin/container && /usr/bin/container install && /bin/echo ------------ postCreateCommand symlink our component ------------ && /bin/mkdir -p /config/custom_components && /bin/ln -s /workspaces/hacs-govee/custom_components/govee /config/custom_components/govee && /bin/echo ------------ postCreateCommand install hacs ------------ && mkdir -p /src/hacs && cd /src/hacs && /bin/mkdir -p /config/custom_components/hacs && /usr/bin/wget https://github.com/hacs/integration/releases/latest/download/hacs.zip && /usr/bin/unzip hacs.zip -d /config/custom_components/hacs && /bin/rm hacs.zip && /bin/echo ------------ postCreateCommand finished, starting HASS ------------ ", "extensions": [ "ms-python.python", "github.vscode-pull-request-github", @@ -29,6 +40,34 @@ "editor.formatOnPaste": false, "editor.formatOnSave": true, "editor.formatOnType": true, - "files.trimTrailingWhitespace": true - } -} \ No newline at end of file + "files.trimTrailingWhitespace": true, + // to develop on your raspberry pi 4 (for BLE): + "docker.host": "ssh://root@192.168.144.5", + // also set docker.host for this workspace in vscode + // create keys with "ssh-keygen -t rsa -b 4096" + // also run this on your pi + // copy your local id-rsa.pub content to /root/.ssh/authorized_keys + // then configure remote-ssh to use key auth: "Remote-SSH: Open Configuration file": + // Host 192.168.144.5 + // HostName 192.168.144.5 + // User root + // ForwardAgent yes + // IdentityFile C:\Users\root\.ssh\id_rsa + // then in "Remote Containers: Re-build and re-open in container" + }, + "runArgs": [ + "--name", + "devcontainer_govee", + "--network", + "host", + "--privileged", + "-v", + "/etc/machine-id:/etc/machine-id:ro", + "-v", + "/run/dbus:/run/dbus:ro", + "-v", + "/dev:/dev:ro", + "-v", + "/run/udev:/run/udev:ro", + ] +} diff --git a/.gitignore b/.gitignore index a81c8ee..f62fc6e 100644 --- a/.gitignore +++ b/.gitignore @@ -136,3 +136,6 @@ dmypy.json # Cython debug symbols cython_debug/ + +# other components in test environment +custom_components/hacs diff --git a/.vscode/launch.json b/.vscode/launch.json index 41edfdf..2da02af 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -15,8 +15,12 @@ "pathMappings": [ { "localRoot": "${workspaceFolder}", - "remoteRoot": "." - } + "remoteRoot": "/workspaces/hacs-govee" + }, + { + "localRoot": "/custom_components/govee", + "remoteRoot": "/workspaces/hacs-govee" + }, ], "justMyCode": false } diff --git a/.vscode/settings.json b/.vscode/settings.json index b924d64..5d58c56 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,7 @@ { "python.linting.pylintEnabled": true, "python.linting.enabled": true, - "python.pythonPath": "/usr/bin/python", + "python.pythonPath": "/usr/local/bin/python", "files.associations": { "*.yaml": "home-assistant" }, @@ -11,5 +11,7 @@ "python.testing.pytestEnabled": true, "python.testing.pytestArgs": [ "tests" - ] + ], + "docker.host": "ssh://root@192.168.144.5", + "docker.imageBuildContextPath": "/usr/share/hassio/share/dev/hacs-govee", } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index d586b7b..6bfc1ed 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -24,20 +24,19 @@ "type": "shell", "command": "container set-version", "problemMatcher": [] - } - // , + }//, // { // "label": "Run HASS", // "type": "shell", - // "command": "hass -c ./config", - // "group": { - // "kind": "test", - // "isDefault": true - // }, - // "presentation": { - // "reveal": "always", - // "panel": "new" - // }, + // "command": "hass -c /config", + // // "group": { + // // "kind": "test", + // // "isDefault": true + // // }, + // // "presentation": { + // // "reveal": "always", + // // "panel": "new" + // // }, // "problemMatcher": [] // } ] diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..71e4f7c --- /dev/null +++ b/Pipfile @@ -0,0 +1,11 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] + +[dev-packages] + +[requires] +python_version = "3.9" diff --git a/README.md b/README.md index 22fd249..59111b3 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# 'Govee LED strips' integration +# 'Govee' integration The Govee integration allows you to control and monitor lights using the Govee API. -To set up this integration, click Configuration in the sidebar and then click Integrations. Click the + icon to add "Govee LED strips" to the integrations. An API key +To set up this integration, click Configuration in the sidebar and then click Integrations. Click the + icon to add "Govee" to the integrations. An API key is necessary, you need to obtain it in the 'Govee Home' app on your mobile, in the User menu - About us - Apply for API Key. The key will be sent to you by email. ## Pulling or assuming state diff --git a/core b/core new file mode 100644 index 0000000..b75c5fd Binary files /dev/null and b/core differ diff --git a/custom_components/__init__.py b/custom_components/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/custom_components/govee/__init__.py b/custom_components/govee/__init__.py index bb79534..56b3fa6 100644 --- a/custom_components/govee/__init__.py +++ b/custom_components/govee/__init__.py @@ -1,4 +1,4 @@ -"""The Govee LED strips integration.""" +"""The Govee integration.""" import asyncio import logging @@ -20,8 +20,15 @@ PLATFORMS = ["light"] +def setup(hass, config): + """This setup does nothing, we use the async setup.""" + hass.states.set("govee.state", "setup called") + return True + + async def async_setup(hass: HomeAssistant, config: dict): - """Set up the Govee LED strips component.""" + """Set up the Govee component.""" + hass.states.async_set("govee.state", "async_setup called") hass.data[DOMAIN] = {} return True @@ -35,7 +42,7 @@ def is_online(online: bool): async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): - """Set up Govee LED strips from a config entry.""" + """Set up Govee from a config entry.""" # get vars from ConfigFlow/OptionsFlow config = entry.data diff --git a/custom_components/govee/config_flow.py b/custom_components/govee/config_flow.py index 7a732de..ac531bc 100644 --- a/custom_components/govee/config_flow.py +++ b/custom_components/govee/config_flow.py @@ -1,4 +1,4 @@ -"""Config flow for Govee LED strips integration.""" +"""Config flow for Govee integration.""" import logging @@ -35,7 +35,7 @@ async def validate_api_key(hass: core.HomeAssistant, user_input): @config_entries.HANDLERS.register(DOMAIN) class GoveeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): - """Handle a config flow for Govee LED strips.""" + """Handle a config flow for Govee.""" VERSION = 1 CONNECTION_CLASS = config_entries.CONN_CLASS_CLOUD_POLL diff --git a/custom_components/govee/learning_storage.py b/custom_components/govee/learning_storage.py index 81929f1..f33ce3a 100644 --- a/custom_components/govee/learning_storage.py +++ b/custom_components/govee/learning_storage.py @@ -14,7 +14,7 @@ class GoveeLearningStorage(GoveeAbstractLearningStorage): - """The govee_api_laggat library uses this to store learned information about led strips.""" + """The govee_api_laggat library uses this to store learned information about lights.""" def __init__(self, config_dir, *args, **kwargs): """Get the config directory.""" diff --git a/custom_components/govee/light.py b/custom_components/govee/light.py index 635cc3b..2ada5e7 100644 --- a/custom_components/govee/light.py +++ b/custom_components/govee/light.py @@ -1,4 +1,4 @@ -"""Govee LED strips platform.""" +"""Govee platform.""" from datetime import timedelta import logging diff --git a/custom_components/govee/manifest.json b/custom_components/govee/manifest.json index 408903c..656aa54 100644 --- a/custom_components/govee/manifest.json +++ b/custom_components/govee/manifest.json @@ -1,14 +1,14 @@ { + "codeowners": ["@LaggAt"], "domain": "govee", - "name": "Govee LED strips", - "version": "0.1.6-beta.1", + "name": "Govee", + "version": "0.1.7", "config_flow": true, "documentation": "https://github.com/LaggAt/hacs-govee/blob/master/README.md", "issue_tracker": "https://github.com/LaggAt/hacs-govee/issues", - "requirements": ["govee-api-laggat==0.1.37", "dacite==1.5.1"], + "requirements": ["govee-api-laggat==0.1.38", "dacite==1.5.1"], "ssdp": [], "zeroconf": [], "homekit": {}, - "dependencies": [], - "codeowners": ["@LaggAt"] + "dependencies": [] } diff --git a/custom_components/govee/strings.json b/custom_components/govee/strings.json index f0cf93f..ecf454c 100644 --- a/custom_components/govee/strings.json +++ b/custom_components/govee/strings.json @@ -1,5 +1,5 @@ { - "title": "Govee LED strips", + "title": "Govee", "config": { "abort": { "already_configured": "Already configured. Only a single configuration possible." @@ -14,7 +14,7 @@ "api_key": "API Key", "delay": "Poll Interval" }, - "title": "Govee LED strips", + "title": "Govee", "description": "Get your API Key from the Govee Home App. For Details see https://github.com/LaggAt/hacs-govee/blob/master/README.md" } } @@ -28,7 +28,7 @@ "use_assumed_state": "Use 'assumed state' (two buttons). Default: True", "offline_is_off": "When a led is offline, show it as off (default doesn't change state). Default: False" }, - "title": "Govee LED strips - Options", + "title": "Govee - Options", "description": "Configure the Govee integration. For Details see 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 13ecc92..da7557e 100644 --- a/custom_components/govee/translations/de.json +++ b/custom_components/govee/translations/de.json @@ -1,5 +1,5 @@ { - "title": "Govee LED Strips", + "title": "Govee", "config": { "abort": { "already_configured": "Bereits eingerichtet. Es ist nur eine Konfiguration möglich." @@ -14,7 +14,7 @@ "api_key": "API Key", "delay": "Abfrage-Intervall" }, - "title": "Govee LED Strips", + "title": "Govee", "description": "Den API Key bekommen Sie in der Govee Home App. Details dazu hier: https://github.com/LaggAt/hacs-govee/blob/master/README.md" } } @@ -28,7 +28,7 @@ "use_assumed_state": "Verwende 'angenommenen Zustand' (zwei Buttons). Standard: True", "offline_is_off": "Wenn eine LED offline ist, zeige sie als Aus (Standard ändert den Status nicht). Standard: False" }, - "title": "Govee LED Strips - Einstellungen", + "title": "Govee - Einstellungen", "description": "Einstellen der Govee Integration. Details dazu hier: https://github.com/LaggAt/hacs-govee/blob/master/README.md" } } diff --git a/custom_components/govee/translations/en.json b/custom_components/govee/translations/en.json index 58295f1..27790d3 100644 --- a/custom_components/govee/translations/en.json +++ b/custom_components/govee/translations/en.json @@ -1,5 +1,5 @@ { - "title": "Govee LED strips", + "title": "Govee", "config": { "abort": { "already_configured": "Already configured. Only a single configuration possible." @@ -14,7 +14,7 @@ "api_key": "API Key", "delay": "Poll Interval" }, - "title": "Govee LED strips", + "title": "Govee", "description": "Get your API Key from the Govee Home App. For Details see https://github.com/LaggAt/hacs-govee/blob/master/README.md" } } @@ -28,7 +28,7 @@ "use_assumed_state": "Use 'assumed state' (two buttons). Default: True", "offline_is_off": "When a led is offline, show it as off (default doesn't change state). Default: False" }, - "title": "Govee LED strips - Options", + "title": "Govee - Options", "description": "Configure the Govee integration. For Details see https://github.com/LaggAt/hacs-govee/blob/master/README.md" } } diff --git a/hacs.json b/hacs.json index e51098a..89a9009 100644 --- a/hacs.json +++ b/hacs.json @@ -1,6 +1,6 @@ { "name": "govee", - "hacs": "0.1.6-beta.1", + "hacs": "0.1.7", "domains": [ "light" ], diff --git a/info.md b/info.md index 4a06dfe..7c3d7be 100644 --- a/info.md +++ b/info.md @@ -3,13 +3,13 @@ [![BuyMeCoffee][buymecoffeebadge]][buymecoffee] -_Component to integrate with [Govee LED strips][hacs-govee]._ +_Component to integrate with [Govee][hacs-govee]._ **This component will set up the following platforms.** Platform | Description -- | -- -`light` | Control your led strips. +`light` | Control your lights. diff --git a/tests/__init__.py b/tests/__init__.py index 05bbd2b..fd3f4bc 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +1 @@ -"""Tests for the Govee LED strips integration.""" +"""Tests for the Govee integration.""" diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index 5402b8c..21593e5 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -1,4 +1,4 @@ -"""Test the Govee LED strips 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