Skip to content

Commit

Permalink
Merge pull request #18 from LaggAt/feature/ble
Browse files Browse the repository at this point in the history
Feature/ble
  • Loading branch information
LaggAt authored Apr 10, 2021
2 parents 9ee0309 + d90619e commit 768e9c9
Show file tree
Hide file tree
Showing 22 changed files with 171 additions and 52 deletions.
56 changes: 55 additions & 1 deletion .devcontainer/configuration.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
55 changes: 47 additions & 8 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -29,6 +40,34 @@
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true
}
}
"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",
]
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,6 @@ dmypy.json

# Cython debug symbols
cython_debug/

# other components in test environment
custom_components/hacs
8 changes: 6 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
}
"remoteRoot": "/workspaces/hacs-govee"
},
{
"localRoot": "/custom_components/govee",
"remoteRoot": "/workspaces/hacs-govee"
},
],
"justMyCode": false
}
Expand Down
6 changes: 4 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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"
},
Expand All @@ -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",
}
21 changes: 10 additions & 11 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": []
// }
]
Expand Down
11 changes: 11 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[dev-packages]

[requires]
python_version = "3.9"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Binary file added core
Binary file not shown.
Empty file added custom_components/__init__.py
Empty file.
13 changes: 10 additions & 3 deletions custom_components/govee/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""The Govee LED strips integration."""
"""The Govee integration."""
import asyncio
import logging

Expand All @@ -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

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions custom_components/govee/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Config flow for Govee LED strips integration."""
"""Config flow for Govee integration."""

import logging

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion custom_components/govee/learning_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion custom_components/govee/light.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Govee LED strips platform."""
"""Govee platform."""

from datetime import timedelta
import logging
Expand Down
10 changes: 5 additions & 5 deletions custom_components/govee/manifest.json
Original file line number Diff line number Diff line change
@@ -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": []
}
6 changes: 3 additions & 3 deletions custom_components/govee/strings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"title": "Govee LED strips",
"title": "Govee",
"config": {
"abort": {
"already_configured": "Already configured. Only a single configuration possible."
Expand All @@ -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"
}
}
Expand All @@ -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"
}
}
Expand Down
6 changes: 3 additions & 3 deletions custom_components/govee/translations/de.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"title": "Govee LED Strips",
"title": "Govee",
"config": {
"abort": {
"already_configured": "Bereits eingerichtet. Es ist nur eine Konfiguration möglich."
Expand All @@ -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"
}
}
Expand All @@ -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"
}
}
Expand Down
6 changes: 3 additions & 3 deletions custom_components/govee/translations/en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"title": "Govee LED strips",
"title": "Govee",
"config": {
"abort": {
"already_configured": "Already configured. Only a single configuration possible."
Expand All @@ -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"
}
}
Expand All @@ -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"
}
}
Expand Down
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "govee",
"hacs": "0.1.6-beta.1",
"hacs": "0.1.7",
"domains": [
"light"
],
Expand Down
Loading

0 comments on commit 768e9c9

Please sign in to comment.