many changes
This commit is contained in:
71
hosts/fw.cloonar.com/modules/home-assistant/3dprinter.nix
Normal file
71
hosts/fw.cloonar.com/modules/home-assistant/3dprinter.nix
Normal file
@@ -0,0 +1,71 @@
|
||||
{ config, ... }:
|
||||
let
|
||||
unstable = import
|
||||
(builtins.fetchTarball https://github.com/nixos/nixpkgs/tarball/nixpkgs-unstable)
|
||||
# reuse the current configuration
|
||||
{ config = config.nixpkgs.config; };
|
||||
in {
|
||||
services.home-assistant.customComponents = with unstable.home-assistant-custom-components; [
|
||||
moonraker
|
||||
];
|
||||
|
||||
services.home-assistant.config = {
|
||||
sensor = [
|
||||
{
|
||||
platform = "rest";
|
||||
name = "creality extruder";
|
||||
resource = "http://k1c-63e9.cloonar.smart:7125/printer/objects/query?extruder";
|
||||
value_template = "OK";
|
||||
json_attributes_path = "$.result.status.extruder";
|
||||
json_attributes = [
|
||||
"pressure_advance"
|
||||
"power"
|
||||
"target"
|
||||
"temperature"
|
||||
];
|
||||
}
|
||||
{
|
||||
platform = "rest";
|
||||
name = "creality print stats";
|
||||
resource = "http://k1c-63e9.cloonar.smart:7125/printer/objects/query?print_stats";
|
||||
value_template = "OK";
|
||||
json_attributes_path = "$.result.status.print_stats";
|
||||
json_attributes = [
|
||||
"filename"
|
||||
"total_duration"
|
||||
"print_duration"
|
||||
"filament_used"
|
||||
"state"
|
||||
"message"
|
||||
];
|
||||
}
|
||||
{
|
||||
platform = "template";
|
||||
sensors = {
|
||||
crality_hotend_actual = {
|
||||
friendly_name = "Hot End Actual";
|
||||
value_template = "{{ state_attr('sensor.creality_extruder', 'temperature') | float | round(1) }}";
|
||||
device_class = "temperature";
|
||||
unit_of_measurement = "°C";
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
"automation 3d printer state" = {
|
||||
alias = "3d printer state change";
|
||||
hide_entity = true;
|
||||
trigger = [
|
||||
{
|
||||
platform = "template";
|
||||
value_template = "{{ state_attr('sensor.creality_print_stats','state') == 'standby' }}";
|
||||
}
|
||||
];
|
||||
action = {
|
||||
service = "notify.mobile_app_dominiks_iphone";
|
||||
data = {
|
||||
message = "Printer status changed to {{ state_attr('sensor.creality_print_stats','state') }}";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -7,20 +7,33 @@
|
||||
services.home-assistant.config = {
|
||||
sensor = [
|
||||
{
|
||||
name = "Living Room Window Handle";
|
||||
name = "Living Room Window Handle 2";
|
||||
platform = "enocean";
|
||||
id = [ 129 0 227 53 ];
|
||||
device_class = "windowhandle";
|
||||
}
|
||||
{
|
||||
name = "Living Room Window Handle 1";
|
||||
platform = "enocean";
|
||||
id = [ 129 0 229 8 ];
|
||||
device_class = "windowhandle";
|
||||
}
|
||||
];
|
||||
"automation ac_livingroom" = {
|
||||
alias = "ac_livingroom";
|
||||
hide_entity = true;
|
||||
trigger = {
|
||||
platform = "state";
|
||||
entity_id = "sensor.windowhandle_living_room_window_handle";
|
||||
to = [ "open" "tilt" ];
|
||||
};
|
||||
trigger = [
|
||||
{
|
||||
platform = "state";
|
||||
entity_id = "sensor.windowhandle_living_room_window_handle_1";
|
||||
to = [ "open" "tilt" ];
|
||||
}
|
||||
{
|
||||
platform = "state";
|
||||
entity_id = "sensor.windowhandle_living_room_window_handle_2";
|
||||
to = [ "open" "tilt" ];
|
||||
}
|
||||
];
|
||||
action = {
|
||||
service = "climate.set_hvac_mode";
|
||||
target = {
|
||||
|
||||
@@ -66,9 +66,11 @@ in
|
||||
};
|
||||
config = { lib, config, pkgs, ... }: {
|
||||
imports = [
|
||||
./3dprinter.nix
|
||||
./ac.nix
|
||||
# ./aeg.nix
|
||||
./battery.nix
|
||||
./electricity.nix
|
||||
./enocean.nix
|
||||
./ldap.nix
|
||||
./light.nix
|
||||
@@ -77,6 +79,7 @@ in
|
||||
./notify.nix
|
||||
./pc.nix
|
||||
./pushover.nix
|
||||
./presense.nix
|
||||
./roborock.nix
|
||||
./scene-switch.nix
|
||||
./sleep.nix
|
||||
@@ -201,8 +204,18 @@ in
|
||||
];
|
||||
};
|
||||
|
||||
users.users.hass.extraGroups = [ "dialout" ];
|
||||
services.mosquitto = {
|
||||
enable = true;
|
||||
listeners = [
|
||||
{
|
||||
acl = [ "pattern readwrite #" ];
|
||||
omitPasswordAuth = true;
|
||||
settings.allow_anonymous = true;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
users.users.hass.extraGroups = [ "dialout" ];
|
||||
system.stateVersion = "23.05";
|
||||
};
|
||||
};
|
||||
|
||||
28
hosts/fw.cloonar.com/modules/home-assistant/electricity.nix
Normal file
28
hosts/fw.cloonar.com/modules/home-assistant/electricity.nix
Normal file
@@ -0,0 +1,28 @@
|
||||
{ config, ... }:
|
||||
let
|
||||
unstable = import
|
||||
(builtins.fetchTarball https://github.com/nixos/nixpkgs/tarball/nixpkgs-unstable)
|
||||
# reuse the current configuration
|
||||
{ config = config.nixpkgs.config; };
|
||||
in {
|
||||
services.home-assistant.customComponents = with unstable.home-assistant-custom-components; [
|
||||
epex_spot
|
||||
];
|
||||
|
||||
services.home-assistant.config = {
|
||||
sensor = [
|
||||
{
|
||||
platform = "template";
|
||||
sensors = {
|
||||
electricity_price = {
|
||||
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 }}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -11,15 +11,22 @@
|
||||
name = "xbox";
|
||||
platform = "ping";
|
||||
host = "xbox.cloonar.multimedia";
|
||||
count = 1;
|
||||
scan_interval = 2;
|
||||
count = 2;
|
||||
scan_interval = 5;
|
||||
}
|
||||
{
|
||||
name = "ps5";
|
||||
platform = "ping";
|
||||
host = "ps5.cloonar.multimedia";
|
||||
count = 1;
|
||||
scan_interval = 2;
|
||||
count = 2;
|
||||
scan_interval = 5;
|
||||
}
|
||||
{
|
||||
name = "steamdeck";
|
||||
platform = "ping";
|
||||
host = "steamdeck.cloonar.com";
|
||||
count = 2;
|
||||
scan_interval = 5;
|
||||
}
|
||||
{
|
||||
platform = "template";
|
||||
@@ -28,7 +35,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' %}
|
||||
{% 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)) %}
|
||||
on
|
||||
{% else %}
|
||||
off
|
||||
@@ -80,6 +87,25 @@
|
||||
# };
|
||||
# };
|
||||
# };
|
||||
"automation steamdeck on" = {
|
||||
alias = "steamdeck on";
|
||||
hide_entity = true;
|
||||
trigger = {
|
||||
platform = "template";
|
||||
value_template = "{% if is_state('binary_sensor.steamdeck', 'on') and (states('sensor.steamdeck_power') | float > 5) %}true{% endif %}";
|
||||
};
|
||||
action = [
|
||||
{
|
||||
service = "denonavr.get_command";
|
||||
target = {
|
||||
entity_id = "media_player.marantz_sr6015";
|
||||
};
|
||||
data = {
|
||||
command = "/goform/formiPhoneAppDirect.xml?SIDVD";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
"automation xbox on" = {
|
||||
alias = "xbox on";
|
||||
hide_entity = true;
|
||||
@@ -90,26 +116,14 @@
|
||||
};
|
||||
action = [
|
||||
{
|
||||
service = "media_player.select_source";
|
||||
service = "denonavr.get_command";
|
||||
target = {
|
||||
entity_id = "media_player.marantz_sr6015";
|
||||
};
|
||||
data = {
|
||||
source = "Xbox";
|
||||
command = "/goform/formiPhoneAppDirect.xml?SIGAME";
|
||||
};
|
||||
}
|
||||
# {
|
||||
# delay = 5;
|
||||
# }
|
||||
# {
|
||||
# service = "denonavr.get_command";
|
||||
# target = {
|
||||
# entity_id = "media_player.marantz_sr6015";
|
||||
# };
|
||||
# data = {
|
||||
# command = "/goform/formiPhoneAppDirect.xml?PWSTANDBY";
|
||||
# };
|
||||
# }
|
||||
];
|
||||
};
|
||||
"automation firetv on" = {
|
||||
@@ -258,29 +272,188 @@
|
||||
}
|
||||
];
|
||||
};
|
||||
# "automation multimedia input" = {
|
||||
# hide_entity = true;
|
||||
# trigger = {
|
||||
# platform = "state";
|
||||
# entity_id = "sensor.computer_power";
|
||||
# };
|
||||
# condition = {
|
||||
# condition = "and";
|
||||
# conditions = [
|
||||
# {
|
||||
# condition = "numeric_state";
|
||||
# entity_id = "sensor.computer_power";
|
||||
# below = 15;
|
||||
# }
|
||||
# "{{ (as_timestamp(now()) - as_timestamp(states.switch.computer.last_changed)) > 300 }}"
|
||||
# ];
|
||||
# };
|
||||
# action = {
|
||||
# service = "switch.turn_off";
|
||||
# target = {
|
||||
# entity_id = [ "switch.computer" ];
|
||||
# };
|
||||
# };
|
||||
# };
|
||||
"automation bedroom tv off" = {
|
||||
alias = "bedroom tv off";
|
||||
hide_entity = true;
|
||||
trigger = {
|
||||
platform = "state";
|
||||
entity_id = "media_player.fire_tv_firetv_bedroom_cloonar_multimedia";
|
||||
to = "off";
|
||||
};
|
||||
action = [
|
||||
{
|
||||
service = "media_player.turn_off";
|
||||
target = {
|
||||
entity_id = "media_player.samsung_7_series_55";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
"automation multimedia scene switch" = {
|
||||
trigger = {
|
||||
platform = "state";
|
||||
entity_id = "sensor.computer_power";
|
||||
};
|
||||
condition = {
|
||||
condition = "state";
|
||||
entity_id = "binary_sensor.multimedia_device_on";
|
||||
state = "on";
|
||||
};
|
||||
action = [
|
||||
{
|
||||
choose = [
|
||||
{
|
||||
conditions = [
|
||||
{
|
||||
condition = "state";
|
||||
entity_id = "media_player.android_tv_metz_cloonar_multimedia";
|
||||
state = "on";
|
||||
}
|
||||
];
|
||||
sequence = [
|
||||
{
|
||||
service = "remote.send_command";
|
||||
target = {
|
||||
entity_id = "remote.rmproplus";
|
||||
};
|
||||
data = {
|
||||
num_repeats = 1;
|
||||
delay_secs = 0.4;
|
||||
hold_secs = 0;
|
||||
command = "b64:sQs0AB0JCxsLGx0IHQgLGh0ICxoLGx0JCxodCQobCxoLAAEXHQgdCR0JCxodCQsbCxsLGx0JCxoAAAAA";
|
||||
};
|
||||
}
|
||||
{
|
||||
delay = 1;
|
||||
}
|
||||
{
|
||||
service = "remote.send_command";
|
||||
target = {
|
||||
entity_id = "remote.rmproplus";
|
||||
};
|
||||
data = {
|
||||
num_repeats = 1;
|
||||
delay_secs = 0.4;
|
||||
hold_secs = 0;
|
||||
command = "b64:sgAQAhgMGAwZCwcdGQsHHQcdBx0ZCwcdGQsHHQcdGQsZCwcdGQwGHgYeGAwYDAYeBx0GHgcAARgZCxkMGAwGHhkLBh4HHQYeGQsHHRkLBx0GHhkLGQsHHhgMBh4GHhgMGAwGHgcdBh4GAAEZGQwYDBgMBx0YDAYeBx0GHhgMBx0ZCwcdBx0ZCxkMBh4YDAYeBh4YDBgMBh4GHgcdBgABGhgMGAwYDAYeGQsHHQYeBh4YDAYeGAwHHQcdGQwYDAYeGAwGHgYeGAwYDAYeBh4HHQcAARkYDBgMGAwGHhkLBx0HHQcdGQsHHRkMBh0HHRkMGAwGHhgMBh4HHRkLGAwHHQcdBx0HAAEZGAwZCxkLBx0ZDAYdBx0HHRkMBh0ZDAYeBh4YDBgMBh4ZCwcdBx0ZCxkMBh0HHQcdBwABGRkLGQwYDAYeGAwGHgYeBh0ZDAYeGAwHHQcdGQsZDAYdGQwGHQcdGQsZDAYdBx4GHgYAARkZDBgNFwwHHRkMBh0HHQcdGQsHHRkNBR8FHhgMGAwGHRkMBh4GHhkLGA0FHwYdBx4GAAEaGAsZDBgMBh8XDAYeBh4GHhg1EwwGHgcdGAwZDAYeGAwGHgYeGAsZDAYeBh4GHQcAARkZCxkMGAwGHhgMBh4GHgYeGQsHHRgMBx0HHRkLGQwGHhgMBh4GHhkLGQsHHQcdBx0HAAEZGQsYDRgPBAAF3AAAAAAAAAAA";
|
||||
};
|
||||
}
|
||||
{
|
||||
delay = 1;
|
||||
}
|
||||
# TODO turn on beamer
|
||||
{
|
||||
service = "media_player.turn_off";
|
||||
target = {
|
||||
entity_id = "media_player.android_tv_metz_cloonar_multimedia";
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
{
|
||||
conditions = [
|
||||
{
|
||||
condition = "or";
|
||||
conditions = [
|
||||
{
|
||||
condition = "state";
|
||||
entity_id = "media_player.android_tv_metz_cloonar_multimedia";
|
||||
state = "off";
|
||||
}
|
||||
{
|
||||
condition = "state";
|
||||
entity_id = "media_player.android_tv_metz_cloonar_multimedia";
|
||||
state = "unavailable";
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
sequence = [
|
||||
{
|
||||
service = "remote.send_command";
|
||||
target = {
|
||||
entity_id = "remote.rmproplus";
|
||||
};
|
||||
data = {
|
||||
num_repeats = 1;
|
||||
delay_secs = 0.4;
|
||||
hold_secs = 0;
|
||||
command = "b64:sQs0AB0JCxsLGx0IHQgLGh0ICxoLGx0JCxodCQobCxoLAAEXHQgdCR0JCxodCQsbCxsLGx0JCxoAAAAA";
|
||||
};
|
||||
}
|
||||
{
|
||||
delay = 1;
|
||||
}
|
||||
{
|
||||
service = "remote.send_command";
|
||||
target = {
|
||||
entity_id = "remote.rmproplus";
|
||||
};
|
||||
data = {
|
||||
num_repeats = 1;
|
||||
delay_secs = 0.4;
|
||||
hold_secs = 0;
|
||||
command = "b64:sgBqAgkaBBoJCRsJHBoKGgoJGgQaCQkaBAgbGwoIHAgcGwkJGwgAARkbCRsJGwkJGgQaCgkaBAgbCRsbCQkbGwkJGgQIGxwJGwkJGxsJCRwIHBoKCBsECBsbCAQIGwkAARgbChoKGgoJGxsJCRoECBsJHBsJCRoEGgkJGwkcGgobCQkbGwkJGwkbGwoIHAkbGwkJGwkAARgbCRsJGwoIGxwJCRsJGwkbGwoIGxwIChoKGhwJGwkJHBsJCRsJGxsJCRsJHBsJCRsJAAEYGwkbCRsKCBscCQkbCRsJGxsJCRwbCQkbCRsbCRsJCRscCQgcCRocCQkbCRsbCQobCQABGBsJGwkbCQkbHAkJGwkbCRsbCQkbGwoJGwkbGwkbCQkbGwoIHAkbGwkJGgobGwkKGwkAARccCRsJGwkJHBsJCRsJGwkbGwkJGxsKCRsIHBsJGwkJGxsKCRoJGxwJCRsJGxsJChsIAAEZGwgcCRsJCRscCQkbCRsJGhwJCRscCQkaChsbCRsJCRscCQgcCRocCQkbCRsbCggcCQABGBsJGwkbCggcGwkJGwkbCRsbCggcGgoJGwkbGwkbCggcGwkJGwkbGwkJHAgcGwkJGwkAARgbChoKGgoJGhwJCRsJGwkcGgoJGxsJCRsJGxsJHAkJGxsJCRsJGhwJCRwJGhwJCRsJAAEYGwoaChsJCRsbCQkaChsJGxwJCRsbCQkbCRsbChsJCRsbCQkbCRsbCgkbCRsbCQkcCAABFwQaChsJGwkJGxsKCBwIHAgcGwkJGxsKCBwIGwQaCRsJCRwaCggcCBwbCQkbCRwaCggcCAAF3AAAAAAAAAAAAAAAAAAA";
|
||||
};
|
||||
}
|
||||
];
|
||||
# TODO turn off beamer
|
||||
}
|
||||
{
|
||||
conditions = [
|
||||
{
|
||||
condition = "state";
|
||||
entity_id = "media_player.android_tv_metz_cloonar_multimedia";
|
||||
state = "off";
|
||||
}
|
||||
];
|
||||
sequence = [
|
||||
{
|
||||
service = "media_player.turn_on";
|
||||
target = {
|
||||
entity_id = "media_player.android_tv_metz_cloonar_multimedia";
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
{
|
||||
conditions = [
|
||||
{
|
||||
condition = "state";
|
||||
entity_id = "media_player.android_tv_metz_cloonar_multimedia";
|
||||
state = "unavailable";
|
||||
}
|
||||
];
|
||||
sequence = [
|
||||
{
|
||||
service = "remote.send_command";
|
||||
target = {
|
||||
entity_id = "remote.rmproplus";
|
||||
};
|
||||
data = {
|
||||
num_repeats = 1;
|
||||
delay_secs = 0.4;
|
||||
hold_secs = 0;
|
||||
command = "b64:JgBOAJaSFREVNRU2FTUVERURFRAVERURFTUVNhU1FREVERUQFREVERUQFTYVNRURFREVEBURFTYVNRURFRAVNhU1FTYVNRUABfmWkhURFQANBQAAAAAAAAAAAAA=";
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
}
|
||||
{
|
||||
delay = 5;
|
||||
}
|
||||
{
|
||||
service = "androidtv.adb_command";
|
||||
target = {
|
||||
entity_id = "media_player.android_tv_metz_cloonar_multimedia";
|
||||
};
|
||||
data = {
|
||||
command = "adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHDMI100004";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
138
hosts/fw.cloonar.com/modules/home-assistant/presense.nix
Normal file
138
hosts/fw.cloonar.com/modules/home-assistant/presense.nix
Normal file
@@ -0,0 +1,138 @@
|
||||
{
|
||||
services.home-assistant.extraComponents = [
|
||||
"daikin"
|
||||
"enocean"
|
||||
];
|
||||
|
||||
services.home-assistant.config = {
|
||||
"automation presense kitchen" = {
|
||||
alias = "presense kitchen";
|
||||
mode = "restart";
|
||||
trigger = {
|
||||
platform = "state";
|
||||
entity_id = [
|
||||
"sensor.presense_kitchen"
|
||||
];
|
||||
};
|
||||
action = [
|
||||
{
|
||||
choose = [
|
||||
{
|
||||
conditions = [ "{{ trigger.to_state.state == \"\" }}" ];
|
||||
sequence = [
|
||||
];
|
||||
}
|
||||
{
|
||||
conditions = [ "{{ trigger.to_state.state != \"\" }}" ];
|
||||
sequence = [
|
||||
{
|
||||
service = "light.turn_on";
|
||||
entity_id = "light.kitchen_lights";
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
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("") }}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -4,10 +4,8 @@
|
||||
alias = "wakeup";
|
||||
hide_entity = true;
|
||||
trigger = {
|
||||
platform = "template";
|
||||
value_template = ''
|
||||
{{ now().timestamp() | timestamp_custom('%H:%M') == (as_timestamp(strptime(states('sensor.bedtime_alarm'), "%H:%M")) - 1800) | timestamp_custom('%H:%M', false) }}
|
||||
'';
|
||||
platform = "time";
|
||||
at = "input_datetime.wakeup";
|
||||
};
|
||||
action = {
|
||||
service_template = "switch.turn_on";
|
||||
|
||||
Reference in New Issue
Block a user