home/zigbee: add separate file for cake
This commit is contained in:
parent
aa7bfd3d75
commit
a3419c353a
2configs/home
|
@ -1,43 +0,0 @@
|
|||
# provides:
|
||||
# switch
|
||||
# automation
|
||||
# binary_sensor
|
||||
# sensor
|
||||
# input_select
|
||||
# timer
|
||||
let
|
||||
inherit (import ./lib) zigbee;
|
||||
prefix = zigbee.prefix;
|
||||
in
|
||||
{
|
||||
services.home-assistant.config = {
|
||||
sensor =
|
||||
|
||||
[
|
||||
# Sensor for monitoring the bridge state
|
||||
{
|
||||
platform = "mqtt";
|
||||
name = "Zigbee2mqtt Bridge state";
|
||||
state_topic = "${prefix}/bridge/state";
|
||||
icon = "mdi:router-wireless";
|
||||
}
|
||||
# Sensor for Showing the Zigbee2mqtt Version
|
||||
{
|
||||
platform = "mqtt";
|
||||
name = "Zigbee2mqtt Version";
|
||||
state_topic = "${prefix}/bridge/config";
|
||||
value_template = "{{ value_json.version }}";
|
||||
icon = "mdi:zigbee";
|
||||
}
|
||||
# Sensor for Showing the Coordinator Version
|
||||
{
|
||||
platform = "mqtt";
|
||||
name = "Coordinator Version";
|
||||
state_topic = "${prefix}/bridge/config";
|
||||
value_template = "{{ value_json.coordinator }}";
|
||||
icon = "mdi:chip";
|
||||
}
|
||||
];
|
||||
|
||||
};
|
||||
}
|
49
2configs/home/zigbee/cake.nix
Normal file
49
2configs/home/zigbee/cake.nix
Normal file
|
@ -0,0 +1,49 @@
|
|||
{config, pkgs, lib, ...}:
|
||||
|
||||
let
|
||||
dataDir = "/var/lib/zigbee2mqtt";
|
||||
internal-ip = "192.168.111.11";
|
||||
webport = 8521;
|
||||
in
|
||||
{
|
||||
sops.secrets."cake-zigbee2mqtt" = {
|
||||
owner = "zigbee2mqtt";
|
||||
path = "/var/lib/zigbee2mqtt/configuration.yaml";
|
||||
};
|
||||
services.udev.extraRules = ''
|
||||
SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", SYMLINK+="cc2531", MODE="0660", GROUP="dialout"
|
||||
'';
|
||||
|
||||
services.zigbee2mqtt = {
|
||||
enable = true;
|
||||
inherit dataDir;
|
||||
# sets DeviceAllow in systemd service
|
||||
settings.serial.port = "/dev/cc2531";
|
||||
};
|
||||
|
||||
services.nginx.recommendedProxySettings = true;
|
||||
services.nginx.virtualHosts."zigbee_cake" = {
|
||||
serverAliases = [ "zigbee_cake.lan" ];
|
||||
locations."/".proxyPass = "http://localhost:${toString webport}";
|
||||
locations."/api".proxyPass = "http://localhost:${toString webport}";
|
||||
locations."/api".proxyWebsockets = true;
|
||||
extraConfig = ''
|
||||
if ( $server_addr != "${internal-ip}" ) {
|
||||
return 403;
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
state = [ "${dataDir}/devices.yaml" "${dataDir}/state.json" ];
|
||||
|
||||
systemd.services.zigbee2mqtt = {
|
||||
# override automatic configuration.yaml deployment
|
||||
environment.ZIGBEE2MQTT_DATA = dataDir;
|
||||
serviceConfig.ExecStartPre = lib.mkForce "${pkgs.coreutils}/bin/true";
|
||||
after = [
|
||||
"home-assistant.service"
|
||||
"mosquitto.service"
|
||||
# "network-online.target"
|
||||
];
|
||||
};
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
|
||||
|
||||
availability_topic: /ham/zigbee/bridge/state
|
||||
command_topic: /ham/zigbee/flur_arbeitszimmer_osram2/set
|
||||
|
||||
- platform: "mqtt"
|
||||
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
|
||||
availability_topic: "zigbee2mqtt/bridge/state"
|
||||
payload_on: true
|
||||
payload_off: false
|
||||
value_template: "{{ value_json.battery_low}}"
|
||||
device_class: "battery"
|
||||
}
|
Loading…
Reference in a new issue