Skip to content

Commit

Permalink
First attempt at conversion to home assistant addon
Browse files Browse the repository at this point in the history
  • Loading branch information
starsoccer committed Jan 25, 2024
1 parent cceca75 commit 90f1daf
Show file tree
Hide file tree
Showing 37 changed files with 88 additions and 48 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/github-actions-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "Publish"

on:
release:
types: [published]

jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v2.0.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Publish
uses: home-assistant/builder@master
with:
args: |
--all \
--docker-hub "ghcr.io/starsoccer" \
--image "energysmartbridge/{arch}" \
--target energysmartbridge
37 changes: 0 additions & 37 deletions .github/workflows/github-actions.yml

This file was deleted.

5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"*.yaml": "home-assistant"
}
}
16 changes: 7 additions & 9 deletions Dockerfile → energysmartbridge/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
FROM mono:latest AS build

WORKDIR /build
COPY ./EnergySmartBridge .
COPY ./src .
RUN nuget restore /build/EnergySmartBridge.sln
RUN msbuild /build/EnergySmartBridge.sln /t:Build /p:Configuration=Release
RUN mv /build/bin/Release /app

FROM nginx:1.24.0
#ENV NGINX_ENVSUBST_OUTPUT_DIR=/etc/nginx

RUN apt-get update && apt-get install -y openssl
RUN apt-get update && apt-get install -y openssl && apt-get install -y mono-devel

COPY energysmart-proxy/nginx.conf.template .
COPY nginx.conf.template .

RUN openssl req -nodes -new -x509 -sha1 -subj '/CN=energysmartwaterheater.com' -keyout /etc/nginx/energysmartwaterheater.com.key -out /etc/nginx/energysmartwaterheater.com.crt -days 3650

EXPOSE 443/tcp

RUN apt-get install -y mono-devel
COPY --from=build /app .
COPY --from=build /app/EnergySmartBridge.ini /config/EnergySmartBridge.ini
COPY startup.sh .
COPY run.sh .

EXPOSE 443/tcp

CMD ["sh", "startup.sh"]
CMD [ "sh", "run.sh" ]
31 changes: 31 additions & 0 deletions energysmartbridge/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "Energy Smart Bridge"
description: "Energy Smart Bridge"
version: "0.0.1"
slug: "energy_smart_bridge"
image: "ghcr.io/starsoccer/energysmartbridge/{arch}"
init: false
host_network: true
arch:
- aarch64
- amd64
- armv7
ports:
443/tcp: 443
options:
MQTT_PORT: 1883
MQTT_SERVER: null
MQTT_USERNAME: null
MQTT_PASSWORD: null
MQTT_PREFIX: "energysmart"
MQTT_DISCOVERY_PREFIX: "homeassistant"
HTTPS: 443
log_level: "info"
schema:
MQTT_PORT: port
MQTT_SERVER: str
MQTT_USERNAME: str
MQTT_PASSWORD: password
MQTT_PREFIX: str
MQTT_DISCOVERY_PREFIX: str
HTTPS: port
log_level: list(fatal|error|warn|info|debug|trace)
File renamed without changes.
12 changes: 12 additions & 0 deletions energysmartbridge/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
set -e

echo Listing Versions!
echo "nginx Version: $(nginx -v)"

for keyval in $(grep -E '": [^\{]' my.json | sed -e 's/: /=/' -e "s/\(\,\)$//"); do
echo "export $keyval"
eval export $keyval
done

#envsubst < /nginx.conf.template > /etc/nginx/nginx.conf;
exec nginx -g 'daemon off;' & mono EnergySmartBridge.exe -i -c /config/EnergySmartBridge.ini -e
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public static void LoadSettings(NameValueCollection settings)
Global.mqtt_password = settings.CheckEnv("mqtt_password");
Global.mqtt_prefix = settings.CheckEnv("mqtt_prefix") ?? "energysmart";
Global.mqtt_discovery_prefix = settings.CheckEnv("mqtt_discovery_prefix");

log.Debug("Trying to connect to " + Global.mqtt_server + " using username " + Global.mqtt_username);
}

private static string CheckEnv(this NameValueCollection settings, string name)
Expand Down
2 changes: 2 additions & 0 deletions repository.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: Energy Smart Bridge Repo
url: 'https://github.com/starsoccer/energysmartbridge'
2 changes: 0 additions & 2 deletions startup.sh

This file was deleted.

0 comments on commit 90f1daf

Please sign in to comment.