-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from atbore-phx/feat/ha
Adding Home Assistant add-ons
- Loading branch information
Showing
23 changed files
with
340 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,11 @@ on: | |
|
||
permissions: | ||
contents: write | ||
packages: write | ||
id-token: write | ||
|
||
jobs: | ||
goreleaser: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
|
@@ -25,4 +27,21 @@ jobs: | |
version: latest | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
- name: copy binary to local ha folder | ||
run: | | ||
mkdir home-assistant/addons/sbam/bin/ | ||
cp -v dist/sbam_linux_amd64_v1/bin/sbam home-assistant/addons/sbam/bin/ | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Publish build - Home Assistant builder | ||
uses: home-assistant/[email protected] | ||
with: | ||
args: | | ||
--amd64 \ | ||
--target /data/home-assistant/addons/sbam \ | ||
--addon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
*.so | ||
*.dylib | ||
bin/ | ||
|
||
home-assistant/addons/sbam/bin/ | ||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ builds: | |
binary: bin/sbam | ||
env: | ||
- CGO_ENABLED=0 | ||
|
||
changelog: | ||
sort: asc | ||
filters: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[sbam](https://github.com/atbore-phx/sbam/releases/latest) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[sbam](https://github.com/atbore-phx/sbam) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
ARG BUILD_FROM | ||
FROM $BUILD_FROM | ||
|
||
# Copy data for add-on | ||
COPY run.sh / | ||
RUN chmod a+x /run.sh | ||
|
||
COPY bin/sbam /usr/bin/ | ||
RUN chmod a+x /usr/bin/sbam | ||
|
||
CMD [ "/run.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[sbam](https://github.com/atbore-phx/sbam) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"build_from": { | ||
"amd64": "ghcr.io/home-assistant/amd64-base:3.19" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "sbam", | ||
"version": "latest", | ||
"slug": "sbam", | ||
"init": "false", | ||
"description": "Smart Battery Avanced Manager", | ||
"arch": [ | ||
"amd64" | ||
], | ||
"url": "https://github.com/atbore-phx/sbam", | ||
"image": "ghcr.io/atbore-phx/ha-sbam", | ||
"options": { | ||
"url": "https://api.solcast.com.au/rooftop_sites/<YOUR-SITE>/forecasts?format=json", | ||
"apikey": "", | ||
"fronius_ip": "", | ||
"start_hr": "00:00", | ||
"end_hr": "06:00", | ||
"crontab": "00 00-05 * * *", | ||
"pw_consumption": "11000", | ||
"max_charge": "3500", | ||
"pw_batt_reserve": "4000", | ||
"defaults": "true" | ||
}, | ||
"schema": { | ||
"url": "str", | ||
"apikey": "password", | ||
"fronius_ip": "match(^((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)(\\.(?!$)|$)){4}$)", | ||
"start_hr": "match(^([01]?[0-9]|2[0-3]):[0-5][0-9]$)", | ||
"end_hr": "match(^([01]?[0-9]|2[0-3]):[0-5][0-9]$)", | ||
"crontab": "match(^((((\\d+,)+\\d+|(\\d+(\/|-|#)\\d+)|\\d+L?|\\*(\/\\d+)?|L(-\\d+)?|\\?|[A-Z]{3}(-[A-Z]{3})?) ?){5,7})|(@(annually|yearly|monthly|weekly|daily|hourly|reboot))|(@every (\\d+(ns|us|µs|ms|s|m|h))+)$)", | ||
"pw_consumption": "float", | ||
"max_charge": "float", | ||
"pw_batt_reserve": "float", | ||
"defaults": "bool" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/with-contenv bashio | ||
|
||
export URL=$(bashio::config 'url') | ||
export APIKEY=$(bashio::config 'apikey') | ||
export FRONIUS_IP=$(bashio::config 'fronius_ip') | ||
export START_HR=$(bashio::config 'start_hr') | ||
export END_HR=$(bashio::config 'end_hr') | ||
export CRONTAB=$(bashio::config 'crontab') | ||
export PW_CONSUMPTION=$(bashio::config 'pw_consumption') | ||
export MAX_CHARGE=$(bashio::config 'max_charge') | ||
export PW_BATT_RESERVE=$(bashio::config 'pw_batt_reserve') | ||
export DEFAULTS=$(bashio::config 'defaults') | ||
|
||
sbam schedule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
BUILDCONTAINER_DATA_PATH="/data" | ||
PATHTOBUILD="$BUILDCONTAINER_DATA_PATH" | ||
ARCH=amd64 | ||
|
||
|
||
PROJECTDIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/sbam | ||
ROOTDIR=$PROJECTDIR/../../../ | ||
cd $PRROOTDIROJECTDIR/../../../ | ||
make build | ||
cd - | ||
|
||
|
||
rm -rf $PROJECTDIR/bin | ||
mkdir -p $PROJECTDIR/bin | ||
cp $ROOTDIR/bin/sbam $PROJECTDIR/bin/ | ||
|
||
echo "project directory is $PROJECTDIR" | ||
echo "build container data path is $BUILDCONTAINER_DATA_PATH" | ||
echo "build container target build path is $PATHTOBUILD" | ||
CMD="docker run --rm -ti --name hassio-builder --privileged -v $PROJECTDIR:$BUILDCONTAINER_DATA_PATH -v /var/run/docker.sock:/var/run/docker.sock:ro homeassistant/amd64-builder --target $PATHTOBUILD --$ARCH --test --docker-hub local" | ||
echo "$CMD" | ||
$CMD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.