Skip to content

Commit

Permalink
feat: test add ha-addon func
Browse files Browse the repository at this point in the history
  • Loading branch information
Dim145 committed May 29, 2024
1 parent 24e12ae commit ce038eb
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
README.md

addon
repository.json
19 changes: 19 additions & 0 deletions addon/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM dim145/hariane2mqtt:latest AS base


COPY entrypoint.sh /addon_entrypoint.sh

RUN chmod +x /addon_entrypoint.sh

VOLUME /data

ENTRYPOINT ["/addon_entrypoint.sh"]

############
# 5 Labels #
############

LABEL \
io.hass.version="0.1.0" \
io.hass.type="addon" \
io.hass.arch="armv7|amd64|arm64"
47 changes: 47 additions & 0 deletions addon/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: "Hariane 2 MQTT"
description: "Extracts Hariane water data into MQTT a.o."
version: 0.1.0
slug: "hariane_2_mqtt"
url: https://github.com/Dim145/Hariane2Mqtt
init: false
homeassistant_api: true
arch:
- aarch64
- amd64
- armhf
- armv7
- i386
map:
- addon_config:rw
- addon_configs:rw
- homeassistant_config:rw
- all_addon_configs:rw
services:
- mqtt:need
options:
log_level: info
debug: true
cron: "0 * * * *"
hariane_num_contrat: ""
hariane_password: ""
hariane_username: ""
mqtt_client_id: harianne2mqtt_client
mqtt_host: ""
mqtt_password: ""
mqtt_port: 1883
mqtt_topic: homeassistant
mqtt_username: ""
schema:
log_level: list(trace|debug|info|notice|warning|error|fatal)?
debug: boolean?
cron: string?
hariane_password: string?
hariane_username: string?
hariane_num_contrat: string?
mqtt_host: string?
mqtt_port: int?
mqtt_username: string?
mqtt_password: string?
mqtt_client_id: string?
mqtt_topic: string?

29 changes: 29 additions & 0 deletions addon/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

# Exit if /config is not mounted
if [ ! -d /config ]; then
echo "Error: /config not mounted"
exit 0
fi

# Default location
CONFIGSOURCE="/config/gazpar_2_mqtt/config.yaml"

mkdir -p /config/gazpar_2_mqtt

# transform each config.yaml entries to env variables
if [ -f $CONFIGSOURCE ]; then
echo "Loading config from $CONFIGSOURCE"
while IFS=': ' read -r key value
do
if [ ! -z "$key" ] && [ ! -z "$value" ]; then
key=$(echo $key | tr '[:lower:]' '[:upper:]' | tr '-' '_' | tr '.' '_')
value=$(echo $value | sed 's/^ *//g' | sed 's/ *$//g')

# add to env for cron jobs
export $key=$value
fi
done < $CONFIGSOURCE
fi

exec "$@"
Binary file added addon/icon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added addon/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions addon/translations/en.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
configuration:
log_level:
name: Log level
description: >-
Controls the level of log details the add-on provides.
debug:
name: Debug
description: >-
Enable debug mode
cron:
name: Cron
description: >-
Cron schedule
hariane_password:
name: Hariane password
description: >-
Hariane website password.
hariane_username:
name: Hariane username
description: >-
Hariane website username.
hariane_num_contrat:
name: Hariane contract number
description: >-
Hariane contract number. You can find it on your Hariane account or on your bill.
mqtt_host:
name: MQTT host
description: >-
MQTT broker host. You can use the IP address or the hostname.
mqtt_port:
name: MQTT port
description: >-
MQTT broker port.
mqtt_username:
name: MQTT username
description: >-
MQTT broker username.
mqtt_password:
name: MQTT password
description: >-
MQTT broker password.
mqtt_client_id:
name: MQTT client ID
description: >-
Unique ID.
mqtt_topic:
name: MQTT topic
description: >-
Base topic to publish the data. Use your topic configured in MQTT service to permit Home Assistant to read the data.
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@
MQTT_HOST: "XXX.XXX.XXX.XXX"
MQTT_PASSWORD: "123456789"
MQTT_PORT: 1883
CRON: 0 * * * *
CRON: 0 * * * *
MQTT_TOPIC: homeassistant
MQTT_USERNAME: xxxxx
5 changes: 5 additions & 0 deletions repository.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Hariane 2 Mqtt ",
"url": "hhttps://github.com/Dim145/Hariane2Mqtt",
"maintainer": "Dim145"
}

0 comments on commit ce038eb

Please sign in to comment.