-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve error handling, Nightly build #44
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
8880a82
added nightly addon
761b356
fix run.sh
08eea50
add debug logging option
29ba244
minor comment change in dockerfile
6e713f7
use try_publish instead of publish to propagate connection failures i…
7e7314a
revert change in config.toml
d1c4337
add debug_logging to home assistant addon options
fa3953f
fix version in ha addon config.yaml
7e51ff9
version bump for nightly addon
c2a2589
add date to nightly build tag
d06b1f9
update nightly dockerfile
21a5568
run.sh bugfix
fc92a0b
bugfix for run.sh
4719bb1
Merge remote-tracking branch 'origin_orig/main'
dbf03e0
main addon version bump
150b698
cargo fmt
b214f8d
Merge remote-tracking branch 'origin_orig/main'
b3d45e5
revert source code changes, use env variable for debug logging
ae02abb
fix dockerfile
9b29d3a
revert debug logging via cli
0f8731f
update Dockerfile of nightly addon
63a60d5
minor bugfix for run.sh
eda9b16
fix dockerfile
442030c
update addon changelog
051b7ed
Merge remote-tracking branch 'origin_orig/main'
6494716
fix failing docker build
9eb7624
Merge remote-tracking branch 'origin_orig/main'
aa27b6c
bump home assistant nightly addon version
feeed80
Update main addon to latest version
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:/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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We haven't released 0.3 yet. 😀 I can fix the version number as part of the the next release. No need to rush.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I need to do a version bump in the addon, otherwise home assistant won't show that an update exists, so I've been setting the addon versions independently of the releases