summaryrefslogtreecommitdiffstats
path: root/lass/2configs/hass/lib.nix
diff options
context:
space:
mode:
authorJeschli <jeschli@gmail.com>2020-04-22 12:35:00 +0200
committerJeschli <jeschli@gmail.com>2020-04-22 12:35:00 +0200
commit3c0496ec1a774c539cf10311bff821ff07ddbf01 (patch)
tree9fbafe92c3f26571bb562255d86ffcc2975216ea /lass/2configs/hass/lib.nix
parent119a7cfe5a87323ec7231c263abc444229564a1c (diff)
parentcabaf519b5970cbe5c1e57832d3bd12da4f47371 (diff)
Merge branch 'master' of https://cgit.lassul.us/stockholm
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;
+ };
+ };
+ }
+ ];
+ };
+}