Compare commits

...

2 Commits

Author SHA1 Message Date
1c4cc1e393 feat: home-assistant changes 2024-12-01 11:42:34 +01:00
03eaa38a08 add esphome devices 2024-12-01 11:42:03 +01:00
15 changed files with 714 additions and 102 deletions

View File

@@ -1,6 +1,8 @@
# Installation # Installation
OTA Update Shelly Device to tasmota: OTA Update Shelly Device to tasmota:
https://github.com/arendst/mgos-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: In Tasmota make OTA Update to minimal:
http://ota.tasmota.com/tasmota/release/tasmota-minimal.bin.gz http://ota.tasmota.com/tasmota/release/tasmota-minimal.bin.gz
Make ESPHome Configuration in Dashboard: Make ESPHome Configuration in Dashboard:

100
esphome/hallway-switch.yaml Normal file
View File

@@ -0,0 +1,100 @@
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

View File

@@ -0,0 +1,33 @@
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:

View File

@@ -0,0 +1,33 @@
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:

View File

@@ -0,0 +1,33 @@
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:

View File

@@ -0,0 +1,55 @@
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

View File

@@ -1,8 +1,15 @@
{ pkgs, ... }:
{ {
services.home-assistant.extraComponents = [ services.home-assistant.extraComponents = [
"daikin" "daikin"
"enocean" "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 = { services.home-assistant.config = {
sensor = [ sensor = [

View File

@@ -0,0 +1,18 @@
{ 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/
'';
}

View File

@@ -0,0 +1,27 @@
{ 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)";
};
}

View File

@@ -20,12 +20,12 @@ buildNpmPackage rec {
runHook preInstall runHook preInstall
mkdir $out mkdir $out
cp scheduler-card.js $out cp card-mod.js $out
runHook postInstall runHook postInstall
''; '';
passthru.entrypoint = "scheduler-card.js"; passthru.entrypoint = "card-mod.js";
meta = with lib; { 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."; 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.";

View File

@@ -6,7 +6,7 @@
}: }:
buildHomeAssistantComponent rec { buildHomeAssistantComponent rec {
owner = "KartoffelToby"; owner = "nielsfaber";
domain = "scheduler"; domain = "scheduler";
version = "3.3.7"; version = "3.3.7";

View File

@@ -4,7 +4,7 @@ let
pkgs-with-home-assistant = import (builtins.fetchGit { pkgs-with-home-assistant = import (builtins.fetchGit {
name = "new-home-assistant"; name = "new-home-assistant";
url = "https://github.com/nixos/nixpkgs/"; url = "https://github.com/nixos/nixpkgs/";
rev = "268bb5090a3c6ac5e1615b38542a868b52ef8088"; rev = "41dea55321e5a999b17033296ac05fe8a8b5a257";
}) {}; }) {};
in in
{ {
@@ -91,6 +91,7 @@ in
./power-saving.nix ./power-saving.nix
./pushover.nix ./pushover.nix
./presense.nix ./presense.nix
./remote.nix
./roborock.nix ./roborock.nix
./scene-switch.nix ./scene-switch.nix
./shelly.nix ./shelly.nix
@@ -149,6 +150,25 @@ in
"tplink_omada" "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; [ services.home-assistant.extraPackages = ps: with ps; [
mysqlclient mysqlclient
]; ];

View File

@@ -49,7 +49,7 @@
friendly_name = "Any multimedia device on"; friendly_name = "Any multimedia device on";
device_class = "connectivity"; device_class = "connectivity";
value_template = '' value_template = ''
{% 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)) %} {% 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)) %}
on on
{% else %} {% else %}
off off
@@ -73,6 +73,12 @@
} }
]; ];
sequence = [ sequence = [
{
service = "automation.turn_off";
target = {
entity_id = "automation.all_multimedia_off"; # Replace with your target automation ID
};
}
{ {
service = "switch.turn_on"; service = "switch.turn_on";
target = { target = {
@@ -94,6 +100,24 @@
command = "b64:JgBOAJaSFREVNRU2FTUVERURFRAVERURFTUVNhU1FREVERUQFREVERUQFTYVNRURFREVEBURFTYVNRURFRAVNhU1FTYVNRUABfmWkhURFQANBQAAAAAAAAAAAAA="; 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
};
}
]; ];
} }
{ {

View File

@@ -1,9 +1,33 @@
{ pkgs, ... }:
let
bermuda = pkgs.callPackage ./custom-components/bermuda.nix {};
in
{ {
services.home-assistant.extraComponents = [ services.home-assistant.extraComponents = [
"daikin" "daikin"
"enocean" "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 = { services.home-assistant.config = {
"automation presense kitchen" = { "automation presense kitchen" = {
alias = "presense kitchen"; alias = "presense kitchen";
@@ -36,103 +60,6 @@
]; ];
}; };
sensor = [ 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("") }}
'';
};
};
}
]; ];
}; };
} }

View File

@@ -0,0 +1,333 @@
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";
}
];
};
};
}