From 53351c89441ed7843472b7292949180d491614b1 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 17 Mar 2021 20:02:55 +0100 Subject: ma home: move zigbee2mqtt out of ham --- makefu/2configs/home/ham/zigbee2mqtt/default.nix | 91 ---------------- makefu/2configs/home/ham/zigbee2mqtt/hass.nix | 130 ----------------------- makefu/2configs/home/ham/zigbee2mqtt/osram.nix | 14 --- 3 files changed, 235 deletions(-) delete mode 100644 makefu/2configs/home/ham/zigbee2mqtt/default.nix delete mode 100644 makefu/2configs/home/ham/zigbee2mqtt/hass.nix delete mode 100644 makefu/2configs/home/ham/zigbee2mqtt/osram.nix (limited to 'makefu/2configs/home/ham') diff --git a/makefu/2configs/home/ham/zigbee2mqtt/default.nix b/makefu/2configs/home/ham/zigbee2mqtt/default.nix deleted file mode 100644 index 6ccf8b241..000000000 --- a/makefu/2configs/home/ham/zigbee2mqtt/default.nix +++ /dev/null @@ -1,91 +0,0 @@ -{config, pkgs, lib, ...}: - -let - dataDir = "/var/lib/zigbee2mqtt"; - sec = import ; - internal-ip = "192.168.1.11"; - webport = 8521; -in - { - # symlink the zigbee controller - #services.udev.extraRules = '' - # SUBSYSTEM=="tty", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="16a8", SYMLINK+="cc2531", MODE="0660", GROUP="dialout" - #''; - - # /dev/serial/by-id/usb-Silicon_Labs_slae.sh_cc2652rb_stick_-_slaesh_s_iot_stuff_00_12_4B_00_21_CC_45_BD-if00-port0 - services.udev.extraRules = '' - SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", SYMLINK+="cc2531", MODE="0660", GROUP="dialout" - ''; - - services.zigbee2mqtt = { - enable = true; - inherit dataDir; - config = { - permit_join = true; - serial.port = "/dev/cc2531"; - homeassistant = true; - mqtt = { - server = "mqtt://omo.lan:1883"; - base_topic = "/ham/zigbee"; - user = sec.mqtt.username; - password = sec.mqtt.password; - include_device_information = true; - client_id = "zigbee2mqtt"; - }; - frontend = { - port = webport; - }; - advanced = { - log_level = "debug"; - log_output = [ "console" ]; - last_seen = "ISO_8601"; - elapsed = true; - reporting = true; # TODO test if it is better with groups - pan_id = 6755; - inherit (sec.zigbee) network_key; - }; - map_options.graphviz.colors = { - fill = { - enddevice = "#fff8ce" ; - coordinator = "#e04e5d"; - router = "#4ea3e0"; - }; - font = { - coordinator= "#ffffff"; - router = "#ffffff"; - enddevice = "#000000"; - }; - line = { - active = "#009900"; - inactive = "#994444"; - }; - }; - }; - }; - - services.nginx.recommendedProxySettings = true; - services.nginx.virtualHosts."zigbee" = { - serverAliases = [ "zigbee.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" - ]; - }; -} diff --git a/makefu/2configs/home/ham/zigbee2mqtt/hass.nix b/makefu/2configs/home/ham/zigbee2mqtt/hass.nix deleted file mode 100644 index faf864ba6..000000000 --- a/makefu/2configs/home/ham/zigbee2mqtt/hass.nix +++ /dev/null @@ -1,130 +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"; - } - ]; - switch = [ - { - platform = "mqtt"; - name = "Zigbee2mqtt Main join"; - state_topic = "${prefix}/bridge/config/permit_join"; - command_topic = "${prefix}/bridge/config/permit_join"; - payload_on = "true"; - payload_off = "false"; - } - ]; - automation = [ - { - alias = "Zigbee2mqtt Log Level"; - initial_state = "on"; - trigger = { - platform = "state"; - entity_id = "input_select.zigbee2mqtt_log_level"; - }; - action = [ - { - service = "mqtt.publish"; - data = { - payload_template = "{{ states('input_select.zigbee2mqtt_log_level') }}"; - topic = "${prefix}/bridge/config/log_level"; - }; - } - ]; - } - # Automation to start timer when enable join is turned on - { - id = "zigbee_join_enabled"; - alias = "Zigbee Join Enabled"; - trigger = - { - platform = "state"; - entity_id = "switch.zigbee2mqtt_main_join"; - to = "on"; - }; - action = - { - service = "timer.start"; - entity_id = "timer.zigbee_permit_join"; - }; - } - # # Automation to stop timer when switch turned off and turn off switch when timer finished - { - id = "zigbee_join_disabled"; - alias = "Zigbee Join Disabled"; - trigger = [ - { - platform = "event"; - event_type = "timer.finished"; - event_data.entity_id = "timer.zigbee_permit_join"; - } - { - platform = "state"; - entity_id = "switch.zigbee2mqtt_main_join"; - to = "off"; - } - ]; - action = [ - { service = "timer.cancel"; - data.entity_id = "timer.zigbee_permit_join"; - } - { service = "switch.turn_off"; - entity_id = "switch.zigbee2mqtt_main_join"; - } - ]; - } - ]; - input_select.zigbee2mqtt_log_level = - { - name = "Zigbee2mqtt Log Level"; - options = [ - "debug" - "info" - "warn" - "error" - ]; - initial = "info"; - icon = "mdi:format-list-bulleted"; - }; - - timer.zigbee_permit_join = - { - name = "Zigbee Time remaining"; - duration = 120; - }; - }; -} diff --git a/makefu/2configs/home/ham/zigbee2mqtt/osram.nix b/makefu/2configs/home/ham/zigbee2mqtt/osram.nix deleted file mode 100644 index d1bf2b296..000000000 --- a/makefu/2configs/home/ham/zigbee2mqtt/osram.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ - - -availability_topic: /ham/zigbee/bridge/state -command_topic: /ham/zigbee/flur_arbeitszimmer_osram2/set - - - platform: "mqtt" - state_topic: "zigbee2mqtt/" - availability_topic: "zigbee2mqtt/bridge/state" - payload_on: true - payload_off: false - value_template: "{{ value_json.battery_low}}" - device_class: "battery" -} -- cgit v1.2.3 From 4f30fddc4aa02289d38b00de9bb7b36ce290a8db Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 17 Mar 2021 20:04:30 +0100 Subject: ma home/ham: pull out zigbee2mqtt --- makefu/2configs/home/ham/default.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'makefu/2configs/home/ham') diff --git a/makefu/2configs/home/ham/default.nix b/makefu/2configs/home/ham/default.nix index e164b177f..33e406e0b 100644 --- a/makefu/2configs/home/ham/default.nix +++ b/makefu/2configs/home/ham/default.nix @@ -14,11 +14,10 @@ in { imports = [ ./nginx.nix ./mqtt.nix - ./zigbee2mqtt ./signal-rest # hass config - ./zigbee2mqtt/hass.nix + ../zigbee2mqtt/hass.nix # ./multi/flurlicht.nix ./multi/kurzzeitwecker.nix ./multi/the_playlist.nix -- cgit v1.2.3