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

Home Assistant Add-on #20

Merged
merged 6 commits into from
Nov 9, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions ha-hoymiles-wifi-addon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# 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.1]
Initial release
16 changes: 16 additions & 0 deletions ha-hoymiles-wifi-addon/Dockerfile
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 dennisosrm/hms-mqtt-publisher:v0.1 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" ]
31 changes: 31 additions & 0 deletions ha-hoymiles-wifi-addon/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Home Assistant Add-on

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

5 changes: 5 additions & 0 deletions ha-hoymiles-wifi-addon/build.yaml
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
25 changes: 25 additions & 0 deletions ha-hoymiles-wifi-addon/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Hoymiles HMS Wifi Addon
version: '0.1'
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
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.
options: # Default options value for the add-on.
inverter_host: ''
mqtt_broker_host: ''
mqtt_username: ''
mqtt_password: ''
mqtt_port: 1883
schema: # Schema validation for the options.
inverter_host: str
mqtt_broker_host: str
mqtt_username: str
mqtt_password: str
mqtt_port: int
Binary file added ha-hoymiles-wifi-addon/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ha-hoymiles-wifi-addon/logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions ha-hoymiles-wifi-addon/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/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
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')


# 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

if [[ -z "$MQTT_USERNAME" ]]; then
echo "The mqtt_username is not configured."
exit 1
fi

if [[ -z "$MQTT_PASSWORD" ]]; then
echo "The mqtt_password is not configured."
exit 1
fi

# Execute the application with the configuration
/usr/local/bin/hms-mqtt-publish "$INVERTER_HOST" "$MQTT_BROKER_HOST" "$MQTT_USERNAME" "$MQTT_PASSWORD" "$MQTT_PORT"
5 changes: 5 additions & 0 deletions repository.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "HA Hoymiles Wifi Addon",
"url": "https://github.com/dominikandreas/hms-mqtt-publisher",
"maintainer": "Dominik Andreas <13525040+dominikandreas@users.noreply.github.com>"
}