From 59d57e09c5c4ef502dbb6c09f985e778a60b386a Mon Sep 17 00:00:00 2001
From: Felix Tenley <dev@felschr.com>
Date: Wed, 2 Dec 2020 10:29:39 +0100
Subject: [PATCH] feat(rpi4): update home-assistant config

---
 services/home-assistant.nix | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/services/home-assistant.nix b/services/home-assistant.nix
index 8923145..f546906 100644
--- a/services/home-assistant.nix
+++ b/services/home-assistant.nix
@@ -85,6 +85,8 @@ in {
       };
       default_config = { };
       config = { };
+      "automation editor" = "!include automations.yaml";
+      automation = {};
       frontend = { };
       mobile_app = { };
       discovery = { };
@@ -105,6 +107,41 @@ in {
         discovery_prefix = "homeassistant";
       };
       owntracks = { mqtt_topic = "owntracks/#"; };
+      netatmo = {
+        client_id = "!secret netatmo_client_id";
+        client_secret = "!secret netatmo_client_secret";
+      };
+      sensor = [
+        {
+          platform = "template";
+          sensors = {
+            energy_total_usage = {
+              friendly_name = "Total Energy Usage";
+              unit_of_measurement = "kWh";
+              value_template = ''
+                {{
+                  (states.sensor.outlet_computer_energy_total.state | float) +
+                  (states.sensor.outlet_tv_energy_total.state | float)
+                }}
+              '';
+            };
+          };
+        }
+      ];
+      utility_meter = {
+        energy_total_usage_daily = {
+          source = "sensor.energy_total_usage";
+          cycle = "daily";
+        };
+        energy_total_usage_monthly = {
+          source = "sensor.energy_total_usage";
+          cycle = "monthly";
+        };
+        energy_total_usage_yearly = {
+          source = "sensor.energy_total_usage";
+          cycle = "yearly";
+        };
+      };
     };
     # configWritable = true; # doesn't work atm
   };