diff options
Diffstat (limited to 'makefu/2configs/bureautomation')
19 files changed, 716 insertions, 258 deletions
diff --git a/makefu/2configs/bureautomation/automation/10h_timer.nix b/makefu/2configs/bureautomation/automation/10h_timer.nix new file mode 100644 index 000000000..dd747114e --- /dev/null +++ b/makefu/2configs/bureautomation/automation/10h_timer.nix @@ -0,0 +1,154 @@ +[ + { alias = "start Felix 10h"; + trigger = { + platform = "state"; + entity_id = [ "device_tracker.felix_phone" "device_tracker.felix_laptop" ]; + from = "not_home"; + to = "home"; + }; + condition = { + condition = "and"; + conditions = [ + { + condition = "state"; + entity_id = "timer.felix_10h"; + state = "idle"; + } + { + condition = "time"; + after = "06:00:00"; + before = "12:00:00"; + } + ]; + }; + action = [ + { service = "timer.start"; + entity_id = [ "timer.felix_10h" "timer.felix_8_30h" "timer.felix_7h" ] ; + } + { service = "homeassistant.turn_on"; + entity_id = [ + "script.buzz_red_led_fast" + "script.blitz_10s" + ]; + } + { service = "light.turn_on"; + data = { + effect = "2"; + entity_id = [ "light.status_felix" ]; + }; + } + ]; + } + + { alias = "Disable Felix timer at button press"; + trigger = { + platform = "state"; + entity_id = "binary_sensor.redbutton"; + to = "on"; + }; + condition = { + condition = "and"; + conditions = [ + { + condition = "state"; + entity_id = "timer.felix_10h"; + state = "active"; + } + { + condition = "time"; + after = "12:00:00"; + before = "22:00:00"; + } + ]; + }; + action = + [ + { + service = "timer.cancel"; + entity_id = [ "timer.felix_10h" "timer.felix_8_30h" "timer.felix_7h" ]; + } + { + service = "homeassistant.turn_on"; + entity_id = [ "script.buzz_red_led_fast" ]; + } + { + service = "homeassistant.turn_off"; + entity_id = [ "light.status_felix" ]; + } + ]; + } + + { + alias = "Genug gearbeitet Felix"; + trigger = + { + platform = "event"; + event_type = "timer.finished"; + event_data.entity_id = "timer.felix_7h"; + }; + action = + [ + { service = "light.turn_on"; + data = { + rgb_color= [0 255 0]; + # effect = "0"; + entity_id = [ "light.status_felix" ]; + }; + } + ]; + } + + { + alias = "nun aber nach hause"; + trigger = + { + platform = "event"; + event_type = "timer.finished"; + event_data.entity_id = "timer.felix_8_30h"; + }; + action = + [ + { service = "light.turn_on"; + data = { + rgb_color= [255 255 0]; + # effect = "0"; + entity_id = [ "light.status_felix" ]; + }; + } + ]; + } + + { + alias = "Zu lange Felix!"; + trigger = + { + platform = "event"; + event_type = "timer.finished"; + event_data.entity_id = "timer.felix_10h"; + }; + action = + [ + { + service = "notify.telegrambot"; + data = { + title = "Zu lange Felix!"; + message = "Du bist schon 10 Stunden auf Arbeit, geh jetzt gefälligst nach Hause!"; + }; + } + { + service = "homeassistant.turn_on"; + entity_id = [ + "script.buzz_red_led" + "script.blitz_10s" + ]; + } + { service = "light.turn_on"; + data = { + rgb_color= [255 0 0]; + effect = "0"; + entity_id = [ "light.status_felix" ]; + }; + } + ]; + } +] diff --git a/makefu/2configs/bureautomation/automation/bureau-shutdown.nix b/makefu/2configs/bureautomation/automation/bureau-shutdown.nix new file mode 100644 index 000000000..c632a9e69 --- /dev/null +++ b/makefu/2configs/bureautomation/automation/bureau-shutdown.nix @@ -0,0 +1,66 @@ +[ + { alias = "Turn on Fernseher on group home"; + trigger = { + platform = "state"; + entity_id = "group.team"; + from = "not_home"; + to = "home"; + }; + action = { + service = "homeassistant.turn_on"; + entity_id = [ + "switch.fernseher" + "switch.feuer" + ]; + }; + } + { alias = "Turn off Fernseher after last in group left"; + trigger = [ + { # trigger when movement was detected at the time + platform = "state"; + entity_id = "group.team"; + from = "home"; + to = "not_home"; + } + { # trigger at 18:00 no matter what + # to avoid 'everybody left before 18:00:00' + platform = "time"; + at = "18:00:00"; + } + ]; + action = [ + { + service = "homeassistant.turn_off"; + entity_id = [ + "switch.fernseher" + "switch.feuer" + "light.status_felix" + "light.status_daniel" + ]; + } + { + service = "notify.telegrambot"; + data = { + title = "Bureau Shutdown"; + message = "All devices are turned off due to {{ trigger.platform }} - {{ trigger }}"; + }; + } + ]; + condition = + { condition = "and"; + conditions = [ + { + condition = "time"; + before = "06:30:00"; #only turn off between 6:30 and 18:00 + after = "18:00:00"; + # weekday = [ "mon" "tue" "wed" "thu" "fri" ]; + } + { # if anybody is still there + condition = "state"; + entity_id = "group.team"; + state = "not_home"; + } + ]; + }; + } +] diff --git a/makefu/2configs/bureautomation/automation/nachtlicht.nix b/makefu/2configs/bureautomation/automation/nachtlicht.nix new file mode 100644 index 000000000..2becd4a39 --- /dev/null +++ b/makefu/2configs/bureautomation/automation/nachtlicht.nix @@ -0,0 +1,43 @@ +[ + { + alias = "Turn off Nachtlicht on sunrise"; + trigger = + { + platform = "sun"; + event = "sunrise"; + }; + action = + { + service = "homeassistant.turn_off"; + entity_id = [ "group.nachtlicht" ]; + }; + } + + { + alias = "Turn on Nachtlicht on motion and dusk"; + 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"; + } + ]; + }; + action = + { + service = "homeassistant.turn_on"; + entity_id = [ "group.nachtlicht" ]; + }; + } +] diff --git a/makefu/2configs/bureautomation/binary_sensor/buttons.nix b/makefu/2configs/bureautomation/binary_sensor/buttons.nix new file mode 100644 index 000000000..e23c4a362 --- /dev/null +++ b/makefu/2configs/bureautomation/binary_sensor/buttons.nix @@ -0,0 +1,17 @@ +let + tasmota_button = name: topic: + # detects a pushbutton press from tasmota + { platform = "mqtt"; + inherit name; + state_topic = "/bam/${topic}/cmnd/POWER"; + availability_topic = "/bam/${topic}/tele/LWT"; + payload_on = "ON"; + payload_off = "OFF"; + payload_available= "Online"; + payload_not_available= "Offline"; + # expire_after = "5"; #expire after 5 seconds + qos = 1; + }; +in [ + (tasmota_button "RedButton" "redbutton") +] diff --git a/makefu/2configs/bureautomation/binary_sensor/motion.nix b/makefu/2configs/bureautomation/binary_sensor/motion.nix new file mode 100644 index 000000000..ad8fab038 --- /dev/null +++ b/makefu/2configs/bureautomation/binary_sensor/motion.nix @@ -0,0 +1,12 @@ +[ + { platform = "mqtt"; + device_class = "motion"; + name = "Motion"; + state_topic = "/bam/easy2/movement/Switch"; + payload_on = "1"; + payload_off = "0"; + availability_topic = "/bam/easy2/tele/LWT"; + payload_available = "Online"; + payload_not_available = "Offline"; + } +] diff --git a/makefu/2configs/bureautomation/camera/verkehrskamera.nix b/makefu/2configs/bureautomation/camera/verkehrskamera.nix new file mode 100644 index 000000000..f2dfdcd91 --- /dev/null +++ b/makefu/2configs/bureautomation/camera/verkehrskamera.nix @@ -0,0 +1,14 @@ +[ + { name = "Baumarkt"; + platform = "generic"; + still_image_url = http://t4915209254324-p80-c0-h6jv2afnujcoftrcstsafb45kdrqv4buy.webdirect.mdex.de/oneshotimage ;# baumarkt + } + { name = "Autobahn Heilbronn"; + platform = "generic"; + still_image_url = https://api.svz-bw.de/v2/verkehrskameras/kameras/K10 ; + } + { name = "Autobahn Singen"; + platform = "generic"; + still_image_url = https://api.svz-bw.de/v2/verkehrskameras/kameras/K11 ; + } +] diff --git a/makefu/2configs/bureautomation/device_tracker/openwrt.nix b/makefu/2configs/bureautomation/device_tracker/openwrt.nix new file mode 100644 index 000000000..0db9821a1 --- /dev/null +++ b/makefu/2configs/bureautomation/device_tracker/openwrt.nix @@ -0,0 +1,14 @@ +[ + { platform = "luci"; + name = "router"; + host = "192.168.8.1"; + username = "root"; + password = import <secrets/hass/router.nix>; + interval_seconds = 30; # instead of 12seconds + consider_home = 300; # 5 minutes timeout + new_device_defaults = { + track_new_devices = true; + hide_if_away = false; + }; + } +] diff --git a/makefu/2configs/bureautomation/devices/users.nix b/makefu/2configs/bureautomation/devices/users.nix new file mode 100644 index 000000000..305c0ca86 --- /dev/null +++ b/makefu/2configs/bureautomation/devices/users.nix @@ -0,0 +1,17 @@ +{ + thorsten-phone = { + name = "Thorsten"; + mac = "8c:f5:a3:bc:83:a0"; + track = true; + hide_if_away = true; + }; + felix-laptop = { + name = "Felix"; + mac = "6c:88:14:b4:43:9c"; + track = true; + hide_if_away = true; + }; + # b0:e5:ed:52:ee:43 - honor8 + # 38:94:96:b0:13:c7 - android-4ef03e4f4a14b6b9 + # ac:5f:3e:cc:b8:5e - Galaxy S7 +} diff --git a/makefu/2configs/bureautomation/hass.nix b/makefu/2configs/bureautomation/hass.nix index b70c9b030..4e5fe7b63 100644 --- a/makefu/2configs/bureautomation/hass.nix +++ b/makefu/2configs/bureautomation/hass.nix @@ -1,79 +1,9 @@ { pkgs, lib, ... }: let - tasmota_rgb = name: topic: -# LED WS2812b -# effect_state_topic: "stat/led/Scheme" -# effect_command_topic: "cmnd/led/Scheme" -# effect_value_template: "{{ value_json.Scheme }}" - { platform = "mqtt"; - inherit name; - retain = false; - qos = 1; - optimistic = false; - # state - # TODO: currently broken, will not use the custom state topic - state_topic = "/bam/${topic}/stat/POWER"; - command_topic = "/bam/${topic}/cmnd/POWER"; - availability_topic = "/bam/${topic}/tele/LWT"; - payload_on= "ON"; - payload_off= "OFF"; - payload_available= "Online"; - payload_not_available= "Offline"; - # brightness - brightness_state_topic = "/bam/${topic}/stat/Dimmer"; - brightness_command_topic = "/bam/${topic}/cmnd/Dimmer"; - brightness_value_template = "{{ value_json.Dimmer }}"; - brightness_scale = 100; - # color - rgb_state_topic = "/bam/${topic}/stat/Color"; - rgb_command_topic = "/bam/${topic}/cmnd/Color2"; - rgb_command_mode = "hex"; - rgb_command_template = "{{ '%02x%02x%02x' | format(red, green, blue)}}"; - # effects - effect_state_topic = "/bam/${topic}/stat/Scheme"; - effect_command_topic = "/bam/${topic}/cmnd/Scheme"; - effect_value_template = "{{ value_json.Scheme }}"; - effect_list = [ 0 1 2 3 4 5 6 7 8 9 10 11 12 ]; -}; - tasmota_plug = name: topic: - { platform = "mqtt"; - inherit name; - state_topic = "/bam/${topic}/stat/POWER"; - command_topic = "/bam/${topic}/cmnd/POWER"; - availability_topic = "/bam/${topic}/tele/LWT"; - payload_on= "ON"; - payload_off= "OFF"; - payload_available= "Online"; - payload_not_available= "Offline"; - }; - espeasy_dht22 = name: [ - { platform = "mqtt"; - name = "${name} DHT22 Temperature"; - device_class = "temperature"; - state_topic = "/bam/${name}/dht22/Temperature"; - availability_topic = "/bam/${name}/tele/LWT"; - payload_available = "Online"; - payload_not_available = "Offline"; - } - { platform = "mqtt"; - device_class = "humidity"; - name = "${name} DHT22 Humidity"; - state_topic = "/bam/${name}/dht22/Humidity"; - availability_topic = "/bam/${name}/tele/LWT"; - payload_available = "Online"; - payload_not_available = "Offline"; - }]; - espeasy_ds18 = name: - { platform = "mqtt"; - name = "${name} DS18 Temperature"; - state_topic = "/bam/${name}/ds18/Temperature"; - availability_topic = "/bam/${name}/tele/LWT"; - payload_available = "Online"; - payload_not_available = "Offline"; - }; + kodi-host = "192.168.8.11"; in { networking.firewall.allowedTCPPorts = [ 8123 ]; - + state = [ "/var/lib/hass/known_devices.yaml" ]; services.home-assistant = { enable = true; config = { @@ -104,90 +34,60 @@ in { retain = true; }; }; - switch = [ - (tasmota_plug "Bauarbeiterlampe" "plug") - (tasmota_plug "Blitzdings" "plug2") - (tasmota_plug "Fernseher" "plug3") - (tasmota_plug "Feuer" "plug4") - (tasmota_plug "Nachtlicht" "plug5") - ]; - light = [ - (tasmota_rgb "Status Felix" "status1") + switch = (import ./switch/tasmota_switch.nix) ++ + (import ./switch/rfbridge.nix); + light = (import ./light/statuslight.nix) ++ + (import ./light/buzzer.nix); + timer = { + felix_10h = { + name = "Felix 10h Timer"; + duration = "10:00:00"; + }; + felix_8_30h = { + name = "Felix 8_30h Timer"; + duration = "08:30:00"; + }; + felix_7h = { + name = "Felix 7h Timer"; + duration = "07:00:00"; + }; + }; + notify = [ + { + platform = "kodi"; + name = "wbob-kodi"; + host = kodi-host; + } + { + platform = "telegram"; + name = "telegrambot"; + chat_id = builtins.elemAt + (builtins.fromJSON (builtins.readFile + <secrets/hass/telegram-bot.json>)).allowed_chat_ids 0; + } ]; - binary_sensor = [ - { platform = "mqtt"; - device_class = "motion"; - name = "Motion"; - state_topic = "/bam/easy2/movement/Switch"; - payload_on = "1"; - payload_off = "0"; - availability_topic = "/bam/easy2/tele/LWT"; - payload_available = "Online"; - payload_not_available = "Offline"; + media_player = [ + { platform = "kodi"; + host = kodi-host; } ]; + script = (import ./script/multi_blink.nix) {inherit lib;}; + binary_sensor = + (import ./binary_sensor/buttons.nix) ++ + (import ./binary_sensor/motion.nix); + sensor = - (espeasy_dht22 "easy1") ++ - (espeasy_dht22 "easy2") ++ - [ (espeasy_ds18 "easy3" ) - { platform = "luftdaten"; - name = "Ditzingen"; - sensorid = "5341"; - monitored_conditions = [ "P1" "P2" ]; - } + (import ./sensor/espeasy.nix) ++ + ((import ./sensor/outside.nix) {inherit lib;}) ++ + (import ./sensor/influxdb.nix); + + camera = + (import ./camera/verkehrskamera.nix); + + # not yet released + #person = + # (import ./person/team.nix ); - { platform = "darksky"; - api_key = lib.removeSuffix "\n" - (builtins.readFile <secrets/hass/darksky.apikey>); - language = "de"; - monitored_conditions = [ "summary" "icon" - "nearest_storm_distance" "precip_probability" - "precip_intensity" - "temperature" # "temperature_high" "temperature_low" - "apparent_temperature" - "hourly_summary" # next 24 hours text - "humidity" - "pressure" - "uv_index" ]; - units = "si" ; - update_interval = { - days = 0; - hours = 0; - minutes = 30; - seconds = 0; - }; - } - #{ platform = "influxdb"; - # queries = [ - # { name = "mean value of feinstaub P1"; - # where = '' "node" = 'esp8266-1355142' ''; - # measurement = "feinstaub"; - # database = "telegraf"; - # field = "P1"; - # } - # { name = "mean value of feinstaub P2"; - # where = '' "node" = 'esp8266-1355142' ''; - # measurement = "feinstaub"; - # database = "telegraf"; - # field = "P2"; - # } - # ]; - #} - ]; - camera = [ - { name = "Baumarkt"; - platform = "generic"; - still_image_url = http://t4915209254324-p80-c0-h6jv2afnujcoftrcstsafb45kdrqv4buy.webdirect.mdex.de/oneshotimage ;# baumarkt - } - { name = "Autobahn Heilbronn"; - platform = "generic"; - still_image_url = https://api.svz-bw.de/v2/verkehrskameras/kameras/K10 ; - } - { name = "Autobahn Singen"; - platform = "generic"; - still_image_url = https://api.svz-bw.de/v2/verkehrskameras/kameras/K11 ; - } - ]; frontend = { }; http = { }; conversation = {}; @@ -195,148 +95,82 @@ in { logbook = {}; tts = [ { platform = "google";} ]; recorder = {}; + telegram_bot = [ + (builtins.fromJSON + (builtins.readFile <secrets/hass/telegram-bot.json>)) + ]; group = { default_view = { view = "yes"; entities = [ "group.sensors" + "group.camera" "group.outside" + "group.team" + "group.nachtlicht" "group.switches" - "group.automation" - "group.camera" ]; }; automation = [ - "automation.turn_off_fernseher_10_minutes_after_last_movement" - "automation.turn_off_nachtlicht_on_sunrise" - "automation.turn_on_nachtlicht_on_motion_and_dusk" ]; switches = [ "switch.bauarbeiterlampe" "switch.blitzdings" "switch.fernseher" "switch.feuer" - "switch.nachtlicht" "light.status_felix" + "light.status_daniel" + "light.buslicht" + ]; + team = [ + "device_tracker.thorsten_phone" + "device_tracker.felix_phone" + "device_tracker.ecki_tablet" + "device_tracker.daniel_phone" + "device_tracker.carsten_phone" + # "person.thorsten" + # "person.felix" + # "person.ecki" + # "person.daniel" ]; camera = [ "camera.Baumarkt" "camera.Autobahn_Heilbronn" "camera.Autobahn_Singen" ]; + nachtlicht = [ + "switch.nachtlicht_a" + "switch.nachtlicht_b" + "switch.nachtlicht_c" + "switch.nachtlicht_d" + ]; sensors = [ - "binary_sensor.motion" + "media_player.kodi" + "script.blitz_10s" + "script.buzz_red_led_fast" + "timer.felix_10h" "sensor.easy2_dht22_humidity" "sensor.easy2_dht22_temperature" + # "binary_sensor.redbutton" ]; outside = [ - "sensor.ditzingen_pm10" - "sensor.ditzingen_pm25" + # "sensor.ditzingen_pm10" + # "sensor.ditzingen_pm25" "sensor.dark_sky_temperature" "sensor.dark_sky_humidity" - "sensor.dark_sky_pressure" + # "sensor.dark_sky_pressure" "sensor.dark_sky_hourly_summary" - "sensor.dark_sky_minutely_summary" + "device_tracker.router" ]; }; # only for automation # feedreader.urls = [ "http://www.heise.de/security/rss/news-atom.xml" ]; - automation = [ - { alias = "Turn on Fernseher on movement"; - trigger = { - platform = "state"; - entity_id = "binary_sensor.motion"; - to = "on"; - }; - action = { - service = "homeassistant.turn_on"; - entity_id = [ - "switch.fernseher" - "switch.feuer" - "light.status_felix" - ]; - }; - } - { - alias = "Turn off Nachtlicht on sunrise"; - trigger = - { - platform = "sun"; - event = "sunrise"; - }; - action = - { - service = "homeassistant.turn_off"; - entity_id = [ "switch.nachtlicht" ]; - }; - } - { - alias = "Turn on Nachtlicht on motion and dusk"; - 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"; - } - ]; - }; - action = - { - service = "homeassistant.turn_on"; - entity_id = [ "switch.nachtlicht" ]; - }; - } - { alias = "Turn off Fernseher 10 minutes after last movement"; - trigger = [ - { # trigger when movement was detected at the time - platform = "state"; - entity_id = "binary_sensor.motion"; - to = "off"; - for.minutes = 10; - } - { # trigger at 20:00 no matter what - # to avoid 'everybody left before 18:00:00' - platform = "time"; - at = "18:00:00"; - } - ]; - action = { - service = "homeassistant.turn_off"; - entity_id = [ - "switch.fernseher" - "switch.feuer" - "light.status_felix" - ]; - }; - condition = - { condition = "and"; - conditions = [ - { - condition = "time"; - before = "06:30:00"; #only turn off between 6:30 and 18:00 - after = "18:00:00"; - # weekday = [ "mon" "tue" "wed" "thu" "fri" ]; - } - { - condition = "state"; - entity_id = "binary_sensor.motion"; - state = "off"; - } - ]; - }; - } - ]; + # we don't use imports because the expressions do not merge in + # home-assistant + automation = (import ./automation/bureau-shutdown.nix) ++ + (import ./automation/nachtlicht.nix) ++ + (import ./automation/10h_timer.nix); + device_tracker = (import ./device_tracker/openwrt.nix ); }; }; } diff --git a/makefu/2configs/bureautomation/led-fader.nix b/makefu/2configs/bureautomation/led-fader.nix new file mode 100644 index 000000000..d7f728534 --- /dev/null +++ b/makefu/2configs/bureautomation/led-fader.nix @@ -0,0 +1,23 @@ +{ config, lib, pkgs, buildPythonPackage, ... }: + +let + mq = "192.168.8.11"; + pkg = pkgs.ampel; +in { + systemd.services.led-fader = { + description = "Send led change to message queue"; + environment = { + NIX_PATH = "/var/src"; + }; + after = [ "network-online.target" ] ++ (lib.optional config.services.mosquitto.enable "mosquitto.service"); + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + # User = "nobody"; # need a user with permissions to run nix-shell + ExecStartPre = pkgs.writeDash "sleep.sh" "sleep 2"; + ExecStart = "${pkg}/bin/ampel"; + Restart = "always"; + RestartSec = 10; + PrivateTmp = true; + }; + }; +} diff --git a/makefu/2configs/bureautomation/light/buzzer.nix b/makefu/2configs/bureautomation/light/buzzer.nix new file mode 100644 index 000000000..2067e47bf --- /dev/null +++ b/makefu/2configs/bureautomation/light/buzzer.nix @@ -0,0 +1,28 @@ +let + tasmota_pwm = name: topic: pwmid: max: + let + id = "PWM${toString pwmid}"; + in { platform = "mqtt"; + inherit name; + state_topic = "/bam/${topic}/stat/RESULT"; + state_value_template = ''{%- if value_json["PWM"]["${id}"]| int > 0 -%} ${toString max} {%- else -%} 0 {%- endif -%}''; + + command_topic = "/bam/${topic}/cmnd/${id}"; + on_command_type = "brightness"; + brightness_command_topic = "/bam/${topic}/cmnd/${id}"; + brightness_value_template = ''{{value_json["PWM"]["${id}"]}}''; + brightness_scale = max; + payload_on = "${toString max}"; + payload_off = "0"; + availability_topic = "/bam/${topic}/tele/LWT"; + payload_available= "Online"; + payload_not_available= "Offline"; + retain = true; + optimistic = false; + qos = 0; + }; +in +[ +# (tasmota_pwm "RedButton LED" "redbutton" 1 1023) #LED PWM1 + (tasmota_pwm "RedButton Buzzer" "redbutton" 2 512) #buzzer PWM2 +] diff --git a/makefu/2configs/bureautomation/light/statuslight.nix b/makefu/2configs/bureautomation/light/statuslight.nix new file mode 100644 index 000000000..0acab7281 --- /dev/null +++ b/makefu/2configs/bureautomation/light/statuslight.nix @@ -0,0 +1,57 @@ +let + tasmota_rgb = name: topic: +# LED WS2812b +# effect_state_topic: "stat/led/Scheme" +# effect_command_topic: "cmnd/led/Scheme" +# effect_value_template: "{{ value_json.Scheme }}" + { platform = "mqtt"; + inherit name; + retain = false; + qos = 1; + #optimistic = true; + # state + command_topic = "/bam/${topic}/cmnd/POWER"; + state_topic = "/bam/${topic}/tele/STATE"; + value_template = "{{ value_json.POWER }}"; + availability_topic = "/bam/${topic}/tele/LWT"; + payload_on = "ON"; + payload_off = "OFF"; + payload_available= "Online"; + payload_not_available= "Offline"; + # brightness + brightness_state_topic = "/bam/${topic}/tele/STATE"; + brightness_value_template = "{{value_json.Dimmer}}"; + brightness_command_topic = "/bam/${topic}/cmnd/Dimmer"; |