changes
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
{ config, pkgs, ... }:
|
||||
let
|
||||
domain = "home-assistant.cloonar.com";
|
||||
pkgs-with-home-assistant = import (builtins.fetchGit {
|
||||
name = "new-home-assistant";
|
||||
url = "https://github.com/nixos/nixpkgs/";
|
||||
rev = "268bb5090a3c6ac5e1615b38542a868b52ef8088";
|
||||
}) {};
|
||||
in
|
||||
{
|
||||
users.users.hass = {
|
||||
@@ -35,21 +40,21 @@ in
|
||||
extraFlags = [
|
||||
"--capability=CAP_NET_ADMIN"
|
||||
];
|
||||
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";
|
||||
};
|
||||
@@ -104,6 +109,7 @@ in
|
||||
|
||||
environment.systemPackages = [
|
||||
pkgs.wol
|
||||
pkgs.mariadb
|
||||
];
|
||||
|
||||
services.nginx.enable = true;
|
||||
@@ -127,6 +133,7 @@ in
|
||||
};
|
||||
|
||||
services.home-assistant = {
|
||||
package = pkgs-with-home-assistant.home-assistant;
|
||||
enable = true;
|
||||
};
|
||||
|
||||
@@ -140,6 +147,30 @@ in
|
||||
"tplink_omada"
|
||||
];
|
||||
|
||||
services.home-assistant.extraPackages = ps: with ps; [
|
||||
mysqlclient
|
||||
];
|
||||
|
||||
services.mysql = {
|
||||
enable = true;
|
||||
package = pkgs.mariadb;
|
||||
ensureDatabases = [ "hass" ];
|
||||
ensureUsers = [
|
||||
{
|
||||
name = "hass";
|
||||
ensurePermissions = {
|
||||
"hass.*" = "ALL PRIVILEGES";
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
services.mysqlBackup = {
|
||||
enable = true;
|
||||
databases = [ "hass" ];
|
||||
};
|
||||
|
||||
services.home-assistant.config =
|
||||
let
|
||||
hiddenEntities = [
|
||||
@@ -148,6 +179,9 @@ in
|
||||
];
|
||||
in
|
||||
{
|
||||
recorder = {
|
||||
db_url = "mysql://hass@localhost/hass?unix_socket=/var/run/mysqld/mysqld.sock";
|
||||
};
|
||||
homeassistant = {
|
||||
name = "Home";
|
||||
latitude = "!secret home_latitude";
|
||||
|
||||
@@ -370,6 +370,7 @@
|
||||
{
|
||||
platform = "group";
|
||||
name = "Livingroom Lights";
|
||||
all = true;
|
||||
entities = [
|
||||
"light.livingroom_switch"
|
||||
"light.living_bulb_1"
|
||||
@@ -380,6 +381,37 @@
|
||||
"light.living_bulb_6"
|
||||
];
|
||||
}
|
||||
{
|
||||
platform = "switch";
|
||||
name = "Kitchen Switch";
|
||||
entity_id = "switch.kitchen_switch";
|
||||
}
|
||||
{
|
||||
platform = "group";
|
||||
name = "Kitchen Lights";
|
||||
all = true;
|
||||
entities = [
|
||||
"light.kitchen_switch"
|
||||
"light.kitchen"
|
||||
];
|
||||
}
|
||||
{
|
||||
platform = "switch";
|
||||
name = "Bedroom Switch";
|
||||
entity_id = "switch.bedroom_switch";
|
||||
}
|
||||
{
|
||||
platform = "group";
|
||||
name = "Bedroom Lights";
|
||||
all = true;
|
||||
entities = [
|
||||
"light.bedroom_switch"
|
||||
"light.bedroom_bulb_1"
|
||||
"light.bedroom_bulb_2"
|
||||
"light.bedroom_bulb_3"
|
||||
"light.bedroom_bulb_4"
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
friendly_name = "Any multimedia device on";
|
||||
device_class = "connectivity";
|
||||
value_template = ''
|
||||
{% if 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 > 5)) %}
|
||||
{% if 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
|
||||
|
||||
@@ -7,17 +7,22 @@ let
|
||||
{ name = "Living Bulb 4"; id = "485519D94A28"; }
|
||||
{ name = "Living Bulb 5"; id = "485519DA6B6A"; }
|
||||
{ name = "Living Bulb 6"; id = "485519D9E018"; }
|
||||
{ name = "Bedroom Bulb 1"; id = "08F9E06F4EB4"; }
|
||||
{ name = "Bedroom Bulb 2"; id = "485519EE0ED9"; }
|
||||
{ name = "Bedroom Bulb 3"; id = "08F9E06FE779"; }
|
||||
{ name = "Bedroom Bulb 4"; id = "485519EE00A0"; }
|
||||
];
|
||||
|
||||
switches = [
|
||||
{ name = "Kitchen Switch"; id = "483FDA8274C2"; relay = "0"; }
|
||||
{ name = "Livingroom Switch"; id = "483FDA8274C2"; relay = "1"; }
|
||||
];
|
||||
|
||||
proswitches = [
|
||||
{ name = "Hallway Circuit"; id = "c8f09e894448"; relay = "0"; }
|
||||
{ name = "Bathroom Circuit"; id = "c8f09e894448"; relay = "1"; }
|
||||
{ name = "Kitchen Circuit"; id = "c8f09e894448"; relay = "2"; }
|
||||
{ name = "Livingroom Switch"; id = "shellyplus2pm-e86beae5d5d8"; relay = "0"; }
|
||||
{ name = "Kitchen Switch"; id = "shellyplus2pm-e86beae5d5d8"; relay = "1"; }
|
||||
{ name = "Bedroom Switch"; id = "shelly1pmminig3-34b7da933fe0"; relay = "0"; }
|
||||
{ name = "Hallway Circuit"; id = "shellypro3-c8f09e894448"; relay = "0"; }
|
||||
{ name = "Bathroom Circuit"; id = "shellypro3-c8f09e894448"; relay = "1"; }
|
||||
{ name = "Kitchen Circuit"; id = "shellypro3-c8f09e894448"; relay = "2"; }
|
||||
];
|
||||
in {
|
||||
services.home-assistant.extraComponents = [
|
||||
@@ -45,14 +50,14 @@ in {
|
||||
in {
|
||||
name = switch.name;
|
||||
unique_id = unique_id;
|
||||
state_topic = "shellies/shellypro3-${switch.id}/status/switch:${switch.relay}";
|
||||
state_topic = "shellies/${switch.id}/status/switch:${switch.relay}";
|
||||
value_template = "{{ value_json.output }}";
|
||||
state_on = true;
|
||||
state_off = false;
|
||||
command_topic = "shellies/shellypro3-c8f09e894448/rpc";
|
||||
command_topic = "shellies/${switch.id}/rpc";
|
||||
payload_on = "{\"id\":${switch.relay}, \"src\":\"homeassistant\", \"method\":\"Switch.Set\", \"params\":{\"id\":${switch.relay}, \"on\":true}}";
|
||||
payload_off = "{\"id\":${switch.relay}, \"src\":\"homeassistant\", \"method\":\"Switch.Set\", \"params\":{\"id\":${switch.relay}, \"on\":false}}";
|
||||
availability_topic = "shellies/shellypro3-${switch.id}/online";
|
||||
availability_topic = "shellies/${switch.id}/online";
|
||||
payload_available = "true";
|
||||
payload_not_available = "false";
|
||||
}
|
||||
|
||||
@@ -14,6 +14,14 @@
|
||||
{
|
||||
delay = 1700;
|
||||
}
|
||||
{
|
||||
service = "switch.turn_on";
|
||||
entity_id = "switch.hallway_circuit";
|
||||
}
|
||||
{
|
||||
service = "switch.turn_on";
|
||||
entity_id = "switch.bathroom_circuit";
|
||||
}
|
||||
{
|
||||
service = "switch.turn_on";
|
||||
entity_id = "switch.78_8c_b5_fe_41_62_port_2_poe"; # livingroom
|
||||
@@ -64,6 +72,14 @@
|
||||
service = "switch.turn_off";
|
||||
entity_id = "switch.78_8c_b5_fe_41_62_port_3_poe";
|
||||
}
|
||||
{
|
||||
service = "switch.turn_off";
|
||||
entity_id = "switch.hallway_circuit";
|
||||
}
|
||||
{
|
||||
service = "switch.turn_off";
|
||||
entity_id = "switch.bathroom_circuit";
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user