-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve error handling, Nightly build (#44)
- Loading branch information
1 parent
84d21a0
commit bc713b8
Showing
15 changed files
with
248 additions
and
25 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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Publish multi platform nightly Docker image | ||
|
||
on: | ||
push: | ||
branches: ["*"] | ||
pull_request: | ||
branches: ["*"] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
push_to_registry: | ||
name: Push nightly Docker image to Docker Hub | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USER }} | ||
password: ${{ secrets.DOCKER_HUB_PASS }} | ||
|
||
- name: Get current date | ||
id: current_date | ||
run: echo "::set-output name=date::$(date +'%Y%m%d')" | ||
|
||
- name: Get the current Git commit hash | ||
id: git_hash | ||
run: echo "GIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 | ||
with: | ||
images: ${{ secrets.DOCKER_HUB_NAMESPACE }}/${{ secrets.DOCKER_HUB_REPOSITORY_NIGHTLY }} | ||
tags: | | ||
type=raw,value=nightly-${{ github.ref_name }}-${{ steps.current_date.outputs.date }} | ||
type=raw,value=latest | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64,linux/arm/v7 | ||
file: ./Dockerfile | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
build-args: GIT_HASH=${{ env.GIT_HASH }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). | ||
|
||
## [v0.4] | ||
Bugfixes and improvements | ||
|
||
## [v0.3] | ||
Add debug_logging option | ||
|
||
## [v0.2] | ||
Warning: breaking changes! The sensor identifiers have changed | ||
Implemented support for home assistant discovery | ||
Add extra sensors | ||
|
||
## [v0.1] | ||
Initial release |
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,16 @@ | ||
ARG BUILD_FROM | ||
|
||
# Use pre-built image to copy the binary from | ||
FROM dominikandreas/hms-mqtt-publisher-nightly:nightly-main-20231209 AS builder | ||
|
||
FROM $BUILD_FROM | ||
|
||
# Copy the compiled binary from the builder stage | ||
COPY --from=builder /usr/local/bin/hms-mqtt-publish /usr/local/bin/hms-mqtt-publish | ||
|
||
# Copy the run script into the container | ||
COPY run.sh /run.sh | ||
RUN chmod a+x /run.sh | ||
|
||
# When the container starts, run the script | ||
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,33 @@ | ||
# Home Assistant Add-on | ||
|
||
> Note: this is the nightly version of the add-on that is used for testing. | ||
This tool can directly run inside Home Assistant OS as an addon. To get started, add the URL of this repository to the add-on store in Home Assistant and install the add-on. Alternatively, you can also run it stand-alone on any machine that supports rust or docker (see section below). | ||
|
||
## Configuration | ||
|
||
To set up the add-on, fill in the following configuration parameters: | ||
|
||
- `inverter_host`: The hostname or IP address of your inverter. | ||
- `mqtt_broker_host`: The hostname or IP address of your MQTT broker. | ||
- `mqtt_username`: The username for your MQTT broker. | ||
- `mqtt_password`: The password for your MQTT broker. Keep this secret! | ||
- `mqtt_port`: The port of your MQTT broker (default is 1883 for unencrypted MQTT). | ||
|
||
## Example configuration | ||
|
||
```yaml | ||
inverter_host: "192.168.1.100" | ||
mqtt_broker_host: "core-mosquitto" | ||
mqtt_username: "yourusername" | ||
mqtt_password: "yourpassword" | ||
mqtt_port: 1883 | ||
``` | ||
## Note of caution | ||
Please note: The tool does not come with any guarantees and if by chance you fry your inverter with a funny series of bits, you are on your own. That being said, no inverters have been harmed during development. | ||
## Known limitations | ||
- One can only fetch updates approximately twice per minute. The inverter firmware seems to implement a mandatory wait period of a little more than 30 seconds. If one makes a request within 30 seconds of the previous one, then the inverter will reply with the previous reading and restart the countdown. It will also not send updated values to S-Miles Cloud if this happens. | ||
- The tools was developed for (and with an) HMS-800W-T2. It may work with the other inverters from the series, but is untested at the time of writing | ||
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: | ||
aarch64: ghcr.io/hassio-addons/debian-base:7.2.0 | ||
amd64: ghcr.io/hassio-addons/debian-base:7.2.0 | ||
armv7: ghcr.io/hassio-addons/debian-base:7.2.0 |
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,28 @@ | ||
--- | ||
name: Hoymiles HMS Wifi Addon (Nightly) | ||
version: 'v0.4' | ||
slug: ha-hoymiles-wifi-addon-nightly | ||
description: Publishes telemetry information from Hoymiles HMS-XXXXW-T2 micro-inverters to your home assistant MQTT broker | ||
url: https://github.com/dominikandreas/hms-mqtt-publisher/tree/main/ha-hoymiles-wifi-addon-nightly | ||
init: false | ||
arch: # List of supported architectures. | ||
- armv7 | ||
- aarch64 | ||
- amd64 | ||
startup: application # When the add-on should start. | ||
boot: auto # Boot options, auto or manual. | ||
services: ['mqtt:want'] | ||
options: # Default options value for the add-on. | ||
inverter_host: '' | ||
mqtt_broker_host: '' | ||
mqtt_username: '' | ||
mqtt_password: '' | ||
mqtt_port: 1883 | ||
debug_logging: false | ||
schema: # Schema validation for the options. | ||
inverter_host: str | ||
mqtt_broker_host: str? | ||
mqtt_username: str? | ||
mqtt_password: str? | ||
mqtt_port: int | ||
debug_logging: 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,53 @@ | ||
#!/usr/bin/with-contenv bashio | ||
|
||
# Enable strict mode for bash (exit on error, error on undefined variable, error if any pipeline element fails) | ||
set -euo pipefail | ||
# Fetch values from the add-on configuration by extracting it from /data/options.json | ||
|
||
HA_MQTT_BROKER_HOST=$(bashio::services mqtt "host") | ||
HA_MQTT_USERNAME=$(bashio::services mqtt "username") | ||
HA_MQTT_PASSWORD=$(bashio::services mqtt "password") | ||
|
||
INVERTER_HOST=$(bashio::config 'inverter_host') | ||
MQTT_BROKER_HOST=$(bashio::config 'mqtt_broker_host') | ||
MQTT_USERNAME=$(bashio::config 'mqtt_username') | ||
MQTT_PASSWORD=$(bashio::config 'mqtt_password') | ||
MQTT_PORT=$(bashio::config 'mqtt_port') | ||
DEBUG_LOGGING=$(bashio::config 'debug_logging') | ||
|
||
# Use bashio::config values if they are defined, otherwise fall back to bashio::services values | ||
MQTT_BROKER_HOST=${MQTT_BROKER_HOST:-$HA_MQTT_BROKER_HOST} | ||
MQTT_USERNAME=${MQTT_USERNAME:-$HA_MQTT_USERNAME} | ||
MQTT_PASSWORD=${MQTT_PASSWORD:-$HA_MQTT_PASSWORD} | ||
DEBUG_LOGGING=${DEBUG_LOGGING:-'false'} | ||
|
||
|
||
# Check if the required configs are provided | ||
if [[ -z "$INVERTER_HOST" ]]; then | ||
echo "The inverter_host is not configured." | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "$MQTT_BROKER_HOST" ]]; then | ||
echo "The mqtt_broker_host is not configured." | ||
exit 1 | ||
fi | ||
|
||
# Create the configuration file | ||
cat <<EOF > ./config.toml | ||
inverter_host = "$INVERTER_HOST" | ||
[home_assistant] | ||
host = "$MQTT_BROKER_HOST" | ||
username = "$MQTT_USERNAME" | ||
password = "$MQTT_PASSWORD" | ||
port = $MQTT_PORT | ||
EOF | ||
|
||
# if DEBUG_LOGGING is true, set the RUST_LOG=debug environment variable to enable debug logging | ||
if [[ "$DEBUG_LOGGING" == "true" ]]; then | ||
export RUST_LOG=debug | ||
fi | ||
|
||
# Execute the application | ||
/usr/local/bin/hms-mqtt-publish |
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
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