Skip to content

Commit c158569

Browse files
committed
Update things :-)
1 parent 6566a6d commit c158569

File tree

13 files changed

+744
-51
lines changed

13 files changed

+744
-51
lines changed

config/profiles/base/andi.pub

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDX0hp8fCemYRxK7Um39wAvUj1wRzAuJfr/DHak2DYG
88
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPqpqC3YXnoh+2fgOWbjCoOSnBv93+K9rpYSg0DuNIq7 andi@ranzbook
99
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMJqyWKhVxfIDDGJRJ1f/Jn1IpasWy5F1jmE7g8Q3jL5G+tq1bSpH1OCaChPR1Ay4LKPYH70I/TyE7zibr5wDPo= ecdsa-sha2-nistp256
1010
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMza5XPqhxrs6fVVXzzFIKQ80qYMYl/zaxNtgIwjGhoo andi@gamma
11+
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ+EdAVdJU+MV9fNjC+mRPIv3EzR9E6Zoc7VGQNRwCqP andi@delta

config/servers/bertha/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ in
5454
./nginx.nix
5555
./mqtt2prom.nix
5656
./streetmerchant.nix
57-
#./lab.nix
57+
./lab.nix
5858
];
5959

6060

config/servers/bertha/lab.nix

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{ pkgs, ... }:
2+
{
3+
systemd.sockets.atftpd = {
4+
listenDatagrams = [ "192.168.1.88:69" ];
5+
wantedBy = [ "sockets.target" ];
6+
};
7+
8+
systemd.services.atftpd = {
9+
requires = [ "atftpd.socket" ];
10+
serviceConfig = {
11+
StateDirectory = "atftpd";
12+
DynamicUser = true;
13+
StandardInput = "socket";
14+
ExecStart = "${pkgs.atftp}/bin/atftpd -v 6 -m 2 --port 69 --tftpd-timeout 300 --retry-timeout 5 --mcast-port 1758 --mcast-addr 239.239.239.0-255 --mcast-ttl 1 /var/lib/atftpd";
15+
WorkingDirectory = "/var/lib/atftpd";
16+
};
17+
};
18+
}

config/servers/crappy/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
];
1111

1212
deployment = {
13-
targetHost = "172.20.24.67";
13+
targetHost = "home.rammhold.de";
1414
targetUser = "morph";
1515
substituteOnDestination = false; # TODO: is this faster?
1616

config/servers/crappy/hardware.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
systemd.network = {
7474
networks = {
7575
"0-default" = {
76-
matchConfig.Name = "eth0";
76+
matchConfig.Name = "end0";
7777
networkConfig = {
7878
DHCP = "yes";
7979
IPv6AcceptRA = true;
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{ rooms }:
2+
{ config, lib, ... }:
3+
let
4+
mkAutomation = name: { climateDevices ? { }, temperatureSensors ? [ ] }:
5+
let
6+
sync_script_name = lib.toLower "synchronize_room_temperature_to_danfoss_in_${name}";
7+
automation_name = sync_script_name;
8+
timer_id = "${automation_name}_timer";
9+
in
10+
if climateDevices == { } || temperatureSensors == [ ] then { } else {
11+
config = {
12+
script.${sync_script_name}.sequence = [
13+
{
14+
variables = {
15+
temperatures = map (sensor: "{{ states('${sensor}')|float*100|round(0) }}") temperatureSensors;
16+
};
17+
}
18+
{
19+
variables = {
20+
mean_temperature = "{{ temperatures|average }}";
21+
};
22+
}
23+
] ++
24+
(map
25+
(climateDeviceName: {
26+
service = "number.set_value";
27+
target.entity_id = "number.${climateDeviceName}_external_measured_room_sensor";
28+
data.value = "{{ mean_temperature|float }}";
29+
})
30+
(builtins.attrNames climateDevices));
31+
32+
timer = lib.mapAttrs'
33+
(climateDevice: _: lib.nameValuePair "${timer_id}_${climateDevice}" {
34+
duration = "300";
35+
})
36+
climateDevices;
37+
38+
automation =
39+
lib.mapAttrsToList (alias: value: { id = alias; inherit alias; } // value)
40+
(lib.mapAttrs'
41+
(climateDevice: _: lib.nameValuePair "${automation_name}_${climateDevice}" {
42+
# on temperature change of any of the sensors
43+
trigger = map
44+
(sensor: {
45+
platform = "state";
46+
entity_id = sensor;
47+
})
48+
temperatureSensors
49+
# or every 30 minutes
50+
++ [{
51+
platform = "event";
52+
event_type = "timer.finished";
53+
event_data.entity_id = "${timer_id}_${climateDevice}";
54+
}];
55+
variables = {
56+
radiator_covered_status = "{{ states('switch.${climateDevice}_radiator_covered') }}";
57+
min_update_minutes = "{% if radiator_covered_status == 'off' %}30{% else %}5{% endif %}";
58+
max_update_minutes = "{% if radiator_covered_status == 'off' %}180{% else %}30{% endif %}";
59+
};
60+
condition = [
61+
{
62+
condition = "template";
63+
value_template = "{{ as_timestamp(now()) - as_timestamp(state_attr(this.entity_id, 'last_triggered'),0) > 60 * min_update_minutes }}";
64+
}
65+
];
66+
action = [
67+
{ service = "script.${sync_script_name}"; }
68+
{ service = "timer.start"; target.entity_id = "timer.${timer_id}_${climateDevice}"; data.duration = "{{ max_update_minutes * 60 }}"; }
69+
];
70+
mode = "single";
71+
})
72+
climateDevices);
73+
};
74+
};
75+
in
76+
lib.mkMerge (map
77+
(room:
78+
{ services.home-assistant = mkAutomation room rooms.${room}; })
79+
(builtins.attrNames rooms))

0 commit comments

Comments
 (0)