summaryrefslogtreecommitdiffstats
path: root/lass/2configs/hass/lib.nix
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2020-04-21 21:50:59 +0200
committermakefu <github@syntax-fehler.de>2020-04-21 21:50:59 +0200
commitc96504d9a0f8f9f5c80c9630906c177ff3667e55 (patch)
tree7b763ca595967bfcc5d8307751091f373fd38e47 /lass/2configs/hass/lib.nix
parent4fc2235ab0a8a11ea21965c86e5ba17279384db4 (diff)
parentcabaf519b5970cbe5c1e57832d3bd12da4f47371 (diff)
Merge remote-tracking branch 'lass/master'
Diffstat (limited to 'lass/2configs/hass/lib.nix')
-rw-r--r--lass/2configs/hass/lib.nix83
1 files changed, 83 insertions, 0 deletions
diff --git a/lass/2configs/hass/lib.nix b/lass/2configs/hass/lib.nix
new file mode 100644
index 000000000..c69f5e887
--- /dev/null
+++ b/lass/2configs/hass/lib.nix
@@ -0,0 +1,83 @@
+{
+ lights = {
+ bett = "light.0x0017880106ed3bd8_light";
+ essen = "light.0x0017880108327622_light";
+ arbeit = "light.0x0017880106ee2865_light";
+ nass = "light.0x00178801082e9f2f_light";
+ };
+
+ sensors = {
+ bett = "0x00178801086ac38c";
+ };
+
+ lightswitch = switch: light: {
+ automation = [
+ {
+ trigger = {
+ platform = "mqtt";
+ topic = "zigbee/${switch}";
+ };
+ condition = {
+ condition = "or";
+ conditions = [
+ {
+ condition = "template";
+ value_template = "{{ trigger.payload_json.action == 'on-press' }}";
+ }
+ {
+ condition = "template";
+ value_template = "{{ trigger.payload_json.action == 'up-press' }}";
+ }
+ {
+ condition = "and";
+ conditions = [
+ {
+ condition = "template";
+ value_template = "{{ trigger.payload_json.action == 'down-press' }}";
+ }
+ {
+ condition = "template";
+ value_template = "{{ trigger.payload_json.brightness > 30 }}";
+ }
+ ];
+ }
+ ];
+ };
+ action = [
+ {
+ service = "light.turn_on";
+ data_template = {
+ entity_id = light;
+ brightness = "{{ trigger.payload_json.brightness }}";
+ };
+ }
+ ];
+ }
+ {
+ trigger = {
+ platform = "mqtt";
+ topic = "zigbee/${switch}";
+ };
+ condition = {
+ condition = "or";
+ conditions = [
+ {
+ condition = "template";
+ value_template = "{{ trigger.payload_json.action == 'off-press' }}";
+ }
+ {
+ condition = "template";
+ value_template = "{{ trigger.payload_json.brightness < 30 }}";
+ }
+ ];
+ };
+ action = {
+ service = "light.turn_off";
+ data_template = {
+ entity_id = light;
+ };
+ };
+ }
+ ];
+ };
+}