Compare commits

..

13 Commits

Author SHA1 Message Date
Willem Serruys
7afd3b878d chore: rename 2026-08-29 09:05:50 +02:00
Willem Serruys
02f1b2549c fix: env file 2026-08-29 08:55:49 +02:00
Willem Serruys
0cfd13807c feat: added immich 2026-08-29 08:54:37 +02:00
willem.serruys
ff749940e6 fix: when no solar energy, do not enable consumers 2026-08-22 19:56:31 +02:00
willem.serruys
7bf479f90a fix: height 2026-08-22 19:46:16 +02:00
willem.serruys
a6d8b66b8a fix: sensor 2026-08-22 19:44:07 +02:00
willem.serruys
d2ea0f16aa fix: sensor 2026-08-22 19:41:03 +02:00
willem.serruys
279a095b05 fix citern 2026-08-22 19:28:13 +02:00
willem.serruys
b56b4912a2 fix: fill percentage 2026-08-22 19:21:50 +02:00
willem.serruys
40cad2ec70 fix: sensor_offset 2026-08-22 19:20:07 +02:00
willem.serruys
6b0d12d6d2 fix: sensor 2026-08-22 19:16:58 +02:00
willem.serruys
2961b477b4 formatting 2026-08-22 19:11:20 +02:00
willem.serruys
e630c92b60 updated config 2026-08-22 19:11:09 +02:00
6 changed files with 190 additions and 6 deletions

View File

@@ -11,3 +11,78 @@ http:
use_x_forwarded_for: true
trusted_proxies:
- 172.16.0.0/12
# ---- 1. Track a running monthly average of the EPEX day-ahead price ----
# (Replace sensor.nordpool_kwh_be_eur_3_10_0 with your actual Nord Pool entity ID)
sensor:
- platform: statistics
name: "Epex Monthly Average"
entity_id: sensor.nordpool_kwh_be_eur_3_10_0
state_characteristic: mean
max_age:
days: 31
sampling_size: 9999
# ---- 2. Apply Mega's formula and add the fixed cost components ----
template:
- sensor:
- name: "Mega Energy Price"
unique_id: mega_energy_price
unit_of_measurement: "€/kWh"
state: >
{% set epex = states('sensor.epex_monthly_average') | float(0) %}
{% set excl_vat = epex * 1.085 %}
{% set incl_vat = excl_vat * 1.06 %}
{{ incl_vat | round(5) }}
- name: "Mega All-in Price"
unique_id: mega_allin_price
unit_of_measurement: "€/kWh"
state: >
{% set energy = states('sensor.mega_energy_price') | float(0) %}
{% set green_power = 0.01554 %}
{% set distribution = 0.066985 %}
{% set excise = 0.0503288 %}
{% set energy_contribution = 0.0020417 %}
{{ (energy + green_power + distribution + excise + energy_contribution) | round(5) }}
- sensor:
- name: "Mega Injection Price"
unique_id: mega_injection_price
unit_of_measurement: "€/kWh"
state: >
{% set epex_spp = states('sensor.epex_spp_monthly_average') | float(0) %}
{% set price = (epex_spp * 0.96) - 1 %}
{{ [price, 0] | max | round(5) }}
- sensor:
- name: "Cistern Water Height"
unique_id: cistern_water_height
unit_of_measurement: "mm"
state_class: measurement
state: >
{% set mount_gap = 290 %} {# mm from sensor down to the "full" water line #}
{% set max_water_height = 1800 %} {# mm, tank depth from full line to bottom #}
{% set distance = states('sensor.regenput_sensor_distance') | float(0) %}
{% set height = max_water_height - (distance - mount_gap) %}
{{ [ [height, 0] | max, max_water_height] | min | round(1) }}
- name: "Cistern Volume"
unique_id: cistern_volume
unit_of_measurement: "L"
device_class: volume
state_class: measurement
state: >
{% set diameter = 1450 %} {# mm #}
{% set radius = diameter / 2 %}
{% set height = states('sensor.cistern_water_height') | float(0) %}
{% set volume_mm3 = 3.14159265 * (radius ** 2) * height %}
{{ (volume_mm3 / 1000000) | round(1) }} {# convert mm³ to liters #}
- name: "Cistern Fill Percentage"
unique_id: cistern_fill_percentage
unit_of_measurement: "%"
state_class: measurement
state: >
{% set sensor_offset = 2090 - 290 %} {# full tank height - sensor_mount #}
{% set height = states('sensor.cistern_water_height') | float(0) %}
{{ (height / sensor_offset * 100) | round(1) }}

76
docker-compose-immich.yml Normal file
View File

@@ -0,0 +1,76 @@
#
# WARNING: To install Immich, follow our guide: https://docs.immich.app/install/docker-compose
#
# Make sure to use the docker-compose.yml of the current release:
#
# https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml
#
# The compose file on main may not be compatible with the latest release.
name: homeAutomation
services:
immich-server:
container_name: immich_server
image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
# extends:
# file: hwaccel.transcoding.yml
# service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding
volumes:
# Do not edit the next line. If you want to change the media storage location on your system, edit the value of UPLOAD_LOCATION in the .env file
- ${UPLOAD_LOCATION}:/data
- /etc/localtime:/etc/localtime:ro
env_file:
- immich.env
labels:
- traefik.http.routers.immich.rule=Host(`immich.pladijs`)
- traefik.http.services.immich.loadbalancer.server.port=2283
depends_on:
- redis
- database
restart: always
healthcheck:
disable: false
immich-machine-learning:
container_name: immich_machine_learning
# For hardware acceleration, add one of -[armnn, cuda, rocm, openvino, rknn] to the image tag.
# Example tag: ${IMMICH_VERSION:-release}-cuda
image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
# extends: # uncomment this section for hardware acceleration - see https://docs.immich.app/features/ml-hardware-acceleration
# file: hwaccel.ml.yml
# service: cpu # set to one of [armnn, cuda, rocm, openvino, openvino-wsl, rknn] for accelerated inference - use the `-wsl` version for WSL2 where applicable
volumes:
- model-cache:/cache
env_file:
- immich.env
restart: always
healthcheck:
disable: false
redis:
container_name: immich_redis
image: docker.io/valkey/valkey:9@sha256:8e8d64b405ce18f41b8e5ee20aa4687a8ed0022d1298f2ce31cdcf3a76e09411
healthcheck:
test: redis-cli ping || exit 1
restart: always
database:
container_name: immich_postgres
image: ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0@sha256:bcf63357191b76a916ae5eb93464d65c07511da41e3bf7a8416db519b40b1c23
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_USER: ${DB_USERNAME}
POSTGRES_DB: ${DB_DATABASE_NAME}
POSTGRES_INITDB_ARGS: '--data-checksums'
# Uncomment the DB_STORAGE_TYPE: 'HDD' var if your database isn't stored on SSDs
# DB_STORAGE_TYPE: 'HDD'
volumes:
# Do not edit the next line. If you want to change the database storage location on your system, edit the value of DB_DATA_LOCATION in the .env file
- ${DB_DATA_LOCATION}:/var/lib/postgresql/data
shm_size: 128mb
restart: always
healthcheck:
disable: false
volumes:
model-cache:

View File

@@ -1,3 +1,4 @@
name: homeAutomation
services:
mosquitto:
restart: unless-stopped

View File

@@ -37,7 +37,7 @@ export class ControlLoopRunner {
const quarterHour = computeQuarterHourStatus(samples, nowMs, targetW);
const current: CurrentReadings = {
powerW: latestPower?.watts ?? null,
solarW: latestSolar?.watts ?? null,
solarW: this.env.SOLAR_INFLUX_ENTITY_ID ? (latestSolar?.watts ?? 0) : null,
};
return { quarterHour, devices, current };
@@ -56,17 +56,27 @@ export class ControlLoopRunner {
/**
* Whether the solar inverter is currently producing power, used to gate
* `onlyWhenSun` devices. Reads the configured InfluxDB solar production
* series and compares its latest sample against SOLAR_PRODUCTION_THRESHOLD_W.
* series and compares its latest sample (treating no reading within the
* lookback window as 0W) against SOLAR_PRODUCTION_THRESHOLD_W.
* Falls back to HA's sun.sun (astronomical above/below horizon) when no
* solar production series is configured, or if either read fails.
* solar production series is configured at all, or if the Influx read
* itself fails.
*/
private async isSolarProducing(): Promise<boolean> {
if (!this.env.SOLAR_INFLUX_ENTITY_ID) {
return this.fallbackToSunUp();
}
try {
const sample = await fetchLatestSolarProductionSample(this.queryApi, this.env);
if (sample) return sample.watts >= this.env.SOLAR_PRODUCTION_THRESHOLD_W;
const watts = sample?.watts ?? 0;
return watts >= this.env.SOLAR_PRODUCTION_THRESHOLD_W;
} catch (err) {
this.log.error({ err }, "failed to read solar production series; falling back to sun.sun");
return this.fallbackToSunUp();
}
}
private fallbackToSunUp(): Promise<boolean> {
return this.ha.isSunUp().catch((err) => {
this.log.error({ err }, "failed to read sun.sun state; treating as unrestricted");
return true;

View File

@@ -41,7 +41,7 @@ export interface QuarterHourStatus {
export interface CurrentReadings {
powerW: number | null; // most recent house power sample, null if none within lookback
solarW: number | null; // most recent solar production sample, null if unconfigured or none within lookback
solarW: number | null; // most recent solar production sample; 0 if configured but no reading within lookback, null if unconfigured
}
export interface ControlAction {

22
immich.env Normal file
View File

@@ -0,0 +1,22 @@
# You can find documentation for all the supported env variables at https://docs.immich.app/install/environment-variables
# The location where your uploaded files are stored
UPLOAD_LOCATION=/srv/appdata/immich/upload
# The location where your database files are stored. Network shares are not supported for the database
DB_DATA_LOCATION=/srv/appdata/immich/db
# To set a timezone, uncomment the next line and change Etc/UTC to a TZ identifier from this list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
# TZ=Etc/UTC
# The Immich version to use. You can pin this to a specific version like "v2.1.0"
IMMICH_VERSION=v3
# Connection secret for postgres. You should change it to a random password
# Please use only the characters `A-Za-z0-9`, without special characters or spaces
DB_PASSWORD=postgres
# The values below this line do not need to be changed
###################################################################################
DB_USERNAME=postgres
DB_DATABASE_NAME=immich