hass: add heater

This commit is contained in:
Ingolf Wagner 2020-10-30 00:36:00 +01:00
parent 19d912d713
commit 49574ee6ec
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
4 changed files with 295 additions and 0 deletions

View file

@ -236,6 +236,86 @@ in {
}]; }];
} }
{
alias = "heater on in the morning";
trigger = [{
platform = "time";
at = "09:30:00";
}];
action = [
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/heater1/set"; # office
payload_template =
''{"system_mode":"auto","current_heating_setpoint":21.5}'';
};
}
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/heater2/set"; # office
payload_template =
''{"system_mode":"auto","current_heating_setpoint":21.5}'';
};
}
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/heater3/set"; # bed room
payload_template =
''{"system_mode":"auto","current_heating_setpoint":20.0}'';
};
}
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/heater4/set"; # storage room
payload_template =
''{"system_mode":"auto","current_heating_setpoint":18.0}'';
};
}
];
}
{
alias = "heater off in the evening";
trigger = [{
platform = "time";
at = "23:00:00";
}];
action = [
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/heater1/set"; # office
payload_template = ''{"system_mode":"off"}'';
};
}
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/heater2/set"; # office
payload_template = ''{"system_mode":"off"}'';
};
}
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/heater3/set"; # bed room
payload_template = ''{"system_mode":"off"}'';
};
}
{
service = "mqtt.publish";
data_template = {
topic = "zigbee2mqtt/heater4/set"; # storage room
payload_template = ''{"system_mode":"off"}'';
};
}
];
}
]; ];
group = let group = let

View file

@ -3,9 +3,11 @@
./mqtt.nix ./mqtt.nix
./zigbee2mqtt/buttons.nix ./zigbee2mqtt/buttons.nix
./zigbee2mqtt/doors.nix ./zigbee2mqtt/doors.nix
./zigbee2mqtt/heater.nix
./zigbee2mqtt/leds.nix ./zigbee2mqtt/leds.nix
./zigbee2mqtt/lights.nix ./zigbee2mqtt/lights.nix
./zigbee2mqtt/motion.nix ./zigbee2mqtt/motion.nix
./zigbee2mqtt/repeater.nix
./zigbee2mqtt/service.nix ./zigbee2mqtt/service.nix
./zigbee2mqtt/temperatur.nix ./zigbee2mqtt/temperatur.nix
./zigbee2mqtt/windows.nix ./zigbee2mqtt/windows.nix

View file

@ -0,0 +1,109 @@
{ pkgs, lib, ... }:
let
# https://www.zigbee2mqtt.io/devices/SPZB0001.html
allDevices = {
"heater1" = { id = "0x00158d00032f5ee4"; }; # office
"heater2" = { id = "0x00158d00032f5f9f"; }; # office (kitchen)
"heater3" = { id = "0x00158d00032f6d1e"; }; # bed room
"heater4" = { id = "0x00158d00032f604d"; }; # abstell raum
};
# -t "zigbee2mqtt/heater3/set" -m '{"system_mode":"auto","current_heating_setpoint":23}'
# -t "zigbee2mqtt/heater3/set" -m '{"system_mode":"off"}'
in {
services.zigbee2mqtt.devices = lib.mapAttrs' (name:
{ id, ... }: {
name = id;
value = {
retain = false;
friendly_name = name;
transition = 1;
};
}) allDevices;
services.homeAssistantConfig = {
#light = lib.flatten (lib.mapAttrsToList (name:
# { ... }: [
# {
# name = "rgb_${name}";
# platform = "mqtt";
# state_topic = "zigbee2mqtt/${name}";
# availability_topic = "zigbee2mqtt/bridge/state";
# brightness = true;
# color_temp = true;
# xy = true;
# schema = "json";
# command_topic = "zigbee2mqtt/${name}/rgb/set";
# brightness_scale = 254;
# state_topic_postfix = "rgb";
# }
# {
# name = "white_${name}";
# platform = "mqtt";
# state_topic = "zigbee2mqtt/${name}";
# availability_topic = "zigbee2mqtt/bridge/state";
# brightness = true;
# schema = "json";
# command_topic = "zigbee2mqtt/${name}/white/set";
# brightness_scale = 254;
# state_topic_postfix = "white";
# }
# ]) allDevices);
#sensor = with lib;
# mapAttrsToList (name:
# { ... }: {
# name = "link_${name}";
# platform = "mqtt";
# state_topic = "zigbee2mqtt/${name}";
# availability_topic = "zigbee2mqtt/bridge/state";
# icon = "mdi:signal";
# unit_of_measurement = "lqi";
# value_template = "{{ value_json.linkquality}}";
# }) allDevices;
# binary_sensor = lib.mapAttrsToList (name:
# { ... }: {
# name = "update_${name}";
# platform = "mqtt";
# state_topic = "zigbee2mqtt/${name}";
# availability_topic = "zigbee2mqtt/bridge/state";
# payload_on = true;
# payload_off = false;
# value_template = "{{ value_json.update_available }}";
# }) allDevices;
# # create groups
# # -------------
# group = let
# # to have nice panels for every device
# lightGroups = lib.mapAttrs (name:
# { ... }: {
# entities = [
# "light.${name}"
# "sensor.link_${name}"
# "binary_sensor.update_${name}"
# ];
# }) allDevices;
# # sort lights into given groups.
# sortedInGroups = let
# groupEntries = lib.zipAttrs (lib.flatten (lib.mapAttrsToList (name:
# { groups ? [ ], ... }:
# map (groupName: { "${groupName}" = "light.${name}"; }) groups)
# allDevices));
# in lib.mapAttrs (name: entities: { inherit entities; }) groupEntries;
# in sortedInGroups // lightGroups // {
# all_lights.entities =
# lib.mapAttrsToList (name: { ... }: "light.${name}") allDevices;
# };
};
}

View file

@ -0,0 +1,104 @@
{ pkgs, lib, ... }:
let
# https://www.zigbee2mqtt.io/devices/SPZB0001.html
allDevices = {
"repeater1" = { id = "0x680ae2fffe6e7dc1"; };
"repeater2" = { id = "0x680ae2fffe8e240d"; };
};
in {
services.zigbee2mqtt.devices = lib.mapAttrs' (name:
{ id, ... }: {
name = id;
value = {
retain = false;
friendly_name = name;
transition = 1;
};
}) allDevices;
services.homeAssistantConfig = {
#light = lib.flatten (lib.mapAttrsToList (name:
# { ... }: [
# {
# name = "rgb_${name}";
# platform = "mqtt";
# state_topic = "zigbee2mqtt/${name}";
# availability_topic = "zigbee2mqtt/bridge/state";
# brightness = true;
# color_temp = true;
# xy = true;
# schema = "json";
# command_topic = "zigbee2mqtt/${name}/rgb/set";
# brightness_scale = 254;
# state_topic_postfix = "rgb";
# }
# {
# name = "white_${name}";
# platform = "mqtt";
# state_topic = "zigbee2mqtt/${name}";
# availability_topic = "zigbee2mqtt/bridge/state";
# brightness = true;
# schema = "json";
# command_topic = "zigbee2mqtt/${name}/white/set";
# brightness_scale = 254;
# state_topic_postfix = "white";
# }
# ]) allDevices);
#sensor = with lib;
# mapAttrsToList (name:
# { ... }: {
# name = "link_${name}";
# platform = "mqtt";
# state_topic = "zigbee2mqtt/${name}";
# availability_topic = "zigbee2mqtt/bridge/state";
# icon = "mdi:signal";
# unit_of_measurement = "lqi";
# value_template = "{{ value_json.linkquality}}";
# }) allDevices;
# binary_sensor = lib.mapAttrsToList (name:
# { ... }: {
# name = "update_${name}";
# platform = "mqtt";
# state_topic = "zigbee2mqtt/${name}";
# availability_topic = "zigbee2mqtt/bridge/state";
# payload_on = true;
# payload_off = false;
# value_template = "{{ value_json.update_available }}";
# }) allDevices;
# # create groups
# # -------------
# group = let
# # to have nice panels for every device
# lightGroups = lib.mapAttrs (name:
# { ... }: {
# entities = [
# "light.${name}"
# "sensor.link_${name}"
# "binary_sensor.update_${name}"
# ];
# }) allDevices;
# # sort lights into given groups.
# sortedInGroups = let
# groupEntries = lib.zipAttrs (lib.flatten (lib.mapAttrsToList (name:
# { groups ? [ ], ... }:
# map (groupName: { "${groupName}" = "light.${name}"; }) groups)
# allDevices));
# in lib.mapAttrs (name: entities: { inherit entities; }) groupEntries;
# in sortedInGroups // lightGroups // {
# all_lights.entities =
# lib.mapAttrsToList (name: { ... }: "light.${name}") allDevices;
# };
};
}