Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
adrblo committed Jul 19, 2024
0 parents commit c776f64
Show file tree
Hide file tree
Showing 8 changed files with 727 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__pycache__/
venv/
state.json
.env
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Thymis Modules

This repository contains thymis modules.
7 changes: 7 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
description = "";
inputs = {
};
outputs = { self }: {
};
}
630 changes: 630 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[tool.poetry]
name = "thymis_modules"
version = "0.1.0"
description = ""
authors = ["Adrian Block <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.11"
thymis-controller = { git = "https://github.com/thymis-io/thymis.git", subdirectory = "controller" }

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Empty file added thymis_modules/__init__.py
Empty file.
Binary file added thymis_modules/assets/home-assistant.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 69 additions & 0 deletions thymis_modules/modules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import thymis_controller
import thymis_controller.lib
import pathlib

from thymis_controller.models import Setting, ModuleSettings
from thymis_controller.modules import Module


class HomeAssistant(Module):
displayName: str = "Home Assistant"
icon: str = thymis_controller.lib.read_into_base64(
pathlib.Path(__file__).parent / "assets" / "home-assistant.png"
)


timezone = Setting(
name="homeassistant.timezone",
type="string",
default="Europe/Berlin",
description="The timezone for Home Assistant.",
example="Europe/Berlin",
)

def write_nix_settings(
self, f, module_settings: thymis_controller.models.ModuleSettings, priority: int
):
timezone = (
module_settings.settings["timezone"]
if "timezone" in module_settings.settings
else self.timezone.default
)
f.write(
f"""
services.home-assistant.enable = true;
services.home-assistant.openFirewall = true;
services.home-assistant.config.homeassistant.time_zone = "{timezone}";
"""
)

class HomeAssistant(Module):
displayName: str = "Home Assistant"
icon: str = thymis_controller.lib.read_into_base64(
pathlib.Path(__file__).parent / "assets" / "home-assistant.png"
)


timezone = Setting(
name="homeassistant.timezone",
type="string",
default="Europe/Berlin",
description="The timezone for Home Assistant.",
example="Europe/Berlin",
)

def write_nix_settings(
self, f, module_settings: thymis_controller.models.ModuleSettings, priority: int
):
timezone = (
module_settings.settings["timezone"]
if "timezone" in module_settings.settings
else self.timezone.default
)
f.write(
f"""
services.home-assistant.enable = true;
services.home-assistant.openFirewall = true;
services.home-assistant.config.homeassistant.time_zone = "{timezone}";
"""
)

0 comments on commit c776f64

Please sign in to comment.