feat: home-assistant changes
This commit is contained in:
@@ -1,8 +1,15 @@
|
||||
{ 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 = [
|
||||
|
||||
@@ -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/
|
||||
'';
|
||||
}
|
||||
@@ -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)";
|
||||
};
|
||||
}
|
||||
@@ -20,12 +20,12 @@ buildNpmPackage rec {
|
||||
runHook preInstall
|
||||
|
||||
mkdir $out
|
||||
cp scheduler-card.js $out
|
||||
cp card-mod.js $out
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
passthru.entrypoint = "scheduler-card.js";
|
||||
passthru.entrypoint = "card-mod.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.";
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
}:
|
||||
|
||||
buildHomeAssistantComponent rec {
|
||||
owner = "KartoffelToby";
|
||||
owner = "nielsfaber";
|
||||
domain = "scheduler";
|
||||
version = "3.3.7";
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ let
|
||||
pkgs-with-home-assistant = import (builtins.fetchGit {
|
||||
name = "new-home-assistant";
|
||||
url = "https://github.com/nixos/nixpkgs/";
|
||||
rev = "268bb5090a3c6ac5e1615b38542a868b52ef8088";
|
||||
rev = "41dea55321e5a999b17033296ac05fe8a8b5a257";
|
||||
}) {};
|
||||
in
|
||||
{
|
||||
@@ -91,6 +91,7 @@ in
|
||||
./power-saving.nix
|
||||
./pushover.nix
|
||||
./presense.nix
|
||||
./remote.nix
|
||||
./roborock.nix
|
||||
./scene-switch.nix
|
||||
./shelly.nix
|
||||
@@ -149,6 +150,25 @@ 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
|
||||
];
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
friendly_name = "Any multimedia device on";
|
||||
device_class = "connectivity";
|
||||
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
|
||||
{% else %}
|
||||
off
|
||||
@@ -73,6 +73,12 @@
|
||||
}
|
||||
];
|
||||
sequence = [
|
||||
{
|
||||
service = "automation.turn_off";
|
||||
target = {
|
||||
entity_id = "automation.all_multimedia_off"; # Replace with your target automation ID
|
||||
};
|
||||
}
|
||||
{
|
||||
service = "switch.turn_on";
|
||||
target = {
|
||||
@@ -94,6 +100,24 @@
|
||||
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
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
{
|
||||
|
||||
@@ -1,9 +1,33 @@
|
||||
{ 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";
|
||||
@@ -36,103 +60,6 @@
|
||||
];
|
||||
};
|
||||
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("") }}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
333
hosts/fw.cloonar.com/modules/home-assistant/remote.nix
Normal file
333
hosts/fw.cloonar.com/modules/home-assistant/remote.nix
Normal 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";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user