Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
christian1180 committed Oct 2, 2024
2 parents 4c323d4 + 8c169e1 commit 71225ea
Show file tree
Hide file tree
Showing 8 changed files with 287 additions and 5 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Docker Image Homehub

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
attestations: write
id-token: write
#
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see "[AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds)."
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM alpine:latest
LABEL description="Alpine based image with apache2 and php8 for HomeHub."

# Setup apache and php
RUN apk --no-cache --update \
add apache2 \
curl \
php83-apache2 \
php83-curl \
php83-xml \
php83-simplexml \
php83-mbstring \
php83-ctype \
&& mkdir /htdocs

COPY ./ /htdocs/
COPY docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh

EXPOSE 80

HEALTHCHECK CMD wget -q --no-cache --spider localhost

ENTRYPOINT ["/docker-entrypoint.sh"]
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,31 @@ Bei folgenden Komponenten lässt sich durch Angabe von ``"showtime":"true"`` die
- Program
- SysVar

## Docker Integration
```
docker run \
-d \
--name=HomeHub \
--restart unless-stopped \
-p 8080:80 \
-e TZ=Europe/Berlin \
-v /FOLDER/OF/YOUR/CONFIG:/htdocs/config \
ghcr.io/etofi/homehub_docker:master
```

Verfügbare Parameters im Detail:

| Parameter | Optional | Beispiel | Erklärung |
| ---- | --- | --- | --- |
| `TIMEZONE` | yes | Europe/Berlin | Timezone im Container |
| `-p` | no | 80:8080 | Zuweisung des Apache2 Port innerhalb dieses Containers auf den Docker-Host Port (Bridge Mode). Mit dieser Konfiguration kann HomeHub dann über Port 8080 des Docker-Hosts erreicht werden, z. B. 192.168.178.100:8080|

Volumes:

| Volume | Erklärung |
| ---- | --- |
| `/FOLDER/OF/YOUR/CONFIG` | Das Verzeichnis /htdocs/config, in dem die HomeHub-Einstellungen gespeichert werden sollen. Dieser Ordner befindet sich auf dem PC, auf dem Docker ausgeführt wird und die Dateien aus dem Verzeichnis config werden dort abgelegt. Sie werden dann automatisch an die HomeHub-Docker-Instanz weitergeleitet. |


## Lizenzen
HomeHub nutzt [jQuery](https://jquery.com/license/), [Chartjs](Chartjs.org), [knx-uf-iconset](https://github.com/OpenAutomationProject/knx-uf-iconset), [Bootstrap](https://getbootstrap.com/)
75 changes: 75 additions & 0 deletions components/HmIP-eTRV-3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php
function HmIP_eTRV_3($component) {

global $export;
$obj = $export;
$key = array_search(substr($component['address'], 0, -1)."0", array_column($obj['channels'], 'address'));
foreach($obj['channels'][$key]['datapoints'] as $datapoint)
{ $status_component[$datapoint['type']] = $datapoint['ise_id']; }

if ($component['parent_device_interface'] == 'HmIP-RF' && $component['visible'] == 'true' && isset($component['CONTROL_MODE'])) {
$modalId = mt_rand();
if (!isset($component['color'])) $component['color'] = '#00CC33';
return '<div class="hh" style=\'border-left-color: '.$component['color'].'; border-left-style: solid;\'>'
. '<div data-toggle="collapse" data-target="#' . $modalId . '">'
. '<div class="pull-left"><img src="icon/' . $component["icon"] . '" class="icon">' . $component['name'] . '</div>'
. '<div class="pull-right">'
. '<span class="info" data-id="' . $status_component['LOW_BAT'] . '" data-component="' . $component['component'] . '" data-datapoint="LOW_BAT"></span>'
. '<span class="info" data-id="' . $component['ACTUAL_TEMPERATURE'] . '" data-component="' . $component['component'] . '" data-datapoint="ACTUAL_TEMPERATURE"></span>'
. '<span class="info" data-id="' . $component['SET_POINT_TEMPERATURE'] . '" data-component="' . $component['component'] . '" data-datapoint="SET_POINT_TEMPERATURE"></span>'
. '<span class="info" data-id="' . $component['LEVEL'] . '" data-component="' . $component['component'] . '" data-datapoint="LEVEL"></span>'
. '<span class="info" data-id="' . $component['WINDOW_STATE'] . '" data-component="' . $component['component'] . '" data-datapoint="WINDOW_STATE"></span>'
. '<span class="info set btn-icon" data-id="' . $component['SET_POINT_MODE'] . '" data-component="' . $component['component'] . '" data-datapoint="SET_POINT_MODE" data-set-id="" data-set-value=""></span>'
. '<span class="info set btn-icon" data-id="' . $component['ACTIVE_PROFILE'] . '" data-component="' . $component['component'] . '" data-datapoint="ACTIVE_PROFILE" data-set-id="" data-set-value=""></span>'
. '</div>'
. '<div class="clearfix"></div>'
. '</div>'
. '<div class="hh2 collapse" id="' . $modalId . '">
<div class="row text-center">'
. '<div class="form-inline">Temperatur: '
. '<div class="input-group">'
. '<input type="number" name="' . $component['SET_POINT_TEMPERATURE'] . '" min="4.5" max="30.5" step="0.5" class="form-control" placeholder="Zahl eingeben">'
. '<span class="input-group-btn">'
. '<button class="btn btn-primary set" data-datapoint="4" data-set-id="' . $component['SET_POINT_TEMPERATURE'] . '" data-set-value="">OK</button>'
. '</span>'
. '</div>'
. '&nbsp;&nbsp;&nbsp;Heizprofil: '
. '<div class="btn-group">'
. '<button type="button" class="btn btn-primary set" data-set-id="' . $component['ACTIVE_PROFILE'] . '" data-set-value="1">'
. '1'
. '</button>'
. '<button type="button" class="btn btn-primary set" data-set-id="' . $component['ACTIVE_PROFILE'] . '" data-set-value="2">'
. '2'
. '</button>'
. '<button type="button" class="btn btn-primary set" data-set-id="' . $component['ACTIVE_PROFILE'] . '" data-set-value="3">'
. '3'
. '</button>'
. '</div>'
. '&nbsp;&nbsp;&nbsp;K&uuml;hlprofil: '
. '<div class="btn-group">'
. '<button type="button" class="btn btn-primary set" data-set-id="' . $component['ACTIVE_PROFILE'] . '" data-set-value="4">'
. '4'
. '</button>'
. '<button type="button" class="btn btn-primary set" data-set-id="' . $component['ACTIVE_PROFILE'] . '" data-set-value="5">'
. '5'
. '</button>'
. '<button type="button" class="btn btn-primary set" data-set-id="' . $component['ACTIVE_PROFILE'] . '" data-set-value="6">'
. '6'
. '</button>'
. '</div>'
. '</div>'
. '</div>'
. '<div class="row text-center top15">'
. '<div class="btn-group">'
. '<button type="button" class="btn btn-primary set" data-set-id="' . $component['CONTROL_MODE'] . '" data-set-value="0">'
. 'Auto'
. '</button>'
. '<button type="button" class="btn btn-primary set" data-set-id="' . $component['CONTROL_MODE'] . '" data-set-value="1">'
. 'Manu'
. '</button>'
. '</div>'
. '</div>'
. '</div>'
. '</div>';
}
}
18 changes: 15 additions & 3 deletions components/HmIP-eTRV-F.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function HmIP_eTRV_F($component) {
. '<button class="btn btn-primary set" data-datapoint="4" data-set-id="' . $component['SET_POINT_TEMPERATURE'] . '" data-set-value="">OK</button>'
. '</span>'
. '</div>'
. '&nbsp;&nbsp;&nbsp;Profil: '
. '&nbsp;&nbsp;&nbsp;Heizprofil: '
. '<div class="btn-group">'
. '<button type="button" class="btn btn-primary set" data-set-id="' . $component['ACTIVE_PROFILE'] . '" data-set-value="1">'
. '1'
Expand All @@ -44,8 +44,20 @@ function HmIP_eTRV_F($component) {
. '<button type="button" class="btn btn-primary set" data-set-id="' . $component['ACTIVE_PROFILE'] . '" data-set-value="3">'
. '3'
. '</button>'
. '</div>'
. '</div>'
. '</div>'
. '&nbsp;&nbsp;&nbsp;K&uuml;hlprofil: '
. '<div class="btn-group">'
. '<button type="button" class="btn btn-primary set" data-set-id="' . $component['ACTIVE_PROFILE'] . '" data-set-value="4">'
. '4'
. '</button>'
. '<button type="button" class="btn btn-primary set" data-set-id="' . $component['ACTIVE_PROFILE'] . '" data-set-value="5">'
. '5'
. '</button>'
. '<button type="button" class="btn btn-primary set" data-set-id="' . $component['ACTIVE_PROFILE'] . '" data-set-value="6">'
. '6'
. '</button>'
. '</div>'
. '</div>'
. '</div>'
. '<div class="row text-center top15">'
. '<div class="btn-group">'
Expand Down
4 changes: 4 additions & 0 deletions config/mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,10 @@
"name": "HmIP-eTRV-F",
"icon": "sani_heating.png"
},
{
"name": "HmIP-eTRV-3",
"icon": "sani_heating.png"
},
{
"name": "HmIP-eTRV-2I9F",
"icon": "sani_heating.png"
Expand Down
41 changes: 41 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh

# Exit on non defined variables and on non zero exit codes
set -eu

SERVER_ADMIN="${SERVER_ADMIN:-you@example.com}"
HTTP_SERVER_NAME="${HTTP_SERVER_NAME:-www.example.com}"
HTTPS_SERVER_NAME="${HTTPS_SERVER_NAME:-www.example.com}"
LOG_LEVEL="${LOG_LEVEL:-info}"
TZ="${TZ:-UTC}"
PHP_MEMORY_LIMIT="${PHP_MEMORY_LIMIT:-256M}"

echo 'Updating configurations'

# Change Server Admin, Name, Document Root and Startpage
sed -i "s/ServerAdmin\ [email protected]/ServerAdmin\ ${SERVER_ADMIN}/" /etc/apache2/httpd.conf
sed -i "s/#ServerName\ www.example.com:80/ServerName\ ${HTTP_SERVER_NAME}/" /etc/apache2/httpd.conf
sed -i 's#^DocumentRoot ".*#DocumentRoot "/htdocs"#g' /etc/apache2/httpd.conf
sed -i 's#Directory "/var/www/localhost/htdocs"#Directory "/htdocs"#g' /etc/apache2/httpd.conf
sed -i 's#AllowOverride None#AllowOverride All#' /etc/apache2/httpd.conf
sed -i 's#DirectoryIndex index.html#DirectoryIndex index.php#' /etc/apache2/httpd.conf

# Change TransferLog after ErrorLog
sed -i 's#^ErrorLog .*#ErrorLog "/dev/stderr"\nTransferLog "/dev/stdout"#g' /etc/apache2/httpd.conf
sed -i 's#CustomLog .* combined#CustomLog "/dev/stdout" combined#g' /etc/apache2/httpd.conf

# Re-define LogLevel
sed -i "s#^LogLevel .*#LogLevel ${LOG_LEVEL}#g" /etc/apache2/httpd.conf

# Enable commonly used apache modules
sed -i 's/#LoadModule\ rewrite_module/LoadModule\ rewrite_module/' /etc/apache2/httpd.conf
sed -i 's/#LoadModule\ deflate_module/LoadModule\ deflate_module/' /etc/apache2/httpd.conf
sed -i 's/#LoadModule\ expires_module/LoadModule\ expires_module/' /etc/apache2/httpd.conf

# Modify php memory limit and timezone
sed -i "s/memory_limit = .*/memory_limit = ${PHP_MEMORY_LIMIT}/" /etc/php83/php.ini
sed -i "s#^;date.timezone =\$#date.timezone = \"${TZ}\"#" /etc/php83/php.ini

echo 'Running Apache'

httpd -D FOREGROUND
46 changes: 44 additions & 2 deletions js/script.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -729,8 +729,7 @@
case 'HmIP-eTRV-E-S':
case 'HmIP-eTRV-CL':
case 'HmIP-eTRV-C':
case 'HmIP-eTRV-C-2':
case 'HmIP-eTRV-F':
case 'HmIP-eTRV-C-2':
switch (datapoint) {
case 'ACTUAL_TEMPERATURE':
$('[data-id="' + ise_id + '"]').html('<img src="icon/ist_temperatur.png" /> ' + (Math.round(value * 10) / 10).toFixed(1) + ' &deg;C&nbsp;&nbsp;&nbsp;&nbsp;');
Expand Down Expand Up @@ -771,6 +770,49 @@
$('[data-id="' + ise_id + '"]').html(value);
}
break;
case 'HmIP-eTRV-F':
case 'HmIP-eTRV-3':
switch (datapoint) {
case 'ACTUAL_TEMPERATURE':
$('[data-id="' + ise_id + '"]').html('<img src="icon/ist_temperatur.png" /> ' + (Math.round(value * 10) / 10).toFixed(1) + ' &deg;C&nbsp;&nbsp;&nbsp;&nbsp;');
break;
case 'SET_POINT_MODE':
if (value === '0') {
$('[data-id="' + ise_id + '"]').html('<img src="icon/time_automatic.png" />');
$('[data-id="' + ise_id + '"]').attr('data-set-id', parseInt(ise_id)-10); //MANU_MODE
$('[data-id="' + ise_id + '"]').attr('data-set-value', '1');
} else {
$('[data-id="' + ise_id + '"]').html('<img src="icon/time_manual_mode.png" />');
$('[data-id="' + ise_id + '"]').attr('data-set-id', parseInt(ise_id)-10); //AUTO_MODE
$('[data-id="' + ise_id + '"]').attr('data-set-value', '0');
}
break;
case 'ACTIVE_PROFILE':
if (value < 4) $('[data-id="' + ise_id + '"]').html(value + '&nbsp;<img src="icon/heating.png"/>');
else $('[data-id="' + ise_id + '"]').html(value + '&nbsp;<img src="icon/cooling.png"/>');
break;
case 'SET_POINT_TEMPERATURE':
$('[data-id="' + ise_id + '"]').html('<img src="icon/soll_temperatur.png" /> ' + (Math.round(value * 10) / 10).toFixed(1) + ' &deg;C');
break;
case 'LEVEL':
$('[data-id="' + ise_id + '"]').html('&nbsp;&nbsp;&nbsp;&nbsp;<img src="icon/ventil.png" /> ' + (Math.round(value * 1000) / 10) + ' %');
break;
case 'WINDOW_STATE':
if (value === '0') {
$('[data-id="' + ise_id + '"]').html('<img src="icon/fts_window_1w.png" />');
} else {
$('[data-id="' + ise_id + '"]').html('<img src="icon/fts_window_1w_open.png" />');
}
break;
case 'LOW_BAT':
if (value === 'true') {
$('[data-id="' + ise_id + '"]').html('<img src="icon/measure_battery_25.png" />');
}
break;
default:
$('[data-id="' + ise_id + '"]').html(value);
}
break;
case 'HmIP-FALMOT-C12':
switch (datapoint) {
case 'LEVEL':
Expand Down

0 comments on commit 71225ea

Please sign in to comment.