diff --git a/esphome/README.md b/esphome/README.md index 7151fdf..330320d 100644 --- a/esphome/README.md +++ b/esphome/README.md @@ -1,8 +1,6 @@ # Installation OTA Update Shelly Device to tasmota: https://github.com/arendst/mgos-to-tasmota -On gen 3 devices just download zip file from below and upload it over the web interface to shelly: -https://github.com/tasmota/mgos32-to-tasmota32/releases In Tasmota make OTA Update to minimal: http://ota.tasmota.com/tasmota/release/tasmota-minimal.bin.gz Make ESPHome Configuration in Dashboard: diff --git a/esphome/hallway-switch.yaml b/esphome/hallway-switch.yaml deleted file mode 100644 index 82d6eef..0000000 --- a/esphome/hallway-switch.yaml +++ /dev/null @@ -1,100 +0,0 @@ -substitutions: - devicename: hallway-switch - max_power: "2000.0" # watt - max_temp: "80.0" # °C - -esphome: - name: ${devicename} - -#esp32: -# board: esp32-c3-devkitm-1 -# flash_size: 8MB -# framework: -# type: esp-idf -# variant: esp32c3 - -esp32: - board: esp32-c3-devkitm-1 - flash_size: 8MB - framework: - type: esp-idf - version: recommended - sdkconfig_options: - COMPILER_OPTIMIZATION_SIZE: y - -wifi: - ssid: !secret wifi_ssid - password: !secret wifi_password - -logger: - -api: - -ota: - platform: esphome - -sensor: - - platform: ntc - sensor: temp_resistance_reading - name: "Temperature" - unit_of_measurement: "°C" - accuracy_decimals: 1 - icon: "mdi:thermometer" - calibration: - b_constant: 3350 - reference_resistance: 10kOhm - reference_temperature: 298.15K - on_value_range: - - above: ${max_temp} - then: - - output.turn_off: relay_output - - homeassistant.service: - service: persistent_notification.create - data: - title: Message from ${devicename} - data_template: - message: Switch turned off because temperature exceeded ${max_temp}°C - - platform: resistance - id: temp_resistance_reading - sensor: temp_analog_reading - configuration: DOWNSTREAM - resistor: 10kOhm - - platform: adc - id: temp_analog_reading - pin: GPIO3 - attenuation: 12db - -output: - - platform: gpio - id: "relay_output" - pin: 7 - -switch: - - platform: output - id: "relay" - name: "Relay" - output: "relay_output" - -binary_sensor: - - platform: gpio - name: "Switch" - pin: 10 - on_press: - then: - - switch.toggle: "relay" - filters: - - delayed_on_off: 50ms - - - platform: gpio - name: "Button" - pin: - number: 1 - inverted: yes - mode: - input: true - pullup: true - -status_led: - pin: - number: 0 - inverted: true \ No newline at end of file diff --git a/esphome/presense-bedroom.yaml b/esphome/presense-bedroom.yaml deleted file mode 100644 index 6e165cd..0000000 --- a/esphome/presense-bedroom.yaml +++ /dev/null @@ -1,33 +0,0 @@ -esphome: - name: presense-bedroom - friendly_name: presense-bedroom - -esp32: - board: esp32dev - framework: - type: arduino - -# Enable logging -logger: - -# Enable Home Assistant API -api: - -ota: - - platform: esphome - -wifi: - ssid: !secret wifi_ssid - password: !secret wifi_password - fast_connect: True - domain: .cloonar.smart - - # Enable fallback hotspot (captive portal) in case wifi connection fails - ap: - ssid: "Presense-Bedroom Fallback" - password: "jMTo5YkCC01q" - -captive_portal: - -bluetooth_proxy: - \ No newline at end of file diff --git a/esphome/presense-hallway.yaml b/esphome/presense-hallway.yaml deleted file mode 100644 index 493fba4..0000000 --- a/esphome/presense-hallway.yaml +++ /dev/null @@ -1,33 +0,0 @@ -esphome: - name: presense-hallway - friendly_name: presense-hallway - -esp32: - board: esp32dev - framework: - type: arduino - -# Enable logging -logger: - -# Enable Home Assistant API -api: - -ota: - - platform: esphome - -wifi: - ssid: !secret wifi_ssid - password: !secret wifi_password - fast_connect: True - domain: .cloonar.smart - - # Enable fallback hotspot (captive portal) in case wifi connection fails - ap: - ssid: "Presense-Hallway Fallback" - password: "jMTo5YkCC01q" - -captive_portal: - -bluetooth_proxy: - \ No newline at end of file diff --git a/esphome/presense-kitchen.yaml b/esphome/presense-kitchen.yaml deleted file mode 100644 index 66f8fcd..0000000 --- a/esphome/presense-kitchen.yaml +++ /dev/null @@ -1,33 +0,0 @@ -esphome: - name: presense-kitchen - friendly_name: presense-kitchen - -esp32: - board: esp32dev - framework: - type: arduino - -# Enable logging -logger: - -# Enable Home Assistant API -api: - -ota: - - platform: esphome - -wifi: - ssid: !secret wifi_ssid - password: !secret wifi_password - fast_connect: True - domain: .cloonar.smart - - # Enable fallback hotspot (captive portal) in case wifi connection fails - ap: - ssid: "Presense-Kitchen Fallback" - password: "jMTo5YkCC01q" - -captive_portal: - -bluetooth_proxy: - \ No newline at end of file diff --git a/esphome/presense-office.yaml b/esphome/presense-office.yaml deleted file mode 100644 index 47fab15..0000000 --- a/esphome/presense-office.yaml +++ /dev/null @@ -1,55 +0,0 @@ -esphome: - name: presense-office - friendly_name: presense-office - -esp32: - board: esp32dev - framework: - type: esp-idf - -# Enable logging -logger: - -# Enable Home Assistant API -api: - -ota: - - platform: esphome - -wifi: - ssid: !secret wifi_ssid - password: !secret wifi_password - fast_connect: True - domain: .cloonar.smart - - # Enable fallback hotspot (captive portal) in case wifi connection fails - ap: - ssid: "Presense-Office Fallback Hotspot" - password: "jMTo5YkCC01q" - -captive_portal: - -bluetooth_proxy: - -external_components: - - source: github://koying/esphome-ble-remote@master - components: [ ble_client_hid ] - -ble_client: - - id: ble_client_1 - mac_address: "90:f8:2e:f9:d7:32" # Replace with your remote's MAC address - -ble_client_hid: - - id: ble_client_hid_1 - ble_client_id: ble_client_1 - -sensor: - - platform: ble_client_hid - type: last_event_value - name: "Last Event Value" - ble_client_hid_id: ble_client_hid_1 - -text_sensor: - - platform: ble_client_hid - name: "Last Event Usage" - ble_client_hid_id: ble_client_hid_1 \ No newline at end of file diff --git a/hosts/fw.cloonar.com/modules/home-assistant/ac.nix b/hosts/fw.cloonar.com/modules/home-assistant/ac.nix index 2ffcac0..0d12ad4 100644 --- a/hosts/fw.cloonar.com/modules/home-assistant/ac.nix +++ b/hosts/fw.cloonar.com/modules/home-assistant/ac.nix @@ -1,15 +1,8 @@ -{ pkgs, ... }: { services.home-assistant.extraComponents = [ "daikin" "enocean" ]; - # services.home-assistant.customComponents = [ - # (pkgs.callPackage ./custom-components/scheduler.nix { }) - # ]; - services.home-assistant.customLovelaceModules = [ - (pkgs.callPackage ./custom-components/lovelace-scheduler.nix { }) - ]; services.home-assistant.config = { sensor = [ diff --git a/hosts/fw.cloonar.com/modules/home-assistant/custom-components/bermuda.nix b/hosts/fw.cloonar.com/modules/home-assistant/custom-components/bermuda.nix deleted file mode 100644 index 0590526..0000000 --- a/hosts/fw.cloonar.com/modules/home-assistant/custom-components/bermuda.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ stdenv, fetchFromGitHub }: - -stdenv.mkDerivation rec { - pname = "ha-bermuda"; - version = "0.7.2"; # Replace with the latest version - - src = fetchFromGitHub { - owner = "agittins"; - repo = "bermuda"; - rev = "v${version}"; - sha256 = "sha256-FBmZc2I9JoLAQ55yasa0i+SM0dMg2IbR3AaKgEybRu8="; # Replace with the correct SHA256 hash - }; - - installPhase = '' - mkdir -p $out - cp -r custom_components/bermuda $out/ - ''; -} diff --git a/hosts/fw.cloonar.com/modules/home-assistant/custom-components/hacs.nix b/hosts/fw.cloonar.com/modules/home-assistant/custom-components/hacs.nix deleted file mode 100644 index 4b09fd0..0000000 --- a/hosts/fw.cloonar.com/modules/home-assistant/custom-components/hacs.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ lib -, buildHomeAssistantComponent -, fetchFromGitHub -}: - -buildHomeAssistantComponent rec { - owner = "hacs"; - domain = "hacs"; - version = "2.0.1"; # Replace with the latest version - - src = fetchFromGitHub { - owner = "hacs"; - repo = "integration"; - rev = version; - sha256 = ""; # You'll need to fill this in - }; - - propagatedBuildInputs = [ - # Add any required dependencies here - ]; - - meta = with lib; { - homepage = "https://github.com/hacs/integration"; - license = licenses.mit; - description = "HACS (Home Assistant Community Store)"; - }; -} diff --git a/hosts/fw.cloonar.com/modules/home-assistant/custom-components/lovelace-scheduler.nix b/hosts/fw.cloonar.com/modules/home-assistant/custom-components/lovelace-scheduler.nix index 5e1d4a9..d653fee 100644 --- a/hosts/fw.cloonar.com/modules/home-assistant/custom-components/lovelace-scheduler.nix +++ b/hosts/fw.cloonar.com/modules/home-assistant/custom-components/lovelace-scheduler.nix @@ -20,12 +20,12 @@ buildNpmPackage rec { runHook preInstall mkdir $out - cp card-mod.js $out + cp scheduler-card.js $out runHook postInstall ''; - passthru.entrypoint = "card-mod.js"; + passthru.entrypoint = "scheduler-card.js"; meta = with lib; { description = "This is a Lovelace card for Home Assistant that can be used to create a time schedule for your smart devices. You can create new rules, modify existing rules and temporarily disable rules."; diff --git a/hosts/fw.cloonar.com/modules/home-assistant/custom-components/scheduler.nix b/hosts/fw.cloonar.com/modules/home-assistant/custom-components/scheduler.nix index f33cf55..7aa1816 100644 --- a/hosts/fw.cloonar.com/modules/home-assistant/custom-components/scheduler.nix +++ b/hosts/fw.cloonar.com/modules/home-assistant/custom-components/scheduler.nix @@ -6,7 +6,7 @@ }: buildHomeAssistantComponent rec { - owner = "nielsfaber"; + owner = "KartoffelToby"; domain = "scheduler"; version = "3.3.7"; diff --git a/hosts/fw.cloonar.com/modules/home-assistant/default.nix b/hosts/fw.cloonar.com/modules/home-assistant/default.nix index 5c2ec12..d0f824d 100644 --- a/hosts/fw.cloonar.com/modules/home-assistant/default.nix +++ b/hosts/fw.cloonar.com/modules/home-assistant/default.nix @@ -4,7 +4,7 @@ let pkgs-with-home-assistant = import (builtins.fetchGit { name = "new-home-assistant"; url = "https://github.com/nixos/nixpkgs/"; - rev = "41dea55321e5a999b17033296ac05fe8a8b5a257"; + rev = "268bb5090a3c6ac5e1615b38542a868b52ef8088"; }) {}; in { @@ -91,7 +91,6 @@ in ./power-saving.nix ./pushover.nix ./presense.nix - ./remote.nix ./roborock.nix ./scene-switch.nix ./shelly.nix @@ -150,25 +149,6 @@ in "tplink_omada" ]; - systemd.services.install-hacs = { - description = "Install HACS"; - wantedBy = [ "multi-user.target" ]; - serviceConfig = { - Type = "oneshot"; - }; - script = '' - set -e - HACS_VERSION="2.0.1" # Replace with the latest version - HACS_DIR="/var/lib/hass/custom_components/hacs" - - mkdir -p "$HACS_DIR" - ${pkgs.curl}/bin/curl -L "https://github.com/hacs/integration/releases/download/$HACS_VERSION/hacs.zip" -o /tmp/hacs.zip - ${pkgs.unzip}/bin/unzip -o /tmp/hacs.zip -d "$HACS_DIR" - rm /tmp/hacs.zip - chown -R hass:hass "$HACS_DIR" - ''; - }; - services.home-assistant.extraPackages = ps: with ps; [ mysqlclient ]; diff --git a/hosts/fw.cloonar.com/modules/home-assistant/multimedia.nix b/hosts/fw.cloonar.com/modules/home-assistant/multimedia.nix index 9b10343..0998159 100644 --- a/hosts/fw.cloonar.com/modules/home-assistant/multimedia.nix +++ b/hosts/fw.cloonar.com/modules/home-assistant/multimedia.nix @@ -49,7 +49,7 @@ friendly_name = "Any multimedia device on"; device_class = "connectivity"; value_template = '' - {% if ((states('media_player.living_room') != 'off') and (states('media_player.living_room') != 'standby')) or is_state('binary_sensor.ps5', 'on') or is_state('binary_sensor.xbox', 'on') or (is_state('binary_sensor.steamdeck', 'on') and (states('sensor.steamdeck_power') | float(default=0) > 5)) %} + {% if (states('media_player.living_room') != 'standby' and states('media_player.living_room') != 'off') or is_state('binary_sensor.ps5', 'on') or is_state('binary_sensor.xbox', 'on') or (states('media_player.fire_tv_firetv_living_cloonar_multimedia') != 'off' and states('media_player.fire_tv_firetv_living_cloonar_multimedia') != 'unavailable') or (is_state('binary_sensor.steamdeck', 'on') and (states('sensor.steamdeck_power') | float(default=0) > 5)) %} on {% else %} off @@ -73,12 +73,6 @@ } ]; sequence = [ - { - service = "automation.turn_off"; - target = { - entity_id = "automation.all_multimedia_off"; # Replace with your target automation ID - }; - } { service = "switch.turn_on"; target = { @@ -100,24 +94,6 @@ command = "b64:JgBOAJaSFREVNRU2FTUVERURFRAVERURFTUVNhU1FREVERUQFREVERUQFTYVNRURFREVEBURFTYVNRURFRAVNhU1FTYVNRUABfmWkhURFQANBQAAAAAAAAAAAAA="; }; } - { - delay = 10; - } - { - service = "remote.turn_on"; - target = { - entity_id = "remote.living_room"; - }; - } - { - delay = 120; - } - { - service = "automation.turn_on"; - target = { - entity_id = "automation.all_multimedia_off"; # Replace with your target automation ID - }; - } ]; } { diff --git a/hosts/fw.cloonar.com/modules/home-assistant/presense.nix b/hosts/fw.cloonar.com/modules/home-assistant/presense.nix index faa1fb3..02279b6 100644 --- a/hosts/fw.cloonar.com/modules/home-assistant/presense.nix +++ b/hosts/fw.cloonar.com/modules/home-assistant/presense.nix @@ -1,33 +1,9 @@ -{ pkgs, ... }: -let - bermuda = pkgs.callPackage ./custom-components/bermuda.nix {}; -in { services.home-assistant.extraComponents = [ "daikin" "enocean" - "private_ble_device" ]; - systemd.services.install-bermuda = { - description = "Install Bermuda"; - wantedBy = [ "multi-user.target" ]; - serviceConfig = { - Type = "oneshot"; - }; - script = '' - set -e - BERMUDA_VERSION="v0.7.2" # Replace with the latest version - BERMUDA_DIR="/var/lib/hass/custom_components/bermuda" - - mkdir -p "$BERMUDA_DIR" - ${pkgs.curl}/bin/curl -L "https://github.com/agittins/bermuda/releases/download/$BERMUDA_VERSION/bermuda.zip" -o /tmp/bermuda.zip - ${pkgs.unzip}/bin/unzip -o /tmp/bermuda.zip -d "$BERMUDA_DIR" - rm /tmp/bermuda.zip - chown -R hass:hass "$BERMUDA_DIR" - ''; - }; - services.home-assistant.config = { "automation presense kitchen" = { alias = "presense kitchen"; @@ -60,6 +36,103 @@ in ]; }; sensor = [ + { + platform = "mqtt_room"; + device_id = "dominiksiphone"; + name = "Dominiks iPhone"; + state_topic = "espresense/devices/dominiksiphone"; + timeout = 10; + away_timeout = 120; + } + { + platform = "template"; + sensors = { + presense_devices = { + friendly_name = "Presense Devices"; + value_template = "dominiks_iphone"; + }; + }; + } + { + platform = "template"; + sensors = { + presense_livingroom = { + friendly_name = "Presense Livingroom"; + value_template = '' + {% set room = "livingroom" %} + {% set presense = namespace(list=[]) %} + {% set presense_list = [] %} + {% set device_list = states('sensor.presense_devices').split(',') %} + {% for device in device_list %} + {% if is_state('sensor.' + device, room) %} + {% set presense.list = presense.list + [device] %} + {% endif %} + {% endfor %} + {{ presense.list | join("") }} + ''; + }; + }; + } + { + platform = "template"; + sensors = { + presense_kitchen = { + friendly_name = "Presense Kitchen"; + value_template = '' + {% set room = "kitchen" %} + {% set presense = namespace(list=[]) %} + {% set presense_list = [] %} + {% set device_list = states('sensor.presense_devices').split(',') %} + {% for device in device_list %} + {% if is_state('sensor.' + device, room) %} + {% set presense.list = presense.list + [device] %} + {% endif %} + {% endfor %} + {{ presense.list | join("") }} + ''; + }; + }; + } + { + platform = "template"; + sensors = { + presense_hallway = { + friendly_name = "Presense Hallway"; + value_template = '' + {% set room = "hallway" %} + {% set presense = namespace(list=[]) %} + {% set presense_list = [] %} + {% set device_list = states('sensor.presense_devices').split(',') %} + {% for device in device_list %} + {% if is_state('sensor.' + device, room) %} + {% set presense.list = presense.list + [device] %} + {% endif %} + {% endfor %} + {{ presense.list | join("") }} + ''; + }; + }; + } + { + platform = "template"; + sensors = { + presense_bedroom = { + friendly_name = "Presense Bedroom"; + value_template = '' + {% set room = "bedroom" %} + {% set presense = namespace(list=[]) %} + {% set presense_list = [] %} + {% set device_list = states('sensor.presense_devices').split(',') %} + {% for device in device_list %} + {% if is_state('sensor.' + device, room) %} + {% set presense.list = presense.list + [device] %} + {% endif %} + {% endfor %} + {{ presense.list | join("") }} + ''; + }; + }; + } ]; }; } diff --git a/hosts/fw.cloonar.com/modules/home-assistant/remote.nix b/hosts/fw.cloonar.com/modules/home-assistant/remote.nix deleted file mode 100644 index 911d57d..0000000 --- a/hosts/fw.cloonar.com/modules/home-assistant/remote.nix +++ /dev/null @@ -1,333 +0,0 @@ -let - remote_entity = "remote.living_room"; - media_player_entity = "media_player.living_room"; -in { - services.home-assistant.config = { - "automation press power" = { - alias = "steamdeck on"; - trigger = { - platform = "event"; - event_type = "esphome.hid_events"; - event_data = { - usage = "Keyboard Power"; - value = "1"; - }; - }; - action = [ - { - choose = [ - { - conditions = [ - { - condition = "state"; - entity_id = "switch.tv_switch"; - state = "off"; - } - ]; - sequence = [ - { - service = "script.turn_on"; - target = { - entity_id = "script.turn_on_tv"; - }; - } - ]; - } - { - conditions = [ - { - condition = "template"; - value_template = "{{ states('media_player.living_room') != 'off' }}"; - } - ]; - sequence = [ - { - action = "remote.send_command"; - target = { - entity_id = remote_entity; - - }; - data = { - hold_secs = 1; - command = "home"; - }; - } - ]; - } - ]; - } - ]; - }; - "automation remote press up" = { - alias = "remote press up"; - trigger = { - platform = "event"; - event_type = "esphome.hid_events"; - event_data = { - usage = "Keyboard UpArrow"; - value = "1"; - }; - }; - action = [ - { - action = "remote.send_command"; - target = { - entity_id = remote_entity; - }; - data = { - command = "up"; - }; - } - ]; - }; - "automation remote press right" = { - alias = "remote press right"; - trigger = { - platform = "event"; - event_type = "esphome.hid_events"; - event_data = { - usage = "Keyboard RightArrow"; - value = "1"; - }; - }; - action = [ - { - action = "remote.send_command"; - target = { - entity_id = remote_entity; - }; - data = { - command = "right"; - }; - } - ]; - }; - "automation remote press down" = { - alias = "remote press down"; - trigger = { - platform = "event"; - event_type = "esphome.hid_events"; - event_data = { - usage = "Keyboard DownArrow"; - value = "1"; - }; - }; - action = [ - { - action = "remote.send_command"; - target = { - entity_id = remote_entity; - }; - data = { - command = "down"; - }; - } - ]; - }; - "automation remote press left" = { - alias = "remote press left"; - trigger = { - platform = "event"; - event_type = "esphome.hid_events"; - event_data = { - usage = "Keyboard LeftArrow"; - value = "1"; - }; - }; - action = [ - { - action = "remote.send_command"; - target = { - entity_id = remote_entity; - }; - data = { - command = "left"; - }; - } - ]; - }; - "automation remote press enter" = { - alias = "remote press enter"; - trigger = { - platform = "event"; - event_type = "esphome.hid_events"; - event_data = { - usage = "Keypad ENTER"; - value = "1"; - }; - }; - action = [ - { - action = "remote.send_command"; - target = { - entity_id = remote_entity; - }; - data = { - command = "select"; - }; - } - ]; - }; - "automation remote press return" = { - alias = "remote press return"; - trigger = { - platform = "event"; - event_type = "esphome.hid_events"; - event_data = { - usage = "7_241"; - value = "1"; - }; - }; - action = [ - { - action = "remote.send_command"; - target = { - entity_id = remote_entity; - }; - data = { - command = "menu"; - }; - } - ]; - }; - "automation remote press home" = { - alias = "remote press home"; - trigger = { - platform = "event"; - event_type = "esphome.hid_events"; - event_data = { - usage = "AC Home"; - value = "1"; - }; - }; - action = [ - { - action = "remote.send_command"; - target = { - entity_id = remote_entity; - }; - data = { - command = "home"; - }; - } - ]; - }; - "automation remote press Menu" = { - alias = "remote press menu"; - trigger = { - platform = "event"; - event_type = "esphome.hid_events"; - event_data = { - usage = "Menu"; - value = "1"; - }; - }; - action = [ - { - action = "remote.send_command"; - target = { - entity_id = remote_entity; - }; - data = { - hold_secs = 1; - command = "select"; - }; - } - ]; - }; - "automation remote press program guide" = { - alias = "remote press program guide"; - trigger = { - platform = "event"; - event_type = "esphome.hid_events"; - event_data = { - usage = "Media Select Program Guide"; - value = "1"; - }; - }; - action = [ - { - service = "automation.trigger"; - target = { - entity_id = "automation.multimedia_scene_switch"; - }; - } - ]; - }; - "automation remote press 1" = { - alias = "remote press 1"; - trigger = { - platform = "event"; - event_type = "esphome.hid_events"; - event_data = { - usage = "AC Set Clock"; - value = "1"; - }; - }; - action = [ - { - service = "light.toggle"; - target = { - entity_id = "light.livingroom_switch"; - }; - } - ]; - }; - "automation remote press 2" = { - alias = "remote press 2"; - trigger = { - platform = "event"; - event_type = "esphome.hid_events"; - event_data = { - usage = "AC View Clock"; - value = "1"; - }; - }; - action = [ - { - service = "light.toggle"; - target = { - entity_id = "light.4d_f7b4"; - }; - } - ]; - }; - "automation remote press prime video" = { - alias = "remote press prime video"; - trigger = { - platform = "event"; - event_type = "esphome.hid_events"; - event_data = { - usage = "161_0"; - value = "1"; - }; - }; - action = [ - { - action = "media_player.select_source"; - target.entity_id = media_player_entity; - data.source = "Prime Video"; - } - ]; - }; - "automation remote press netflix" = { - alias = "remote press netflix"; - trigger = { - platform = "event"; - event_type = "esphome.hid_events"; - event_data = { - usage = "162_0"; - value = "1"; - }; - }; - action = [ - { - action = "media_player.select_source"; - target.entity_id = media_player_entity; - data.source = "Netflix"; - } - ]; - }; - - }; -}