diff --git a/configuration/devices/headless/server/home-assistant/README.md b/configuration/devices/headless/server/home-assistant/README.md index e589171c..93856587 100644 --- a/configuration/devices/headless/server/home-assistant/README.md +++ b/configuration/devices/headless/server/home-assistant/README.md @@ -30,14 +30,6 @@ - Delete all areas - `Settings` -> `Areas & zones` -> `Areas` -## Configure myStrom buttons - -- `curl -d "single=post://XXLPitu-Server.local:8123/api/webhook/mystrom_button_blue" "http://myStrom-Button-E9DACB.local/api/v1/device/F4CFA2E9DACB"` -- `curl -d "single=post://XXLPitu-Server.local:8123/api/webhook/mystrom_button_gray" "http://myStrom-Button-E9DA8E.local/api/v1/device/F4CFA2E9DA8E"` -- `curl -d "single=post://XXLPitu-Server.local:8123/api/webhook/mystrom_button_orange" "http://myStrom-Button-E9DAD9.local/api/v1/device/F4CFA2E9DAD9"` -- `curl -d "single=post://XXLPitu-Server.local:8123/api/webhook/mystrom_button_purple" "http://myStrom-Button-E9D761.local/api/v1/device/F4CFA2E9D761"` -- `curl -d "single=post://XXLPitu-Server.local:8123/api/webhook/mystrom_button_white" "http://myStrom-Button-F8CB7A.local/api/v1/device/CC50E3F8CB7A"` - ## Shelly Configure: diff --git a/configuration/devices/headless/server/home-assistant/discord.nix b/configuration/devices/headless/server/home-assistant/discord.nix index ffd079fd..95c52842 100644 --- a/configuration/devices/headless/server/home-assistant/discord.nix +++ b/configuration/devices/headless/server/home-assistant/discord.nix @@ -42,11 +42,6 @@ "sensor.entrance_dimmer_switch_battery" "sensor.entrance_h_t_gen3_battery" "sensor.living_room_dimmer_switch_battery" - "sensor.mystrom_button_blue_battery" - "sensor.mystrom_button_gray_battery" - "sensor.mystrom_button_orange_battery" - "sensor.mystrom_button_purple_battery" - "sensor.mystrom_button_white_battery" "sensor.reduit_parasoll_battery" "sensor.valve_blue_battery" "sensor.valve_green_battery" diff --git a/configuration/devices/headless/server/home-assistant/lovelace.nix b/configuration/devices/headless/server/home-assistant/lovelace.nix index 434d75f5..4f6f64a6 100644 --- a/configuration/devices/headless/server/home-assistant/lovelace.nix +++ b/configuration/devices/headless/server/home-assistant/lovelace.nix @@ -396,12 +396,6 @@ in { title = "Battery"; bulk_rename = [ - # myStrom buttons - { from = " battery"; } - { - from = "myStrom button "; - } - # Netatmo valves { from = " Battery"; } { diff --git a/configuration/devices/headless/server/home-assistant/mystrom.nix b/configuration/devices/headless/server/home-assistant/mystrom.nix deleted file mode 100644 index 6dabd61c..00000000 --- a/configuration/devices/headless/server/home-assistant/mystrom.nix +++ /dev/null @@ -1,116 +0,0 @@ -{ pkgs, secrets, ... }: -let - apiUrl = "https://mystrom.ch/api"; - - getVoltageScript = id: - pkgs.writers.writePython3 "mystrom_get_voltage_${id}.py" { libraries = [ pkgs.python3Packages.requests ]; } '' - import json - - import requests - - response = requests.post('${apiUrl}/auth', params={ - 'email': '${secrets.mystrom.email}', - 'password': '${secrets.mystrom.password}' - }) - - response = requests.get( - url='${apiUrl}/devices', - headers={'Auth-Token': json.loads(response.content)['authToken']} - ) - - match = next(filter( - lambda device: device['id'] == '${id}', - json.loads(response.content)['devices'] - )) - - print(match['voltage']) - ''; - - createButtonBatterySensors = map (button: { - sensor = { - name = button.name; - scan_interval = 60 * 60; - command = getVoltageScript button.id; - value_template = let - maxVoltage = "4300"; - minVoltage = "3700"; - in "{{ (((value | float) * 1000 - ${minVoltage}) * 100 / (${maxVoltage} - ${minVoltage})) | round }}"; - unit_of_measurement = "%"; - device_class = "battery"; - state_class = "measurement"; - }; - }); -in { - services.home-assistant.config = { - command_line = createButtonBatterySensors [ - { - name = "myStrom button blue battery"; - id = "F4CFA2E9DACB"; - } - { - name = "myStrom button gray battery"; - id = "F4CFA2E9DA8E"; - } - { - name = "myStrom button orange battery"; - id = "F4CFA2E9DAD9"; - } - { - name = "myStrom button purple battery"; - id = "F4CFA2E9D761"; - } - { - name = "myStrom button white battery"; - id = "CC50E3F8CB7A"; - } - ]; - - automation = [ - { - alias = "Placeholder myStrom orange"; - trigger = [{ - platform = "webhook"; - webhook_id = "mystrom_button_orange"; - local_only = true; - }]; - action = [ ]; - } - { - alias = "Placeholder myStrom purple"; - trigger = [{ - platform = "webhook"; - webhook_id = "mystrom_button_purple"; - local_only = true; - }]; - action = [ ]; - } - { - alias = "Placeholder myStrom blue"; - trigger = [{ - platform = "webhook"; - webhook_id = "mystrom_button_blue"; - local_only = true; - }]; - action = [ ]; - } - { - alias = "Placeholder myStrom gray"; - trigger = [{ - platform = "webhook"; - webhook_id = "mystrom_button_gray"; - local_only = true; - }]; - action = [ ]; - } - { - alias = "Placeholder myStrom white"; - trigger = [{ - platform = "webhook"; - webhook_id = "mystrom_button_white"; - local_only = true; - }]; - action = [ ]; - } - ]; - }; -} diff --git a/secrets.nix b/secrets.nix index 752c525a..ed1506ed 100755 Binary files a/secrets.nix and b/secrets.nix differ