Compare commits

..

11 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
6 changed files with 120 additions and 10 deletions

View File

@@ -60,10 +60,11 @@ template:
unit_of_measurement: "mm" unit_of_measurement: "mm"
state_class: measurement state_class: measurement
state: > state: >
{% set sensor_offset = 290 %} {# distance (mm) from sensor to tank bottom #} {% 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 distance = states('sensor.regenput_sensor_distance') | float(0) %}
{% set height = sensor_offset - distance %} {% set height = max_water_height - (distance - mount_gap) %}
{{ [ [height, 0] | max, sensor_offset] | min | round(1) }} {{ [ [height, 0] | max, max_water_height] | min | round(1) }}
- name: "Cistern Volume" - name: "Cistern Volume"
unique_id: cistern_volume unique_id: cistern_volume
@@ -75,13 +76,13 @@ template:
{% set radius = diameter / 2 %} {% set radius = diameter / 2 %}
{% set height = states('sensor.cistern_water_height') | float(0) %} {% set height = states('sensor.cistern_water_height') | float(0) %}
{% set volume_mm3 = 3.14159265 * (radius ** 2) * height %} {% set volume_mm3 = 3.14159265 * (radius ** 2) * height %}
{{ (volume_cm3 / 1000000) | round(1) }} {# convert mm³ to liters #} {{ (volume_mm3 / 1000000) | round(1) }} {# convert mm³ to liters #}
- name: "Cistern Fill Percentage" - name: "Cistern Fill Percentage"
unique_id: cistern_fill_percentage unique_id: cistern_fill_percentage
unit_of_measurement: "%" unit_of_measurement: "%"
state_class: measurement state_class: measurement
state: > state: >
{% set sensor_offset = 290 %} {# same as above, = full tank height #} {% set sensor_offset = 2090 - 290 %} {# full tank height - sensor_mount #}
{% set height = states('sensor.cistern_water_height') | float(0) %} {% set height = states('sensor.cistern_water_height') | float(0) %}
{{ (height / sensor_offset * 100) | round(1) }} {{ (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: services:
mosquitto: mosquitto:
restart: unless-stopped restart: unless-stopped

View File

@@ -37,7 +37,7 @@ export class ControlLoopRunner {
const quarterHour = computeQuarterHourStatus(samples, nowMs, targetW); const quarterHour = computeQuarterHourStatus(samples, nowMs, targetW);
const current: CurrentReadings = { const current: CurrentReadings = {
powerW: latestPower?.watts ?? null, powerW: latestPower?.watts ?? null,
solarW: latestSolar?.watts ?? null, solarW: this.env.SOLAR_INFLUX_ENTITY_ID ? (latestSolar?.watts ?? 0) : null,
}; };
return { quarterHour, devices, current }; return { quarterHour, devices, current };
@@ -56,17 +56,27 @@ export class ControlLoopRunner {
/** /**
* Whether the solar inverter is currently producing power, used to gate * Whether the solar inverter is currently producing power, used to gate
* `onlyWhenSun` devices. Reads the configured InfluxDB solar production * `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 * 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> { private async isSolarProducing(): Promise<boolean> {
if (!this.env.SOLAR_INFLUX_ENTITY_ID) {
return this.fallbackToSunUp();
}
try { try {
const sample = await fetchLatestSolarProductionSample(this.queryApi, this.env); 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) { } catch (err) {
this.log.error({ err }, "failed to read solar production series; falling back to sun.sun"); 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) => { return this.ha.isSunUp().catch((err) => {
this.log.error({ err }, "failed to read sun.sun state; treating as unrestricted"); this.log.error({ err }, "failed to read sun.sun state; treating as unrestricted");
return true; return true;

View File

@@ -41,7 +41,7 @@ export interface QuarterHourStatus {
export interface CurrentReadings { export interface CurrentReadings {
powerW: number | null; // most recent house power sample, null if none within lookback 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 { 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