From f56d9dbc47a6125f48b407feddbbad038ac5bc33 Mon Sep 17 00:00:00 2001
From: Jan-Henrik Bruhn <hi@jhbruhn.de>
Date: Mon, 6 Feb 2023 22:36:21 +0100
Subject: [PATCH] Add config options

---
 epaper-station/Dockerfile                              |  2 +-
 epaper-station/config.yaml                             | 10 +++++-----
 .../rootfs/etc/services.d/epaper-station/run           |  8 ++++++++
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/epaper-station/Dockerfile b/epaper-station/Dockerfile
index 93fc3a7..67d981b 100644
--- a/epaper-station/Dockerfile
+++ b/epaper-station/Dockerfile
@@ -1,7 +1,7 @@
 ARG BUILD_FROM=ghcr.io/hassio-addons/base-python/amd64:9.0.1
 FROM ${BUILD_FROM}
 
-ADD "https://github.com/jhbruhn/ZBS_Flasher/archive/refs/heads/config_image_format.tar.gz" /src.tar.gz
+ADD "https://github.com/jhbruhn/ZBS_Flasher/archive/refs/heads/database_path_config.tar.gz" /src.tar.gz
 RUN mkdir /src && tar xvfz /src.tar.gz -C /src --strip-components=1
 RUN mv /src/CC2531_station/epaper_station_websocket/ /app
 
diff --git a/epaper-station/config.yaml b/epaper-station/config.yaml
index eab6067..66b7a57 100644
--- a/epaper-station/config.yaml
+++ b/epaper-station/config.yaml
@@ -1,6 +1,6 @@
 ---
 name: EPaper Station
-version: 1.0.0.2
+version: 1.0.0.3
   #image: ghcr.io/maxwinterstein/homeassistant-addon-toogoodtogo-ha-mqtt-bridge-{arch}
 slug: epaper-station 
 description: Publish Pictures to EPaper pricetags
@@ -10,11 +10,11 @@ arch:
   - armv7
   - aarch64
 options:
-  serial:
-    port: ""
+  serial_port: ""
+  channel: 25
 schema:
-  serial:
-    port: str
+  serial_port: str
+  channel: "int(11, 25)"
 stage: experimental
 url: https://github.com/jhbruhn/ZBS_Flasher
 hassio_api: true
diff --git a/epaper-station/rootfs/etc/services.d/epaper-station/run b/epaper-station/rootfs/etc/services.d/epaper-station/run
index 29a9178..347ca85 100644
--- a/epaper-station/rootfs/etc/services.d/epaper-station/run
+++ b/epaper-station/rootfs/etc/services.d/epaper-station/run
@@ -1,4 +1,12 @@
 #!/usr/bin/with-contenv bashio
+bashio::log.info "Reading config..."
+CONFIG_PATH=/data/options.json
+
+EPS_CHANNEL="$(bashio::config 'channel')"
+EPS_PORT="$(bashio::config 'serial_port')"
+EPS_IMAGE_WORKDIR="/tmp"
+EPS_DATABASE_DIR="/data/database/"
+mkdir -p $EPS_DATABASE_DIR
 
 bashio::log.info "Starting epaper station..."
 exec python /app/station.py