Skip to content
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

Update ha addons #121

Merged
merged 8 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/dockerhub-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ jobs:
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ secrets.DOCKER_HUB_NAMESPACE }}/${{ secrets.DOCKER_HUB_REPOSITORY_NIGHTLY }}
images: ${{ secrets.DOCKER_HUB_NAMESPACE }}/${{ secrets.DOCKER_HUB_REPOSITORY_NIGHTLY }}-${{ github.ref_name }}
tags: |
type=raw,value=nightly-${{ github.ref_name }}-${{ steps.current_date.outputs.date }}
type=raw,value=nightly-${{ steps.current_date.outputs.date }}
type=raw,value=latest
- name: Build and push Docker image
Expand Down
3 changes: 3 additions & 0 deletions ha-hoymiles-wifi-addon-nightly/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ 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.5]
Add update interval option

## [v0.4]
Bugfixes and improvements

Expand Down
2 changes: 1 addition & 1 deletion ha-hoymiles-wifi-addon-nightly/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG BUILD_FROM

# Use pre-built image to copy the binary from
FROM dominikandreas/hms-mqtt-publisher-nightly:nightly-main-20231209 AS builder
FROM dominikandreas/hms-mqtt-publisher-nightly-main:latest AS builder

FROM $BUILD_FROM

Expand Down
27 changes: 21 additions & 6 deletions ha-hoymiles-wifi-addon-nightly/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
# Home Assistant Add-on
# Home Assistant Add-on - Nightly

> Note: this is the nightly version of the add-on that is used for testing.
> THIS ADDON SHOULD ONLY BE USED FOR TESTING!

> This is the nightly version of the add-on that is used for testing,
> it references the latest build of the underlying rust application
> and may not always work.

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:
To set up the add-on, fill in the IP of the inverter host:

- `inverter_host`: The hostname or IP address of your inverter.

The following mqtt options can be acquired via the home assistant API if available:

- `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).

The update_interval setting controls the frequency of the updates. This should not be
set to a value less than 30 seconds (see limitations below), any smaller values will be ignored.

- `update_interval: 60500`: The interval in milliseconds between updates.

## Example configuration

```yaml
Expand All @@ -22,12 +34,15 @@ mqtt_broker_host: "core-mosquitto"
mqtt_username: "yourusername"
mqtt_password: "yourpassword"
mqtt_port: 1883
update_interval: 30500
```

## 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.

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

- 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, 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
4 changes: 3 additions & 1 deletion ha-hoymiles-wifi-addon-nightly/config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Hoymiles HMS Wifi Addon (Nightly)
version: 'v0.4'
version: 'v0.5'
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
Expand All @@ -18,11 +18,13 @@ options: # Default options value for the add-on.
mqtt_username: ''
mqtt_password: ''
mqtt_port: 1883
update_interval: 60500
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
update_interval: int
debug_logging: bool
20 changes: 15 additions & 5 deletions ha-hoymiles-wifi-addon-nightly/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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')
UPDATE_INTERVAL=$(bashio::config 'update_interval')
DEBUG_LOGGING=$(bashio::config 'debug_logging')

# Use bashio::config values if they are defined, otherwise fall back to bashio::services values
Expand All @@ -24,18 +25,27 @@ 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
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
echo "The mqtt_broker_host is not configured."
exit 1
fi

# print a warning if update interval is < 60500
if [[ "$UPDATE_INTERVAL" -lt 60500 ]]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "The update_interval is set to a value lower than 60500."
echo "This is not recommended and may cause the inverter to become unresponsive."
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
fi

# Create the configuration file
cat <<EOF > ./config.toml
inverter_host = "$INVERTER_HOST"
update_interval = $UPDATE_INTERVAL
[home_assistant]
host = "$MQTT_BROKER_HOST"
Expand All @@ -46,7 +56,7 @@ 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
export RUST_LOG=debug
fi

# Execute the application
Expand Down
4 changes: 4 additions & 0 deletions ha-hoymiles-wifi-addon/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ 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.5]
Add update interval option
Update to v0.4 of the underlying rust application

## [v0.4]
Bugfixes and improvements

Expand Down
19 changes: 15 additions & 4 deletions ha-hoymiles-wifi-addon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@ This tool can directly run inside Home Assistant OS as an addon. To get started,

## Configuration

To set up the add-on, fill in the following configuration parameters:
To set up the add-on, fill in the IP of the inverter host:

- `inverter_host`: The hostname or IP address of your inverter.

The following mqtt options can be acquired via the home assistant API if available:

- `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).

The update_interval setting controls the frequency of the updates. This should not be
set to a value less than 30 seconds (see limitations below), any smaller values will be ignored.

- `update_interval: 60500`: The interval in milliseconds between updates.

## Example configuration

```yaml
Expand All @@ -20,12 +28,15 @@ mqtt_broker_host: "core-mosquitto"
mqtt_username: "yourusername"
mqtt_password: "yourpassword"
mqtt_port: 1883
update_interval: 30500
```
## 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.
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
- 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, 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
6 changes: 4 additions & 2 deletions ha-hoymiles-wifi-addon/config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: Hoymiles HMS Wifi Addon
version: 'v0.3'
version: 'v0.5'
slug: ha-hoymiles-wifi-addon
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/master/ha-hoymiles-wifi-addon
url: https://github.com/DennisOSRM/hms-mqtt-publisher/tree/master/ha-hoymiles-wifi-addon
init: false
arch: # List of supported architectures.
- armv7
Expand All @@ -18,11 +18,13 @@ options: # Default options value for the add-on.
mqtt_username: ''
mqtt_password: ''
mqtt_port: 1883
update_interval: 60500
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
update_interval: int
debug_logging: bool
20 changes: 15 additions & 5 deletions ha-hoymiles-wifi-addon/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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')
UPDATE_INTERVAL=$(bashio::config 'update_interval')
DEBUG_LOGGING=$(bashio::config 'debug_logging')

# Use bashio::config values if they are defined, otherwise fall back to bashio::services values
Expand All @@ -24,18 +25,27 @@ 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
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
echo "The mqtt_broker_host is not configured."
exit 1
fi

# print a warning if update interval is < 60500
if [[ "$UPDATE_INTERVAL" -lt 60500 ]]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "The update_interval is set to a value lower than 60500."
echo "This is not recommended and may cause the inverter to become unresponsive."
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
fi

# Create the configuration file
cat <<EOF > ./config.toml
inverter_host = "$INVERTER_HOST"
update_interval = $UPDATE_INTERVAL
[home_assistant]
host = "$MQTT_BROKER_HOST"
Expand All @@ -46,7 +56,7 @@ 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
export RUST_LOG=debug
fi

# Execute the application
Expand Down
Loading