Skip to content

Commit

Permalink
Merge pull request #345 from TWilkin/343.config-schema
Browse files Browse the repository at this point in the history
#343/#335 Rebrand clacks-config/sensors and update config-server to support schema in user config files
  • Loading branch information
TWilkin committed Jun 7, 2023
2 parents 605cd39 + a987b1f commit 43fbb8e
Show file tree
Hide file tree
Showing 134 changed files with 603 additions and 553 deletions.
22 changes: 11 additions & 11 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
**/*.egg-info/
**/\*.egg-info/
**/.pytest_cache/
**/__pycache__/
**/esp8266/
**/**pycache**/
**/sensors/
**/build/
**/db/
**/dist/
Expand All @@ -10,16 +10,16 @@
**/platforms/
**/venv/
**/.converage
**/*.dev.js
**/*.dev.ts
**/*.test.ts
**/*.test.tsx
**/*.pyc
**/*.log
**/\*.dev.js
**/_.dev.ts
\*\*/_.test.ts
**/\*.test.tsx
**/_.pyc
\*\*/_.log
**/.eslintignore
**/.eslintrc
**/.gitignore
**/.pylintrc
**/Dockerfile
**/*.md
services/shutdown/*
**/_.md
services/shutdown/_
4 changes: 2 additions & 2 deletions .github/scripts/tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ tag_service "controllers/network" "network-controller"
tag_service "controllers/node" "node-controller"
tag_service "controllers/zigbee" "zigbee-controller"

tag_service "esp8266" "powerpi-sensor"
tag_service "sensors" "powerpi-sensor"

tag_service "services/clacks-config" "clacks-config"
tag_service "services/config-server" "config-server"
tag_service "services/deep-thought" "deep-thought"
tag_service "services/energy-monitor" "energy-monitor"
tag_service "services/freedns" "freedns"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Release PowerPi
on:
push:
branches:
- master
- main

jobs:
release:
Expand Down
6 changes: 3 additions & 3 deletions PowerPi.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"path": "services/deep-thought"
},
{
"name": "Config Service",
"path": "services/clacks-config"
"name": "Config Server",
"path": "services/config-server"
},
{
"name": "Energy Monitor",
Expand Down Expand Up @@ -98,7 +98,7 @@
// Other
{
"name": "Sensors",
"path": "esp8266"
"path": "sensors"
},
{
"name": "Kubernetes",
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This project was devised to utilise open, reverse engineered or free home automa

The project is split into the following services, each of which have their own _README_ describing the configuration interface they support as well as how to modify and test them.

- [**clacks-config**](services/clacks-config/README.md) - Retrieve configuration files from GitHub.
- [**config-server**](services/config-server/README.md) - Retrieve configuration files from GitHub.
- **controllers**:
- [**energenie**](controllers/energenie/README.md) - Allows control of [Energenie MiHome](https://energenie4u.co.uk/catalogue/category/Raspberry-Pi-Accessories) devices using the ENER314 or ENER314-RT Pi module.
- [**harmony**](controllers/harmony/README.md) - Allows control of [Logitech Harmony](https://www.logitech.com/en-gb/products/harmony.html) Smart Hub devices.
Expand All @@ -42,7 +42,7 @@ The project is split into the following services, each of which have their own _

The project includes a [_shutdown_](services/shutdown/README.md) service which allows a computer to be remotely shutdown by message queue events generated by PowerPi, this is used by the [_node_](controllers/node/README.md) controller to shutdown the cluster node when the battery has insufficient charge.

The project also includes sensor NodeMCU code in the [_esp8266_](esp8266/README.md) directory which can be used to generate events when motion is detected, or temperature/humidity readings at an interval.
The project also includes sensor NodeMCU code in the [_sensors_](sensors/README.md) directory which can be used to generate events when motion is detected, or temperature/humidity readings at an interval.

## Building

Expand All @@ -53,13 +53,13 @@ The images can be built with Docker's [_buildx_](https://docs.docker.com/buildx/
```bash
# From the root of your checkout of PowerPi
# Build an image with buildx, the image version tags can be found in the service's package.json or pyproject.toml file.
docker buildx build --platform linux/arm/v7 --push -t MY_DOCKER_REGISTRY/powerpi-clacks-config:0.1.1 -f services/clacks-config/Dockerfile .
docker buildx build --platform linux/arm/v7 --push -t MY_DOCKER_REGISTRY/powerpi-config-server:1.0.0 -f services/config-server/Dockerfile .

# Or for 64-bit ARM
docker buildx build --platform linux/arm64 --push -t MY_DOCKER_REGISTRY/powerpi-clacks-config:0.1.1 -f services/clacks-config/Dockerfile .
docker buildx build --platform linux/arm64 --push -t MY_DOCKER_REGISTRY/powerpi-config-server:1.0.0 -f services/config-server/Dockerfile .

# Or x86-64
docker buildx build --platform linux/amd64 --push -t MY_DOCKER_REGISTRY/powerpi-clacks-config:0.1.1 -f services/clacks-config/Dockerfile .
docker buildx build --platform linux/amd64 --push -t MY_DOCKER_REGISTRY/powerpi-config-server:1.0.0 -f services/config-server/Dockerfile .
```

## Deployment
Expand Down
8 changes: 4 additions & 4 deletions controllers/energenie/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ This service expects the following environment variables to be set before it wil
- **MQTT_ADDRESS** - The URI to the MQTT instance to use, e.g. _mqtt://POWERPI_URL:1883_
- **ENERGENIE_DEVICE** - Which Energenie controller board to use, either ENER314 or ENER314-RT (default _ENER314-RT_).
- **DEVICE_FATAL** - Whether to kill the service if it's unable to communicate with the Energenie device, useful when debugging off the Raspberry Pi but should be true in production. (default _false_).
- **USE_CONFIG_FILE** - Use local config files instead of the files downloaded from GitHub by [_clacks-config_](../../services/clacks-config/README.md) (default _false_).
- **USE_CONFIG_FILE** - Use local config files instead of the files downloaded from GitHub by [_config-server_](../../services/config-server/README.md) (default _false_).
- **DEVICES_FILE** - When _USE_CONFIG_FILE_ is true, load the _devices.json_ from this path.
- **EVENTS_FILE** - When _USE_CONFIG_FILE_ is true, load the _events.json_ from this path.

### Configuration Files

This service requires two configuration files, both of which are described on the following [_clacks-config_](../../services/clacks-config/README.md) pages.
This service requires two configuration files, both of which are described on the following [_config-server_](../../services/config-server/README.md) pages.

- [devices.json](../../services/clacks-config/README.md#devicesjson)
- [events.json](../../services/clacks-config/README.md#eventsjson)
- [devices.json](../../services/config-server/README.md#devicesjson)
- [events.json](../../services/config-server/README.md#eventsjson)

### Kubernetes

Expand Down
8 changes: 4 additions & 4 deletions controllers/harmony/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ The Docker container can be built utilising _buildx_ as described in the [projec
This service expects the following environment variables to be set before it will start successfully. When using kubernetes these are already configured in the helm chart, however when running locally for testing we need to define these:

- **MQTT_ADDRESS** - The URI to the MQTT instance to use, e.g. _mqtt://POWERPI_URL:1883_
- **USE_CONFIG_FILE** - Use local config files instead of the files downloaded from GitHub by [_clacks-config_](../../services/clacks-config/README.md) (default _false_).
- **USE_CONFIG_FILE** - Use local config files instead of the files downloaded from GitHub by [_config-server_](../../services/config-server/README.md) (default _false_).
- **DEVICES_FILE** - When _USE_CONFIG_FILE_ is true, load the _devices.json_ from this path.
- **EVENTS_FILE** - When _USE_CONFIG_FILE_ is true, load the _events.json_ from this path.

### Configuration Files

This service requires two configuration files, both of which are described on the following [_clacks-config_](../../services/clacks-config/README.md) pages.
This service requires two configuration files, both of which are described on the following [_config-server_](../../services/config-server/README.md) pages.

- [devices.json](../../services/clacks-config/README.md#devicesjson)
- [events.json](../../services/clacks-config/README.md#eventsjson)
- [devices.json](../../services/config-server/README.md#devicesjson)
- [events.json](../../services/config-server/README.md#eventsjson)

## Testing

Expand Down
8 changes: 4 additions & 4 deletions controllers/lifx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ The Docker container can be built utilising _buildx_ as described in the [projec
This service expects the following environment variables to be set before it will start successfully. When using kubernetes these are already configured in the helm chart, however when running locally for testing we need to define these:

- **MQTT_ADDRESS** - The URI to the MQTT instance to use, e.g. _mqtt://POWERPI_URL:1883_
- **USE_CONFIG_FILE** - Use local config files instead of the files downloaded from GitHub by [_clacks-config_](../../services/clacks-config/README.md) (default _false_).
- **USE_CONFIG_FILE** - Use local config files instead of the files downloaded from GitHub by [_config-server_](../../services/config-server/README.md) (default _false_).
- **DEVICES_FILE** - When _USE_CONFIG_FILE_ is true, load the _devices.json_ from this path.
- **EVENTS_FILE** - When _USE_CONFIG_FILE_ is true, load the _events.json_ from this path.

### Configuration Files

This service requires two configuration files, both of which are described on the following [_clacks-config_](../../services/clacks-config/README.md) pages.
This service requires two configuration files, both of which are described on the following [_config-server_](../../services/config-server/README.md) pages.

- [devices.json](../../services/clacks-config/README.md#devicesjson)
- [events.json](../../services/clacks-config/README.md#eventsjson)
- [devices.json](../../services/config-server/README.md#devicesjson)
- [events.json](../../services/config-server/README.md#eventsjson)

## Testing

Expand Down
8 changes: 4 additions & 4 deletions controllers/macro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ The Docker container can be built utilising _buildx_ as described in the [projec
This service expects the following environment variables to be set before it will start successfully. When using kubernetes these are already configured in the helm chart, however when running locally for testing we need to define these:

- **MQTT_ADDRESS** - The URI to the MQTT instance to use, e.g. _mqtt://POWERPI_URL:1883_
- **USE_CONFIG_FILE** - Use local config files instead of the files downloaded from GitHub by [_clacks-config_](../../services/clacks-config/README.md) (default _false_).
- **USE_CONFIG_FILE** - Use local config files instead of the files downloaded from GitHub by [_config-server_](../../services/config-server/README.md) (default _false_).
- **DEVICES_FILE** - When _USE_CONFIG_FILE_ is true, load the _devices.json_ from this path.
- **EVENTS_FILE** - When _USE_CONFIG_FILE_ is true, load the _events.json_ from this path.

### Configuration Files

This service requires two configuration files, both of which are described on the following [_clacks-config_](../../services/clacks-config/README.md) pages.
This service requires two configuration files, both of which are described on the following [_config-server_](../../services/config-server/README.md) pages.

- [devices.json](../../services/clacks-config/README.md#devicesjson)
- [events.json](../../services/clacks-config/README.md#eventsjson)
- [devices.json](../../services/config-server/README.md#devicesjson)
- [events.json](../../services/config-server/README.md#eventsjson)

## Testing

Expand Down
8 changes: 4 additions & 4 deletions controllers/network/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ The Docker container can be built utilising _buildx_ as described in the [projec
This service expects the following environment variables to be set before it will start successfully. When using kubernetes these are already configured in the helm chart, however when running locally for testing we need to define these:

- **MQTT_ADDRESS** - The URI to the MQTT instance to use, e.g. _mqtt://POWERPI_URL:1883_
- **USE_CONFIG_FILE** - Use local config files instead of the files downloaded from GitHub by [_clacks-config_](../../services/clacks-config/README.md) (default _false_).
- **USE_CONFIG_FILE** - Use local config files instead of the files downloaded from GitHub by [_config-server_](../../services/config-server/README.md) (default _false_).
- **DEVICES_FILE** - When _USE_CONFIG_FILE_ is true, load the _devices.json_ from this path.
- **EVENTS_FILE** - When _USE_CONFIG_FILE_ is true, load the _events.json_ from this path.

### Configuration Files

This service requires two configuration files, both of which are described on the following [_clacks-config_](../../services/clacks-config/README.md) pages.
This service requires two configuration files, both of which are described on the following [_config-server_](../../services/config-server/README.md) pages.

- [devices.json](../../services/clacks-config/README.md#devicesjson)
- [events.json](../../services/clacks-config/README.md#eventsjson)
- [devices.json](../../services/config-server/README.md#devicesjson)
- [events.json](../../services/config-server/README.md#eventsjson)

## Testing

Expand Down
8 changes: 4 additions & 4 deletions controllers/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ This service expects the following environment variables to be set before it wil
- **I2C_DEVICE** - The path to the I2C device on the host, if you're using an original Pi you'll want to change this to _/dev/i2c-0_ as the bus id was changed with later revisions.(default _/dev/i2c-1_).
- **I2C_ADDRESS** - The I2C address of the PiJuice on the bus (default _0x14_).
- **DEVICE_FATAL** - Whether to kill the service if it's unable to communicate with the [PiJuice](https://www.pijuice.com) device or PWM fan, useful when debugging off the Raspberry Pi but should be true in production. (default _false_).
- **USE_CONFIG_FILE** - Use local config files instead of the files downloaded from GitHub by [_clacks-config_](../../services/clacks-config/README.md) (default _false_).
- **USE_CONFIG_FILE** - Use local config files instead of the files downloaded from GitHub by [_config-server_](../../services/config-server/README.md) (default _false_).
- **DEVICES_FILE** - When _USE_CONFIG_FILE_ is true, load the _devices.json_ from this path.
- **EVENTS_FILE** - When _USE_CONFIG_FILE_ is true, load the _events.json_ from this path.

### Configuration Files

This service requires two configuration files, both of which are described on the following [_clacks-config_](../../services/clacks-config/README.md) pages.
This service requires two configuration files, both of which are described on the following [_config-server_](../../services/config-server/README.md) pages.

- [devices.json](../../services/clacks-config/README.md#devicesjson)
- [events.json](../../services/clacks-config/README.md#eventsjson)
- [devices.json](../../services/config-server/README.md#devicesjson)
- [events.json](../../services/config-server/README.md#eventsjson)

### Kubernetes

Expand Down
8 changes: 4 additions & 4 deletions controllers/zigbee/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ This service expects the following environment variables to be set before it wil
- **MQTT_ADDRESS** - The URI to the MQTT instance to use, e.g. _mqtt://POWERPI_URL:1883_
- **ZIGBEE_DEVICE** - The path to the ZigBee device on the host (default _/dev/ttyACM0_).
- **DATABASE_PATH** - The path to the database which contains the ZigBee network configuration (default _/var/data/zigbee.db_).
- **USE_CONFIG_FILE** - Use local config files instead of the files downloaded from GitHub by [_clacks-config_](../../services/clacks-config/README.md) (default _false_).
- **USE_CONFIG_FILE** - Use local config files instead of the files downloaded from GitHub by [_config-server_](../../services/config-server/README.md) (default _false_).
- **DEVICES_FILE** - When _USE_CONFIG_FILE_ is true, load the _devices.json_ from this path.
- **EVENTS_FILE** - When _USE_CONFIG_FILE_ is true, load the _events.json_ from this path.

### Configuration Files

This service requires two configuration files, both of which are described on the following [_clacks-config_](../../services/clacks-config/README.md) pages.
This service requires two configuration files, both of which are described on the following [_config-server_](../../services/config-server/README.md) pages.

- [devices.json](../../services/clacks-config/README.md#devicesjson)
- [events.json](../../services/clacks-config/README.md#eventsjson)
- [devices.json](../../services/config-server/README.md#devicesjson)
- [events.json](../../services/config-server/README.md#eventsjson)

### Kubernetes

Expand Down
8 changes: 4 additions & 4 deletions kubernetes/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ apiVersion: v2
name: powerpi
description: A Helm chart for deploying the PowerPi home automation stack
type: application
version: 0.2.1
appVersion: 0.2.1
version: 0.2.2
appVersion: 0.2.2
dependencies:
# services
- name: clacks-config
version: 0.1.7
- name: config-server
version: 0.1.8
condition: global.config
- name: database
version: 0.1.3
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ microk8s kubectl create secret generic ihd-secret --namespace powerpi \
--from-file=ihd=./__SECRET_NAME__
```

- **github-secret** - A GitHub personal access token which allows _clacks-config_ to retrieve configuration files from a GitHub repository.
- **github-secret** - A GitHub personal access token which allows _config-server_ to retrieve configuration files from a GitHub repository.

```bash
microk8s kubectl create secret generic github-secret --namespace powerpi \
Expand Down
6 changes: 0 additions & 6 deletions kubernetes/charts/clacks-config/Chart.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions kubernetes/charts/config-server/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: config-server
description: A Helm chart for the PowerPi configuration server
type: application
version: 0.1.8
appVersion: 1.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Command" (list "yarn")
"Args" (list
"workspace"
"@powerpi/clacks-config"
"@powerpi/config-server"
"start:prd"
)
"PriorityClassName" "powerpi-critical"
Expand All @@ -27,6 +27,10 @@
"Name" "FILE_PATH"
"Value" .Values.path
)
(dict
"Name" "BRANCH"
"Value" .Values.branch
)
)
-}}
{{- include "powerpi.cron-job" (merge (dict "Params" $data) . ) -}}
File renamed without changes.
4 changes: 2 additions & 2 deletions kubernetes/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ global:
# whether to use FreeDNS or not
freeDNS: false

# whether to include the clacks-config service to get configuration from GitHub
# whether to include the config-server service to get configuration from GitHub
config: false

# whether to include the persistence service to store messages in a database
Expand Down Expand Up @@ -62,7 +62,7 @@ global:
# whether to include N3rgy energy monitoring support
energy-monitor: false

clacks-config:
config-server:
# the path to the config files in the GitHub repo
path: "kubernetes/config"

Expand Down
Loading

0 comments on commit 43fbb8e

Please sign in to comment.