diff --git a/esphome/livingroom-bulb-1.yaml b/esphome/livingroom-bulb-1.yaml index 438eff3..d91534a 100644 --- a/esphome/livingroom-bulb-1.yaml +++ b/esphome/livingroom-bulb-1.yaml @@ -8,14 +8,27 @@ esphome: platform: ESP8266 board: esp01_1m on_boot: + priority: 300 then: - - light.turn_on: my_light - -# Enable logging -logger: - -web_server: - port: 80 + - light.turn_on: + id: my_light + red: 0.2 + green: 0.1 + blue: 0 + white: 0.2 + color_brightness: 0.2 + brightness: 0.2 + +interval: + - interval: 15s + then: + - if: + condition: + api.connected: # check if api connected + else: + - light.dim_relative: + id: my_light + relative_brightness: 1 # Enable Home Assistant API api: @@ -29,8 +42,6 @@ wifi: fast_connect: True domain: .cloonar.smart -captive_portal: - light: - platform: rgbw id: my_light @@ -39,10 +50,6 @@ light: green: pwm_g blue: pwm_b white: pwm_w - effects: - - random: - - strobe: - - flicker: output: - platform: esp8266_pwm diff --git a/esphome/livingroom-bulb-2.yaml b/esphome/livingroom-bulb-2.yaml index bc71d02..58f8813 100644 --- a/esphome/livingroom-bulb-2.yaml +++ b/esphome/livingroom-bulb-2.yaml @@ -8,14 +8,27 @@ esphome: platform: ESP8266 board: esp01_1m on_boot: + priority: 300 then: - - light.turn_on: my_light - -# Enable logging -logger: - -web_server: - port: 80 + - light.turn_on: + id: my_light + red: 0.2 + green: 0.1 + blue: 0 + white: 0.2 + color_brightness: 0.2 + brightness: 0.2 + +interval: + - interval: 15s + then: + - if: + condition: + api.connected: # check if api connected + else: + - light.dim_relative: + id: my_light + relative_brightness: 1 # Enable Home Assistant API api: @@ -29,8 +42,6 @@ wifi: fast_connect: True domain: .cloonar.smart -captive_portal: - light: - platform: rgbw id: my_light @@ -39,10 +50,6 @@ light: green: pwm_g blue: pwm_b white: pwm_w - effects: - - random: - - strobe: - - flicker: output: - platform: esp8266_pwm diff --git a/esphome/livingroom-bulb-3.yaml b/esphome/livingroom-bulb-3.yaml index 361b60c..d6ddf80 100644 --- a/esphome/livingroom-bulb-3.yaml +++ b/esphome/livingroom-bulb-3.yaml @@ -9,14 +9,26 @@ esphome: board: esp01_1m on_boot: then: - - light.turn_on: my_light - -# Enable logging -logger: - -web_server: - port: 80 - + - light.turn_on: + id: my_light + red: 0.2 + green: 0.1 + blue: 0 + white: 0.2 + color_brightness: 0.2 + brightness: 0.2 + +interval: + - interval: 15s + then: + - if: + condition: + api.connected: # check if api connected + else: + - light.dim_relative: + id: my_light + relative_brightness: 1 + # Enable Home Assistant API api: @@ -29,8 +41,6 @@ wifi: fast_connect: True domain: .cloonar.smart -captive_portal: - light: - platform: rgbw id: my_light @@ -39,10 +49,6 @@ light: green: pwm_g blue: pwm_b white: pwm_w - effects: - - random: - - strobe: - - flicker: output: - platform: esp8266_pwm diff --git a/esphome/livingroom-bulb-4.yaml b/esphome/livingroom-bulb-4.yaml index f65283b..e9b6320 100644 --- a/esphome/livingroom-bulb-4.yaml +++ b/esphome/livingroom-bulb-4.yaml @@ -9,13 +9,25 @@ esphome: board: esp01_1m on_boot: then: - - light.turn_on: my_light - -# Enable logging -logger: - -web_server: - port: 80 + - light.turn_on: + id: my_light + red: 0.2 + green: 0.1 + blue: 0 + white: 0.2 + color_brightness: 0.2 + brightness: 0.2 + +interval: + - interval: 15s + then: + - if: + condition: + api.connected: # check if api connected + else: + - light.dim_relative: + id: my_light + relative_brightness: 1 # Enable Home Assistant API api: @@ -29,8 +41,6 @@ wifi: fast_connect: True domain: .cloonar.smart -captive_portal: - light: - platform: rgbw id: my_light @@ -39,10 +49,6 @@ light: green: pwm_g blue: pwm_b white: pwm_w - effects: - - random: - - strobe: - - flicker: output: - platform: esp8266_pwm diff --git a/esphome/livingroom-bulb-5.yaml b/esphome/livingroom-bulb-5.yaml index 3650e1d..905c896 100644 --- a/esphome/livingroom-bulb-5.yaml +++ b/esphome/livingroom-bulb-5.yaml @@ -9,13 +9,25 @@ esphome: board: esp01_1m on_boot: then: - - light.turn_on: my_light - -# Enable logging -logger: - -web_server: - port: 80 + - light.turn_on: + id: my_light + red: 0.2 + green: 0.1 + blue: 0 + white: 0.2 + color_brightness: 0.2 + brightness: 0.2 + +interval: + - interval: 15s + then: + - if: + condition: + api.connected: # check if api connected + else: + - light.dim_relative: + id: my_light + relative_brightness: 1 # Enable Home Assistant API api: @@ -29,8 +41,6 @@ wifi: fast_connect: True domain: .cloonar.smart -captive_portal: - light: - platform: rgbw id: my_light @@ -39,10 +49,6 @@ light: green: pwm_g blue: pwm_b white: pwm_w - effects: - - random: - - strobe: - - flicker: output: - platform: esp8266_pwm diff --git a/esphome/livingroom-bulb-6.yaml b/esphome/livingroom-bulb-6.yaml index f3057cd..8860cbf 100644 --- a/esphome/livingroom-bulb-6.yaml +++ b/esphome/livingroom-bulb-6.yaml @@ -9,13 +9,25 @@ esphome: board: esp01_1m on_boot: then: - - light.turn_on: my_light - -# Enable logging -logger: - -web_server: - port: 80 + - light.turn_on: + id: my_light + red: 0.2 + green: 0.1 + blue: 0 + white: 0.2 + color_brightness: 0.2 + brightness: 0.2 + +interval: + - interval: 15s + then: + - if: + condition: + api.connected: # check if api connected + else: + - light.dim_relative: + id: my_light + relative_brightness: 1 # Enable Home Assistant API api: @@ -29,8 +41,6 @@ wifi: fast_connect: True domain: .cloonar.smart -captive_portal: - light: - platform: rgbw id: my_light @@ -39,10 +49,6 @@ light: green: pwm_g blue: pwm_b white: pwm_w - effects: - - random: - - strobe: - - flicker: output: - platform: esp8266_pwm diff --git a/esphome/toilet-bulb.yaml b/esphome/toilet-bulb.yaml new file mode 100644 index 0000000..6611bc9 --- /dev/null +++ b/esphome/toilet-bulb.yaml @@ -0,0 +1,49 @@ +substitutions: + device_name: "toilet-bulb" + friendly_name: "Toilet Bulb" + +esphome: + name: ${device_name} + comment: ${friendly_name} + platform: ESP8266 + board: esp01_1m + on_boot: + then: + - light.turn_on: my_light + +# Enable logging +logger: + +web_server: + port: 80 + +# Enable Home Assistant API +api: + +ota: + platform: esphome + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + fast_connect: True + domain: .cloonar.smart + +captive_portal: + +output: + - platform: esp8266_pwm + id: warm_white + pin: GPIO4 + - platform: esp8266_pwm + id: brightness + pin: GPIO5 + +light: + - platform: cwww + id: my_light + name: ${friendly_name} + warm_white: warm_white + cold_white: brightness + cold_white_color_temperature: 6500 K + warm_white_color_temperature: 2700 K diff --git a/hosts/fw-new/modules/home-assistant/default.nix b/hosts/fw-new/modules/home-assistant/default.nix index ab5cc6e..b651073 100644 --- a/hosts/fw-new/modules/home-assistant/default.nix +++ b/hosts/fw-new/modules/home-assistant/default.nix @@ -40,6 +40,7 @@ in localAddress = "10.42.113.20/24"; extraFlags = [ "--capability=CAP_NET_ADMIN" + "--capability=CAP_MKNOD" ]; # allowedDevices = [ # { @@ -50,12 +51,16 @@ in # modifier = "rwm"; # node = "char-ttyUSB"; # } + # { + # modifier = "rwm"; + # node = "/dev/ttyUSB0"; + # } # ]; bindMounts = { - # "/dev/ttyUSB0" = { - # hostPath = "/dev/ttyUSB0"; - # isReadOnly = false; - # }; + "/dev/ttyUSB0" = { + hostPath = "/dev/ttyUSB0"; + isReadOnly = false; + }; "/etc/localtime" = { hostPath = "/etc/localtime"; }; @@ -113,6 +118,11 @@ in pkgs.mariadb ]; + # Allow access to the USB device + services.udev.extraRules = '' + SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE="0666" + ''; + services.nginx.enable = true; services.nginx.virtualHosts."${domain}" = { sslCertificate = "/var/lib/acme/hass/fullchain.pem"; @@ -247,7 +257,7 @@ in ]; }; - users.users.hass.extraGroups = [ "dialout" ]; + users.users.hass.extraGroups = [ "dialout" "tty" ]; system.stateVersion = "23.05"; }; }; diff --git a/hosts/fw-new/modules/home-assistant/light.nix b/hosts/fw-new/modules/home-assistant/light.nix index 1ef7acb..922ea0d 100644 --- a/hosts/fw-new/modules/home-assistant/light.nix +++ b/hosts/fw-new/modules/home-assistant/light.nix @@ -58,7 +58,7 @@ "light.livingroom_lights" "light.hallway_lights" "light.bathroom_lights" - "light.toilett_lights" + "light.toilet_lights" "light.storage_lights" ]; to = "on"; @@ -67,7 +67,7 @@ { choose = [ { - conditions = [ "{{ state_attr('sun.sun', 'elevation') < 5 and trigger.entity_id == 'light.toilett_lights' }}" ]; + conditions = [ "{{ state_attr('sun.sun', 'elevation') < 5 and trigger.entity_id == 'light.toilet_lights' }}" ]; sequence = [ { delay = 10; @@ -78,7 +78,7 @@ entity_id = "{{ trigger.entity_id }}"; }; data = { - brightness_pct = 10; + brightness_pct = 20; color_temp = 450; }; } @@ -398,6 +398,20 @@ "light.bedroom_bulb_4" ]; } + { + platform = "switch"; + name = "Toilet Switch"; + entity_id = "switch.toilet"; + } + { + platform = "group"; + name = "Toilet Lights"; + all = true; + entities = [ + "light.toilet" + "light.toilet_bulb" + ]; + } ]; }; } diff --git a/hosts/fw.cloonar.com/modules/dhcp4.nix b/hosts/fw.cloonar.com/modules/dhcp4.nix index 9d11493..50ddbb6 100644 --- a/hosts/fw.cloonar.com/modules/dhcp4.nix +++ b/hosts/fw.cloonar.com/modules/dhcp4.nix @@ -248,12 +248,6 @@ reservations = [ # need fixed ips for all shelly devices # living room 1 - 14 - # 10.42.100.2 # bulb1 - # 10.42.100.3 # bulb2 - # 10.42.100.4 # bulb3 - # 10.42.100.5 # bulb4 - # 10.42.100.6 # bulb5 - # 10.42.100.7 # bulb6 # 10.42.100.8 # piano # 10.42.100.9 # switch # 10.42.100.10 # steamdeck @@ -268,23 +262,21 @@ # 10.42.100.37 # readingled2 # 10.42.100.38 # bedled # bath: - # 10.42.100.49 # switch - # 10.42.100.50 # bulb1 - # 10.42.100.51 # bulb2 # 10.42.100.52 # smallswitch # 10.42.100.53 # ht # hallway: # 10.42.100.65 # switch - # 10.42.100.66 # bulb1 - # 10.42.100.67 # bulb2 - # 10.42.100.68 # bulb3 - # 10.42.100.69 # bulb4 # toilet: # 10.42.100.81 # switch # 10.42.100.82 # bulb # storage: # 10.42.100.97 # switch + { + hw-address = "fc:ee:28:03:63:e9"; + ip-address = "10.42.100.148"; + server-hostname = "k1c"; + } { hw-address = "60:a4:23:97:4a:ec"; ip-address = "10.42.100.21"; diff --git a/hosts/fw.cloonar.com/modules/home-assistant/default.nix b/hosts/fw.cloonar.com/modules/home-assistant/default.nix index f7f7b14..d0f824d 100644 --- a/hosts/fw.cloonar.com/modules/home-assistant/default.nix +++ b/hosts/fw.cloonar.com/modules/home-assistant/default.nix @@ -39,22 +39,23 @@ in localAddress = "10.42.97.20/24"; extraFlags = [ "--capability=CAP_NET_ADMIN" + "--capability=CAP_MKNOD" + ]; + allowedDevices = [ + { + modifier = "rwm"; + node = "char-usb_device"; + } + { + modifier = "rwm"; + node = "char-ttyUSB"; + } ]; - # allowedDevices = [ - # { - # modifier = "rwm"; - # node = "char-usb_device"; - # } - # { - # modifier = "rwm"; - # node = "char-ttyUSB"; - # } - # ]; bindMounts = { - # "/dev/ttyUSB0" = { - # hostPath = "/dev/ttyUSB0"; - # isReadOnly = false; - # }; + "/dev/ttyUSB0" = { + hostPath = "/dev/ttyUSB0"; + isReadOnly = false; + }; "/etc/localtime" = { hostPath = "/etc/localtime"; }; diff --git a/hosts/fw.cloonar.com/modules/home-assistant/electricity.nix b/hosts/fw.cloonar.com/modules/home-assistant/electricity.nix index d71ee79..482de06 100644 --- a/hosts/fw.cloonar.com/modules/home-assistant/electricity.nix +++ b/hosts/fw.cloonar.com/modules/home-assistant/electricity.nix @@ -18,7 +18,7 @@ in { friendly_name = "Current Price of electricity"; unit_of_measurement = "EUR/kWh"; value_template = '' - {{ (((states('sensor.epex_spot_data_price') | int ) / 1000) + (0.0149 + 0.0053 + 0.00866)) | float }} + {{ (((states('sensor.epex_spot_data_price') | int ) / 1000) + (0.0149 + 0.053 + 0.00866)) | float }} ''; }; }; diff --git a/hosts/fw.cloonar.com/modules/home-assistant/light.nix b/hosts/fw.cloonar.com/modules/home-assistant/light.nix index 2caef71..a75c0b2 100644 --- a/hosts/fw.cloonar.com/modules/home-assistant/light.nix +++ b/hosts/fw.cloonar.com/modules/home-assistant/light.nix @@ -75,7 +75,7 @@ entity_id = "{{ trigger.entity_id }}"; }; data = { - brightness_pct = 10; + brightness_pct = 20; color_temp = 450; }; } @@ -120,7 +120,7 @@ entity_id = "{{ trigger.entity_id }}"; }; data = { - brightness_pct = 25; + brightness_pct = 20; rgbw_color = [ 255 126 0 255 ]; }; } @@ -416,6 +416,20 @@ "light.hallway_bulb_2" ]; } + { + platform = "switch"; + name = "Toilet Switch"; + entity_id = "switch.toilet"; + } + { + platform = "group"; + name = "Toilet Lights"; + all = true; + entities = [ + "light.toilet_switch" + "light.toilet_bulb" + ]; + } ]; }; } diff --git a/hosts/fw.cloonar.com/modules/home-assistant/power-saving.nix b/hosts/fw.cloonar.com/modules/home-assistant/power-saving.nix index 591b2e5..cf645be 100644 --- a/hosts/fw.cloonar.com/modules/home-assistant/power-saving.nix +++ b/hosts/fw.cloonar.com/modules/home-assistant/power-saving.nix @@ -1,8 +1,4 @@ { - services.home-assistant.extraComponents = [ - "nuki" - ]; - services.home-assistant.config = { "automation power leave home" = { alias = "leave house power"; diff --git a/hosts/fw.cloonar.com/modules/web/matrix.nix b/hosts/fw.cloonar.com/modules/web/matrix.nix index 05e9ab5..93a1727 100644 --- a/hosts/fw.cloonar.com/modules/web/matrix.nix +++ b/hosts/fw.cloonar.com/modules/web/matrix.nix @@ -268,7 +268,7 @@ in { }; bridge = { username_template = "signal_{{.}}"; - displayname_template = "{{or .ProfileName .PhoneNumber \"Unknown user\"}}"; + displayname_template = "{{or .ProfileName .PhoneNumber \"Unknown user\"}} (Signal)"; double_puppet_server_map = { }; login_shared_secret_map = { }; command_prefix = "!signal"; @@ -281,6 +281,9 @@ in { require = true; }; }; + matrix = { + sync_direct_chat_list = true; + }; logging = { min_level = "info"; writers = lib.singleton { @@ -408,13 +411,14 @@ in { }; bridge = { username_template = "discord_{{.}}"; - displayname_template = "{{or .ProfileName .PhoneNumber \"Unknown user\"}}"; + displayname_template = "{{or .GlobalName .Username}} (Discord{{if .Bot}} bot{{end}})"; double_puppet_server_map = { }; login_shared_secret_map = { }; command_prefix = "!discord"; permissions."*" = "relay"; permissions."cloonar.com" = "user"; relay.enabled = true; + restricted_rooms = true; encryption = { allow = true; default = true;