hswaw/machines: add sound.waw.hackerspace.pl

Change-Id: Id0e6a02d9ae4cf61d758713a99d21c6da0c72b66
Reviewed-on: https://gerrit.hackerspace.pl/c/hscloud/+/1401
Reviewed-by: vuko <vuko@hackerspace.pl>
Reviewed-by: informatic <informatic@hackerspace.pl>
diff --git a/hswaw/machines/sound.waw.hackerspace.pl/home-assistant.nix b/hswaw/machines/sound.waw.hackerspace.pl/home-assistant.nix
new file mode 100644
index 0000000..468f5e5
--- /dev/null
+++ b/hswaw/machines/sound.waw.hackerspace.pl/home-assistant.nix
@@ -0,0 +1,289 @@
+{
+  default_config = {};
+
+  homeassistant = {
+    auth_providers = [
+      {
+        type = "homeassistant";
+      }
+      {
+        type = "trusted_networks";
+        trusted_networks = ["127.0.0.1" "::1" "10.0.0.0/8" "fd00::/8"];
+        allow_bypass_login = true;
+      }
+    ];
+    customize = {
+      "light.left_par_brightness" = {hidden = true;};
+      "light.right_par_brightness" = {hidden = true;};
+      "switch.portable_spejsiot_node_b4a90f" = {icon = "mdi:power-plug";};
+      "switch.projection_screen" = {icon = "mdi:projector-screen";};
+      "switch.projector" = {icon = "mdi:projector";};
+      "switch.samsung_tv_mute" = {icon = "mdi:volume-off";};
+      "switch.samsung_tv_telelele" = {icon = "mdi:monitor";};
+      "switch.space_heater" = {icon = "mdi:fire";};
+    };
+    customize_glob = {"media_player.m*" = {custom_ui_state_card = "state-card-mini-media-player";};};
+    elevation = "106";
+    latitude = "52.25";
+    longitude = "21";
+    name = "Warsaw Hackerspace";
+    time_zone = "Europe/Warsaw";
+    unit_system = "metric";
+  };
+
+  http = {
+    use_x_forwarded_for = true;
+    trusted_proxies = [ "127.0.0.1" "::1" ];
+  };
+
+  automation = [
+    {
+      action = {
+        data_template = {
+          payload = "{{ states('input_number.polycom_hdmi_gain') }}";
+          retain = true;
+          topic = "iot/polycom/hdmi:main/gain/set";
+        };
+        service = "mqtt.publish";
+      };
+      hide_entity = true;
+      trigger = {
+        entity_id = "input_number.polycom_hdmi_gain";
+        platform = "state";
+      };
+    }
+    {
+      action = {
+        data_template = {
+          payload = "{{ states('input_number.polycom_aux1_gain') }}";
+          retain = true;
+          topic = "iot/polycom/aux1:main/gain/set";
+        };
+        service = "mqtt.publish";
+      };
+      hide_entity = true;
+      trigger = {
+        entity_id = "input_number.polycom_aux1_gain";
+        platform = "state";
+      };
+    }
+    {
+      action = {
+        data_template = {
+          payload = "{{ states.input_select.hdmi_source_a.attributes['options'].index(states('input_select.hdmi_source_a')) }}";
+          retain = true;
+          topic = "iot/3c189c/matrix/sourceA/set";
+        };
+        service = "mqtt.publish";
+      };
+      hide_entity = true;
+      trigger = {
+        entity_id = "input_select.hdmi_source_a";
+        platform = "state";
+      };
+    }
+    {
+      action = {
+        data_template = {
+          payload = "{{ states.input_select.hdmi_source_b.attributes['options'].index(states('input_select.hdmi_source_b')) }}";
+          retain = true;
+          topic = "iot/3c189c/matrix/sourceB/set";
+        };
+        service = "mqtt.publish";
+      };
+      hide_entity = true;
+      trigger = {
+        entity_id = "input_select.hdmi_source_b";
+        platform = "state";
+      };
+    }
+    {
+      action = {
+        data = {
+          entity_id = "input_select.hdmi_source_b";
+          option = "Input 1 / Kolumna";
+        };
+        service = "input_select.select_option";
+      };
+      alias = "Switch projector on HDMI1 connect";
+      trigger = {
+        payload = "true";
+        platform = "mqtt";
+        topic = "iot/3c189c/matrix/rx1_online";
+      };
+    }
+    {
+      action = {
+        data = {
+          entity_id = "input_select.hdmi_source_b";
+          option = "Chromecast";
+        };
+        service = "input_select.select_option";
+      };
+      alias = "Switch projector on HDMI1 disconnect";
+      trigger = {
+        payload = "false";
+        platform = "mqtt";
+        topic = "iot/3c189c/matrix/rx1_online";
+      };
+    }
+    {
+      action = {
+        data_template = {
+          payload = "{{ states('input_number.heater_fan_speed') }}";
+          retain = true;
+          topic = "iot/ab20d2/heater/fan/set";
+        };
+        service = "mqtt.publish";
+      };
+      hide_entity = true;
+      trigger = {
+        entity_id = "input_number.heater_fan_speed";
+        platform = "state";
+      };
+    }
+  ];
+
+  cast = {media_player = [{host = "10.8.1.44";}];};
+
+  # TODO fix and enable
+  #frontend = {
+  #  extra_html_url = ["/local/custom_ui/state-card-mini-media-player.html"];
+  #  extra_html_url_es5 = ["/local/custom_ui/state-card-mini-media-player_es5.html"];
+  #};
+
+  group = {
+    av = {
+      control = "hidden";
+      entities = ["switch.projector" "switch.projection_screen" "input_select.hdmi_source_a" "input_number.polycom_hdmi_gain" "switch.samsung_tv_telelele" "switch.samsung_tv_mute" "input_select.hdmi_source_b" "input_number.polycom_aux1_gain" "switch.aux1_gain_mic" "media_player.mpd"];
+      name = "HackAV";
+    };
+    heater = {
+      control = "hidden";
+      entities = ["switch.space_heater" "input_number.heater_fan_speed"];
+      name = "Heater";
+    };
+  };
+  input_number = {
+    heater_fan_speed = {
+      max = 100;
+      min = 0;
+      name = "Fan Speed";
+      step = 1;
+    };
+    polycom_aux1_gain = {
+      max = 10;
+      min = -40;
+      name = "AUX1 Audio Gain";
+      step = 1;
+    };
+    polycom_hdmi_gain = {
+      max = 0;
+      min = -40;
+      name = "HDMI Audio Gain";
+      step = 1;
+    };
+  };
+  input_select = {
+    hdmi_source_b = {
+      name = "Projector HDMI Source (Conn A/TX1)";
+      options = ["PS3" "Input 1 / Kolumna" "Unused" "Chromecast"];
+    };
+  };
+
+  media_player = [
+    {
+      host = "10.8.1.16";
+      platform = "mpd";
+    }
+  ];
+
+  mqtt = {
+    light = [
+      {
+        command_topic = "iot/077521/relay/on/set";
+        name = "Main room";
+        payload_off = "false";
+        payload_on = "true";
+        retain = true;
+        state_topic = "iot/077521/relay/on";
+      }
+    ];
+    fan = [
+      {
+        command_topic = "iot/c0dbe7/relay/on/set";
+        name = "Wyciąg";
+        payload_off = "false";
+        payload_on = "true";
+        retain = true;
+        state_topic = "iot/c0dbe7/relay/on";
+      }
+    ];
+    sensor = [
+      {
+        name = "DCR01 Temperature";
+        qos = 0;
+        state_topic = "iot/3394f5/environment/degree";
+        unit_of_measurement = "ºC";
+      }
+      {
+        name = "DCR01 Humidity";
+        qos = 0;
+        state_topic = "iot/3394f5/environment/humidity";
+        unit_of_measurement = "%";
+      }
+    ];
+    switch = [
+      {
+        command_topic = "iot/b4a90f/relay/on/set";
+        name = "Portable SpejsIoT node (b4a90f)";
+        payload_off = "false";
+        payload_on = "true";
+        retain = true;
+        state_topic = "iot/b4a90f/relay/on";
+      }
+      {
+        command_topic = "iot/d106e1/screen/down/set";
+        name = "Projection screen";
+        payload_off = "false";
+        payload_on = "true";
+        retain = true;
+        state_topic = "iot/d106e1/screen/down";
+      }
+      {
+        command_topic = "iot/craptrap/windows10/state/set";
+        name = "Windows 10 VM (Craptrap)";
+        payload_off = "pmsuspended";
+        payload_on = "running";
+        state_topic = "iot/craptrap/windows10/state";
+      }
+      {
+        command_topic = "iot/ab20d2/heater/on/set";
+        name = "Space Heater";
+        payload_off = "false";
+        payload_on = "true";
+        retain = true;
+        state_topic = "iot/ab20d2/heater/on";
+      }
+    ];
+  };
+
+  scene = [
+    {
+      entities = {
+        "light.main_room" = false;
+        "switch.projection_screen" = true;
+        "switch.projector" = true;
+      };
+      name = "Cinema";
+    }
+    {
+      entities = {
+        "light.main_room" = true;
+        "switch.projection_screen" = false;
+        "switch.projector" = false;
+      };
+      name = "Standard";
+    }
+  ];
+}