ma bureautomation: refactor
This commit is contained in:
parent
6fa6659b8f
commit
bccb2fd4e5
@ -5,15 +5,41 @@
|
||||
entity_id = "group.team";
|
||||
from = "not_home";
|
||||
to = "home";
|
||||
for.seconds = 30;
|
||||
};
|
||||
action = {
|
||||
action = [
|
||||
{
|
||||
service = "homeassistant.turn_on";
|
||||
entity_id = [
|
||||
"switch.fernseher"
|
||||
"switch.feuer"
|
||||
];
|
||||
}
|
||||
{
|
||||
service = "media_player.kodi_call_method";
|
||||
data = {
|
||||
entity_id = "media_player.kodi";
|
||||
method = "Player.Open";
|
||||
item.partymode = "music";
|
||||
};
|
||||
}
|
||||
{
|
||||
service = "tts.google_say";
|
||||
entity_id = "media_player.kodi";
|
||||
data = {
|
||||
message = "Willkommen in deinem Lieblingsbüro";
|
||||
language = "de";
|
||||
};
|
||||
}
|
||||
{
|
||||
service = "notify.telegrambot";
|
||||
data = {
|
||||
title = "Bureau Startup";
|
||||
message = "Willkommen {{ trigger.platform }}";
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
{ alias = "Turn off Fernseher after last in group left";
|
||||
trigger = [
|
||||
{ # trigger when movement was detected at the time
|
||||
@ -42,7 +68,7 @@
|
||||
service = "notify.telegrambot";
|
||||
data = {
|
||||
title = "Bureau Shutdown";
|
||||
message = "All devices are turned off due to {{ trigger.platform }} - {{ trigger }}";
|
||||
message = "All devices are turned off due to {{ trigger.platform }}";
|
||||
};
|
||||
}
|
||||
];
|
||||
|
31
makefu/2configs/bureautomation/automation/hass-restart.nix
Normal file
31
makefu/2configs/bureautomation/automation/hass-restart.nix
Normal file
@ -0,0 +1,31 @@
|
||||
[
|
||||
{ alias = "State on HA start-up";
|
||||
trigger = {
|
||||
platform = "homeassistant";
|
||||
event = "start";
|
||||
};
|
||||
action = [
|
||||
# Startup State
|
||||
{ service = "mqtt.publish";
|
||||
data = {
|
||||
topic = "/bam/sonoffs/cmnd/state";
|
||||
payload = "";
|
||||
};
|
||||
}
|
||||
# Firmware Version
|
||||
{ service = "mqtt.publish";
|
||||
data = {
|
||||
topic = "/bam/sonoffs/cmnd/status";
|
||||
payload = "2";
|
||||
};
|
||||
}
|
||||
# Will trigger restart of all devices!
|
||||
#{ service = "mqtt.publish";
|
||||
# data = {
|
||||
# topic = "sonoffs/cmnd/SetOption59"; # configure sending state on power change
|
||||
# payload = "1";
|
||||
# };
|
||||
#}
|
||||
];
|
||||
}
|
||||
]
|
@ -1,42 +1,34 @@
|
||||
[
|
||||
# TODO: trigger if it is before dusk and somebody arives but nachtlichter are
|
||||
# off from last day
|
||||
# TODO: do not have nachtlicht turned on at night
|
||||
{
|
||||
alias = "Turn off Nachtlicht on sunrise";
|
||||
alias = "Turn on Nachtlicht at dusk"; # when it gets dim
|
||||
trigger =
|
||||
{
|
||||
platform = "sun";
|
||||
event = "sunrise";
|
||||
{ platform = "numeric_state";
|
||||
entity_id = "sun.sun";
|
||||
value_template = "{{ state.attributes.elevation }}";
|
||||
below = 10;
|
||||
|
||||
};
|
||||
action =
|
||||
{
|
||||
service = "homeassistant.turn_off";
|
||||
{ service = "homeassistant.turn_on";
|
||||
entity_id = [ "group.nachtlicht" ];
|
||||
};
|
||||
}
|
||||
|
||||
{
|
||||
alias = "Turn on Nachtlicht on motion and dusk";
|
||||
alias = "Turn off Nachtlicht at dawn";
|
||||
trigger =
|
||||
{
|
||||
platform = "state";
|
||||
entity_id = "binary_sensor.motion";
|
||||
to = "on";
|
||||
};
|
||||
condition = # 'when dark'
|
||||
{
|
||||
condition = "or";
|
||||
conditions = [
|
||||
{ condition = "sun";
|
||||
after = "sunset";
|
||||
after_offset = "-00:45:00"; # on dusk
|
||||
}
|
||||
{ condition = "sun";
|
||||
before = "sunrise";
|
||||
}
|
||||
];
|
||||
{ platform = "sun";
|
||||
event = "sunrise";
|
||||
offset = "01:30:00"; # on dawn
|
||||
};
|
||||
# TODO: when somebody is still in the buero
|
||||
# condition =
|
||||
#{
|
||||
#};
|
||||
action =
|
||||
{
|
||||
service = "homeassistant.turn_on";
|
||||
{ service = "homeassistant.turn_off";
|
||||
entity_id = [ "group.nachtlicht" ];
|
||||
};
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ in {
|
||||
state = [ "/var/lib/hass/known_devices.yaml" ];
|
||||
services.home-assistant = {
|
||||
enable = true;
|
||||
package = pkgs.home-assistant.override { python3 = pkgs.python36; };
|
||||
config = {
|
||||
homeassistant = {
|
||||
name = "Bureautomation";
|
||||
@ -13,8 +14,14 @@ in {
|
||||
latitude = "48.8265";
|
||||
longitude = "9.0676";
|
||||
elevation = 303;
|
||||
auth_providers = [
|
||||
{ type = "homeassistant";}
|
||||
{ type = "legacy_api_password";}
|
||||
{ type = "trusted_networks";
|
||||
# allow_bypass_login = true;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
mqtt = {
|
||||
broker = "localhost";
|
||||
port = 1883;
|
||||
@ -79,7 +86,8 @@ in {
|
||||
sensor =
|
||||
(import ./sensor/espeasy.nix) ++
|
||||
((import ./sensor/outside.nix) {inherit lib;}) ++
|
||||
(import ./sensor/influxdb.nix);
|
||||
(import ./sensor/influxdb.nix) ++
|
||||
(import ./sensor/tasmota_firmware.nix);
|
||||
|
||||
camera =
|
||||
(import ./camera/verkehrskamera.nix);
|
||||
@ -89,12 +97,22 @@ in {
|
||||
# (import ./person/team.nix );
|
||||
|
||||
frontend = { };
|
||||
http = { };
|
||||
http = {
|
||||
# TODO: https://github.com/home-assistant/home-assistant/issues/16149
|
||||
api_password = "sistemas";
|
||||
trusted_networks = [
|
||||
"127.0.0.1/32"
|
||||
"192.168.8.0/24"
|
||||
"::1/128"
|
||||
"fd00::/8"
|
||||
];
|
||||
};
|
||||
conversation = {};
|
||||
history = {};
|
||||
logbook = {};
|
||||
tts = [ { platform = "google";} ];
|
||||
recorder = {};
|
||||
sun = {};
|
||||
telegram_bot = [
|
||||
(builtins.fromJSON
|
||||
(builtins.readFile <secrets/hass/telegram-bot.json>))
|
||||
@ -156,8 +174,10 @@ in {
|
||||
outside = [
|
||||
# "sensor.ditzingen_pm10"
|
||||
# "sensor.ditzingen_pm25"
|
||||
"sensor.dark_sky_icon"
|
||||
"sensor.dark_sky_temperature"
|
||||
"sensor.dark_sky_humidity"
|
||||
"sensor.dark_sky_uv_index"
|
||||
# "sensor.dark_sky_pressure"
|
||||
"sensor.dark_sky_hourly_summary"
|
||||
"device_tracker.router"
|
||||
@ -169,6 +189,7 @@ in {
|
||||
# home-assistant
|
||||
automation = (import ./automation/bureau-shutdown.nix) ++
|
||||
(import ./automation/nachtlicht.nix) ++
|
||||
(import ./automation/hass-restart.nix) ++
|
||||
(import ./automation/10h_timer.nix);
|
||||
device_tracker = (import ./device_tracker/openwrt.nix );
|
||||
};
|
||||
|
@ -20,7 +20,7 @@ let
|
||||
payload_not_available= "Offline";
|
||||
# brightness
|
||||
brightness_state_topic = "/bam/${topic}/tele/STATE";
|
||||
brightness_value_template = "{{value_json.Dimmer}}";
|
||||
brightness_value_template = "{{value_json.Dimmer|default(100)}}";
|
||||
brightness_command_topic = "/bam/${topic}/cmnd/Dimmer";
|
||||
brightness_scale = 100;
|
||||
# color
|
||||
@ -30,9 +30,8 @@ let
|
||||
rgb_command_template = "{{ '%02x%02x%02x' | format(red, green, blue)}}";
|
||||
# effects
|
||||
effect_state_topic = "/bam/${topic}/tele/STATE";
|
||||
effects_value_template = "{{value_json.Scheme}}";
|
||||
effects_value_template = "{{value_json.Scheme|default(0)}}";
|
||||
effect_command_topic = "/bam/${topic}/cmnd/Scheme";
|
||||
effect_value_template = "{{ value_json.Scheme }}";
|
||||
effect_list = [
|
||||
0 # single color for LED light
|
||||
1 # start wake up sequence (same as Wakeup)
|
||||
|
15
makefu/2configs/bureautomation/ota.nix
Normal file
15
makefu/2configs/bureautomation/ota.nix
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
# mosquitto_pub -t /bam/sonoffs/cmnd/OtaUrl -m "http://192.168.8.11/sonoff.bin"
|
||||
# mosquitto_pub -t /bam/sonoffs/cmnd/upgrade -m "6.5.0"
|
||||
# wget https://github.com/arendst/Sonoff-Tasmota/releases/download/v6.5.0/sonoff.bin
|
||||
# wget https://github.com/arendst/Sonoff-Tasmota/releases/download/v6.5.0/sonoff-minimal.bin
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
virtualHosts."192.168.8.11" = {
|
||||
root = "/var/www/tasmota";
|
||||
extraConfig = ''
|
||||
autoindex on;
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
16
makefu/2configs/bureautomation/sensor/tasmota_firmware.nix
Normal file
16
makefu/2configs/bureautomation/sensor/tasmota_firmware.nix
Normal file
@ -0,0 +1,16 @@
|
||||
let
|
||||
tasmota_firmware = topic:
|
||||
{ platform = "mqtt";
|
||||
name = "${topic} Firmware";
|
||||
state_topic = "/bam/${topic}/stat/STATUS2";
|
||||
availability_topic = "/bam/${topic}/tele/LWT";
|
||||
value_template = "v{{value_json.StatusFWR.Version}}";
|
||||
payload_available= "Online";
|
||||
payload_not_available= "Offline";
|
||||
};
|
||||
in
|
||||
map tasmota_firmware [
|
||||
"plug" "plug2" "plug3" "plug4" "plug5"
|
||||
"status1" "status2" "buslicht"
|
||||
"rfbridge"
|
||||
]
|
Loading…
Reference in New Issue
Block a user