cantabile_edge 0.1.389
This commit is contained in:
1 parent
c71ddf37ca
commit
343331d234
9 files changed
+383
-25
No files matched your search
@@ -6,9 +6,47 @@ names the commit; the agent inside is the Edge Agent image of that commit.
|
||||
|
||||
## 0.1.x
|
||||
|
||||
- Your consent at installation, in the add-on's configuration: sharing
|
||||
energy data with Cantabile (needed: without it the add-on does not
|
||||
connect, and its page says why) and, separately, control. The same texts
|
||||
and version as a Cantabile Hub's setup; recorded with when and how it was
|
||||
given and sent to Cantabile. With it, reading and control are switched on
|
||||
per device on the Devices page.
|
||||
- Both of the add-on's pages (Devices, Building or community) are for Home
|
||||
Assistant's administrators only.
|
||||
- The add-on's page "Devices": Home Assistant's devices with the Cantabile
|
||||
device profile that fits each (specific profiles first, the generic
|
||||
thermostat otherwise), what Cantabile would read and could control, and
|
||||
**Use with Cantabile**: the device's mapping from its profile with reading
|
||||
and control off, its protection as the profile says (the owner lifts or
|
||||
sets it), heating or cooling for a thermostat that does both. The
|
||||
proposal leaves a used device to its profile. The device appears on
|
||||
Cantabile's dashboard and in the area "Cantabile" (without an area of its
|
||||
own). The page and "Building or community" are one app, linked from the
|
||||
dashboard; only Home Assistant's administrators can use them.
|
||||
- The add-on's page in German or English, as the browser asks (Home
|
||||
Assistant's own language is not changed).
|
||||
- A reinstall is recognised: the add-on sends hashed hardware ids with its
|
||||
enrolment (no serial leaves Home Assistant in clear). When Cantabile merges
|
||||
it into the home's earlier site, it keeps that site, and its page offers the
|
||||
earlier consents for the building's and the community's operator again,
|
||||
given only with your yes.
|
||||
|
||||
- One dashboard "Cantabile" with views (overview, energy, heating & cooling,
|
||||
devices, building) instead of one dashboard per subject; the add-on's
|
||||
page leaves the sidebar and is linked from the dashboard.
|
||||
- A mapping at the first start, proposed from Home Assistant's devices and
|
||||
Cantabile's device profiles, and the import of an earlier install's
|
||||
mapping from `/share/cantabile/mapping.yaml`; consent always off.
|
||||
|
||||
- First packaging as a Home Assistant add-on: the agent and its link to
|
||||
Cantabile, the MQTT broker from the Mosquitto add-on, Cantabile's area,
|
||||
device and dashboards in Home Assistant.
|
||||
- The add-on's page: "Building or community". A home in no building joins
|
||||
an energy community with a code or asks one nearby, after seeing its rules,
|
||||
and chooses whether its operator receives the home's data.
|
||||
- A community's rules on that page include the price of shared energy, its
|
||||
amounts and penalties where set, and the notice period.
|
||||
|
||||
---
|
||||
|
||||
|
||||
+105
-6
@@ -14,21 +14,120 @@ runs those devices through Home Assistant: heating, charging, the battery.
|
||||
in Home Assistant.
|
||||
- Your **claim code**, from the Cantabile card.
|
||||
|
||||
## Your consent
|
||||
|
||||
You give your consent when you install the add-on, in its **Configuration**
|
||||
tab (Settings → Add-ons → Cantabile Edge Agent → Configuration):
|
||||
|
||||
- **Share energy data with Cantabile** (needed): "Cantabile may receive the
|
||||
energy data of the devices chosen for it." Without it the add-on does not
|
||||
connect to Cantabile at all: nothing is enrolled, read for Cantabile or
|
||||
sent, and the add-on's page says so.
|
||||
- **Cantabile may control devices** (optional, separately): "Allow
|
||||
Cantabile to control the devices you choose (heating, charging, battery,
|
||||
shades) within the limits you set."
|
||||
|
||||
These are the same texts, in the same version, as on a Cantabile Hub's
|
||||
setup. The add-on records what you agreed to, the texts' version and when,
|
||||
"given at installation in the add-on's configuration", and tells Cantabile.
|
||||
Which devices Cantabile may read or control you choose device by device on
|
||||
the add-on's **Devices** page. You can take your consent back in the
|
||||
Configuration tab at any time (save and restart the add-on): from then on
|
||||
nothing more is collected or sent.
|
||||
|
||||
## Options
|
||||
|
||||
- **Mode:** `shadow` (default) reads and plans, controls nothing. `off` only
|
||||
keeps the connection. Advising and running devices are turned on from
|
||||
Cantabile, never here, and only with your consent.
|
||||
- **Claim code:** ties this home to your Cantabile account.
|
||||
- **Dashboards:** Cantabile's dashboards (Cantabile, Electricity, Solar &
|
||||
battery, Heating & cooling, Total energy), and Home Assistant's Energy
|
||||
dashboard while you have none of your own. Your own dashboards are never
|
||||
changed.
|
||||
- **Dashboards:** one dashboard, "Cantabile" in the sidebar, with a view for
|
||||
each part your home has: **Overview** (Cantabile's connection and mode,
|
||||
the plan and the price, power now from solar, grid, battery and home,
|
||||
energy today), **Energy** (over days and months), **Heating & cooling**,
|
||||
**Devices** (Cantabile's devices and their main values, with a link to
|
||||
their settings) and **Building** (joining a building). It also sets up
|
||||
Home Assistant's Energy dashboard while you have none of your own. Your
|
||||
own dashboards are never changed.
|
||||
|
||||
## Pages
|
||||
|
||||
The add-on's own pages are not in the sidebar: open them from Cantabile's
|
||||
dashboard ("Devices" under the status, "Building"), or from Settings →
|
||||
Add-ons → Cantabile Edge Agent → Open web UI. "Show in sidebar" on that page
|
||||
puts it there if you want it. Only an administrator of Home Assistant can
|
||||
use them.
|
||||
|
||||
- **Devices:** Home Assistant's devices that a Cantabile device profile
|
||||
knows, and what Cantabile would read from each and could control. See
|
||||
"Using a device with Cantabile" below.
|
||||
- **Building or community:** joining a building or an energy community.
|
||||
|
||||
## Your devices in Cantabile (the mapping)
|
||||
|
||||
At its first start the agent proposes which of Home Assistant's devices
|
||||
Cantabile uses (the mapping, `/data/mapping.yaml` in the add-on's folder):
|
||||
Cantabile's own devices first (their device profiles say what each value
|
||||
is), then devices Cantabile knows, then solar, grid, battery and room
|
||||
sensors by their names. New devices are added while the proposal is
|
||||
unchanged. The proposal only shows your home in Cantabile's dashboard;
|
||||
**nothing is read for Cantabile or sent** until you agree.
|
||||
|
||||
### Using a device with Cantabile
|
||||
|
||||
On the add-on's **Devices** page each device Home Assistant has and a
|
||||
Cantabile device profile knows is listed with what Cantabile would read
|
||||
from it (for example solar power, the battery's charge, a room's
|
||||
temperature) and what it could control (heating, cooling, charging, the
|
||||
battery). A thermostat that no specific profile knows gets the generic one
|
||||
(any device with a climate entity). **Use with Cantabile** confirms the
|
||||
device:
|
||||
|
||||
- Cantabile takes the device's values as its profile describes them,
|
||||
instead of the proposal's guesses, and keeps the proposal away from that
|
||||
device from then on. Stop using it on the same page and the proposal
|
||||
takes it back.
|
||||
- The device appears on Cantabile's dashboard, and in the area "Cantabile"
|
||||
if it has no area of its own (a thermostat in its room keeps its room).
|
||||
- Reading and control start **off**. Switch them on for the device on the
|
||||
same page ("Cantabile may read these values", "Cantabile may control
|
||||
it"): this needs your consent in the Configuration tab first (above;
|
||||
control needs its own). The agent starts again for a few seconds to
|
||||
apply it. The dashboard here shows the device either way: that stays in
|
||||
your home.
|
||||
- Controls that must not be switched off are **protected** as their
|
||||
profile says (a thermostat, an inverter's output): Cantabile never
|
||||
switches them off. You can lift or set protection on the page. A device
|
||||
**sealed** by its custodian (a grid or metering operator) is shown locked.
|
||||
- A thermostat that heats and cools: choose **heating**, **cooling**, **by
|
||||
season** (the default: heating October to April) or **by outdoor
|
||||
temperature**. Cantabile uses one at a time.
|
||||
|
||||
Nothing is installed or set up in Home Assistant here: the page uses the
|
||||
devices Home Assistant already has. Values your own mapping (written by
|
||||
hand) already reads stay there, and a control on an entity another control
|
||||
already writes is left out: one writer per device.
|
||||
|
||||
### Moving from an earlier install
|
||||
|
||||
A mapping an installer confirmed for an earlier install of Cantabile (for
|
||||
example the agent's container, `/root/cantabile-agent/mapping.yaml`) is
|
||||
taken over once:
|
||||
|
||||
1. Copy it to Home Assistant's share folder as `cantabile/mapping.yaml`
|
||||
(`/share/cantabile/mapping.yaml`, e.g. with the Samba or SSH add-on).
|
||||
2. Restart the add-on. Its log says "an earlier install's mapping … imports
|
||||
it once".
|
||||
|
||||
Its entries keep their names; consent is **not** taken over (you decide
|
||||
again). An entry whose sensor has no value here is replaced by the same
|
||||
value from Cantabile's own devices, and the file lists what changed. The
|
||||
copy in the share folder can stay; it is not taken again unless it changes.
|
||||
|
||||
## What it reads, and what leaves your home
|
||||
|
||||
- Nothing leaves until an installer has confirmed, with you, which devices
|
||||
Cantabile may read (the mapping) and you agreed to share data.
|
||||
- Nothing leaves until you agreed to share data (the Configuration tab) and
|
||||
switched reading on for the devices Cantabile may read (the Devices page).
|
||||
- At start the add-on reads Home Assistant's instance id once (in
|
||||
`/homeassistant/.storage`), as the identity of your home in Cantabile. Then
|
||||
it runs as its own user without any special rights; it never reads your
|
||||
|
||||
@@ -8,9 +8,13 @@ FROM ${EDGE_IMAGE}
|
||||
ARG VERSION ARCH REVISION
|
||||
LABEL io.hass.version="${VERSION}" io.hass.type="addon" io.hass.arch="${ARCH}" \
|
||||
org.opencontainers.image.revision="${REVISION}"
|
||||
# bundles.pem is optional (no bundle key: the agent plans with its flat price).
|
||||
COPY addon.env commands.pem bundles.pem* /etc/cantabile/
|
||||
# bundles.pem is optional (no bundle key: the agent plans with its flat price);
|
||||
# devices-ca.pem too (the direct path, docs/direct-link.md).
|
||||
COPY addon.env commands.pem bundles.pem* devices-ca.pem* /etc/cantabile/
|
||||
COPY addon-run /usr/local/bin/addon-run
|
||||
# Cantabile's device profiles (hub/profiles, copied in by build.sh): the
|
||||
# agent proposes a mapping from them (propose.py).
|
||||
COPY profiles/ /usr/share/cantabile/profiles/
|
||||
# addon-run starts as root (it reads Home Assistant's instance id) and runs
|
||||
# the agent as uid 10001.
|
||||
USER root
|
||||
|
||||
+182
-5
@@ -4,25 +4,47 @@
|
||||
|
||||
- Home Assistant's instance id: .storage/core.uuid is root-only; a copy in
|
||||
/data for the link (the site id comes from it, as on the Hub and THR-Home).
|
||||
- The add-on's options (/data/options.json): mode, claim code, dashboards.
|
||||
- The add-on's options (/data/options.json): the owner's consent, mode,
|
||||
claim code, dashboards.
|
||||
- Consent (HANDOVER 0, the owner's decision of 2026-10-30): given when the
|
||||
add-on is installed from Cantabile's repository, in its configuration:
|
||||
sharing the energy data of the devices chosen for Cantabile (needed: until
|
||||
it is given the add-on does not enrol or connect, and its page says why)
|
||||
and, separately, control. The same texts and version as the Hub's setup
|
||||
wizard and panel; recorded in the agent's consent file
|
||||
(/data/state/consent.json: share, control, when, the texts' version, the
|
||||
source), which the link sends to Cantabile with its heartbeat. Taken
|
||||
back in the configuration: nothing more is collected or sent.
|
||||
- The hardware fingerprint (hashed ids: the DMI ones are root-only): written
|
||||
once per start for the link, which recognises a reinstall with it.
|
||||
- MQTT: the broker the Supervisor offers (the Mosquitto add-on), with the
|
||||
login it made for this add-on; without one, no discovery in HA.
|
||||
- First start: config.yaml and an empty mapping, as the Hub's edge-prepare
|
||||
(nothing is sent until an installer confirms the mapping).
|
||||
- First start: config.yaml and an empty mapping, as the Hub's edge-prepare;
|
||||
the agent then proposes one from Home Assistant's devices (propose.py),
|
||||
consent off: nothing is read for Cantabile until the owner agrees.
|
||||
- An earlier install's mapping (/share/cantabile/mapping.yaml, the owner or
|
||||
support puts it there): copied to /data/mapping-import.yaml for the agent,
|
||||
which imports it once per content, consent off.
|
||||
Then the link and the agent (cantabile-run) as uid 10001, without root's
|
||||
capabilities: /homeassistant stays mapped, but only what is readable for
|
||||
everyone is readable for them.
|
||||
ADDON_DATA, ADDON_HA_CONFIG, ADDON_ETC, SUPERVISOR_URL and ADDON_DRY_RUN=1
|
||||
(print the environment instead of starting) are for tests.
|
||||
"""
|
||||
import html
|
||||
import json
|
||||
import os
|
||||
import pwd
|
||||
import re
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import urllib.request
|
||||
|
||||
DATA = os.environ.get("ADDON_DATA", "/data")
|
||||
HA_CONFIG = os.environ.get("ADDON_HA_CONFIG", "/homeassistant")
|
||||
SHARE = os.environ.get("ADDON_SHARE", "/share")
|
||||
ETC = os.environ.get("ADDON_ETC", "/etc/cantabile")
|
||||
SUPERVISOR = os.environ.get("SUPERVISOR_URL", "http://supervisor")
|
||||
DRY = os.environ.get("ADDON_DRY_RUN") == "1"
|
||||
@@ -35,10 +57,32 @@ state_dir: /data/state
|
||||
sink: {kind: link, path: /run/cantabile/link.sock}
|
||||
"""
|
||||
MAPPING = """# Which HA entities Cantabile may read (edge/cantabile_edge/mapping.py).
|
||||
# None yet: an installer confirms the mapping.
|
||||
# None yet: the agent proposes them from Home Assistant's devices, or imports
|
||||
# an earlier install's mapping (/share/cantabile/mapping.yaml), consent off.
|
||||
version: 1
|
||||
assets: []
|
||||
"""
|
||||
IMPORT = "cantabile/mapping.yaml"
|
||||
INGRESS_PORT = 8099
|
||||
RESTART = 75
|
||||
# The consent's texts: the Hub's (hub/.../cantabile/web CONSENT_TEXT,
|
||||
# CONTROL_TEXT and CONSENT_VERSION), working texts until the legal team's.
|
||||
CONSENT_TEXT = "Cantabile may receive the energy data of the devices chosen for it."
|
||||
CONTROL_TEXT = ("Allow Cantabile to control the devices you choose (heating, charging, battery, shades) "
|
||||
"within the limits you set.")
|
||||
CONSENT_VERSION = "working-2026-10-29"
|
||||
CONSENT_SOURCE = "given at installation in the add-on's configuration"
|
||||
WAITING = {
|
||||
"en": ("Cantabile is not connected",
|
||||
"Cantabile connects only with your consent. In the add-on's Configuration (Settings, Apps or Add-ons, "
|
||||
"Cantabile Edge Agent), turn on \"Share energy data with Cantabile\" (and, if you want, \"Cantabile may "
|
||||
"control devices\"), save and restart the add-on.", "Open the configuration"),
|
||||
"de": ("Cantabile ist nicht verbunden",
|
||||
"Cantabile verbindet sich nur mit Ihrer Einwilligung. Schalten Sie in der Konfiguration des Add-ons "
|
||||
"(Einstellungen, Apps bzw. Add-ons, Cantabile Edge Agent) „Energiedaten mit Cantabile teilen“ ein (und, "
|
||||
"wenn Sie möchten, „Cantabile darf Geräte steuern“), speichern Sie und starten Sie das Add-on neu.",
|
||||
"Konfiguration öffnen"),
|
||||
}
|
||||
|
||||
|
||||
def log(msg):
|
||||
@@ -76,6 +120,88 @@ def chown_tree(path, own):
|
||||
os.chown(path, *own)
|
||||
|
||||
|
||||
def consent(opts, own, now=None):
|
||||
"""The owner's consent from the configuration into the agent's consent
|
||||
file; True when sharing is given. Kept as it was (and when it was given)
|
||||
while unchanged; the operators' consents (the add-on's page) stay."""
|
||||
path = f"{DATA}/state/consent.json"
|
||||
try:
|
||||
with open(path) as f:
|
||||
d = json.load(f)
|
||||
d = d if isinstance(d, dict) else {}
|
||||
except (OSError, ValueError):
|
||||
d = {}
|
||||
share = opts.get("consent_data") is True
|
||||
control = share and opts.get("consent_control") is True
|
||||
if (d.get("share"), d.get("control"), d.get("text_version"), d.get("by")) != \
|
||||
(share, control, CONSENT_VERSION, "ha-addon-config") or not os.path.exists(path):
|
||||
d.update(share=share, control=control, at=int(now or time.time()), by="ha-addon-config",
|
||||
source=CONSENT_SOURCE, text_version=CONSENT_VERSION,
|
||||
texts={"share": CONSENT_TEXT, "control": CONTROL_TEXT})
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
put(path, json.dumps(d, ensure_ascii=False), 0o600, own)
|
||||
log(f"consent from the configuration: sharing {'given' if share else 'not given'}, "
|
||||
f"control {'given' if control else 'not given'} (texts {CONSENT_VERSION})")
|
||||
return share
|
||||
|
||||
|
||||
def own_slug():
|
||||
"""This add-on's slug from the Supervisor (for the link to its
|
||||
configuration); "" when it can't be asked."""
|
||||
token = os.environ.get("SUPERVISOR_TOKEN", "")
|
||||
req = urllib.request.Request(f"{SUPERVISOR}/addons/self/info", headers={"Authorization": f"Bearer {token}"})
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=10) as r:
|
||||
return str((json.load(r).get("data") or {}).get("slug") or "")
|
||||
except (OSError, ValueError):
|
||||
return ""
|
||||
|
||||
|
||||
def waiting_html(accept_language, slug=""):
|
||||
"""The page while there is no consent, in German or English, in HA's
|
||||
light or dark look, with a button to the add-on's configuration."""
|
||||
lang = "de" if (accept_language or "").strip().lower().startswith("de") else "en"
|
||||
title, text, button = WAITING[lang]
|
||||
link = (f'<p><a class="b" target="_top" href="/hassio/addon/{html.escape(slug)}/config">{html.escape(button)}</a></p>'
|
||||
if re.fullmatch(r"[a-z0-9_]+", slug or "") else "")
|
||||
return (f'<!doctype html><html lang="{lang}"><head><meta charset="utf-8"><meta name="viewport" '
|
||||
f'content="width=device-width,initial-scale=1"><title>{html.escape(title)}</title><style>'
|
||||
"body{font-family:system-ui,sans-serif;margin:16px;max-width:46rem;background:#fff;color:#1c1c1c}"
|
||||
"a.b{display:inline-block;padding:.6rem 1rem;border-radius:8px;background:#03a9f4;color:#fff;"
|
||||
"text-decoration:none}"
|
||||
"@media (prefers-color-scheme:dark){body{background:#111;color:#e1e1e1}}</style></head><body>"
|
||||
f"<h2>{html.escape(title)}</h2><p>{html.escape(text)}</p>{link}</body></html>")
|
||||
|
||||
|
||||
def waiting_page(own):
|
||||
"""No consent: the add-on's page (HA's ingress) says why Cantabile is not
|
||||
connected and where to give it; nothing is enrolled or sent."""
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
slug = own_slug()
|
||||
|
||||
class Page(BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
body = waiting_html(self.headers.get("Accept-Language"), slug).encode()
|
||||
ok = self.client_address[0] in ("172.30.32.2", "127.0.0.1", "::1")
|
||||
self.send_response(200 if ok else 403)
|
||||
self.send_header("Content-Type", "text/html; charset=utf-8" if ok else "text/plain")
|
||||
self.send_header("Cache-Control", "no-store")
|
||||
self.end_headers()
|
||||
self.wfile.write(body if ok else b"Open this page from Home Assistant.")
|
||||
|
||||
do_POST = do_GET
|
||||
|
||||
def log_message(self, *a):
|
||||
pass
|
||||
|
||||
server = HTTPServer(("0.0.0.0", INGRESS_PORT), Page)
|
||||
if own:
|
||||
os.setgroups([])
|
||||
os.setgid(own[1])
|
||||
os.setuid(own[0])
|
||||
server.serve_forever()
|
||||
|
||||
|
||||
def mqtt(env, own):
|
||||
token = os.environ.get("SUPERVISOR_TOKEN", "")
|
||||
req = urllib.request.Request(f"{SUPERVISOR}/services/mqtt", headers={"Authorization": f"Bearer {token}"})
|
||||
@@ -97,6 +223,21 @@ def mqtt(env, own):
|
||||
log(f"MQTT broker {d['host']}:{env['CANTABILE_MQTT_PORT']}")
|
||||
|
||||
|
||||
def fingerprint(env, own):
|
||||
"""The box's hardware ids, hashed by the link itself (`cantabile-link
|
||||
fingerprint`, as root); no raw serial is written."""
|
||||
if DRY:
|
||||
return
|
||||
try:
|
||||
out = subprocess.run(["cantabile-link", "fingerprint"], capture_output=True, text=True, timeout=30).stdout
|
||||
json.loads(out)
|
||||
except (OSError, ValueError, subprocess.TimeoutExpired) as e:
|
||||
log(f"no hardware fingerprint: {e}")
|
||||
return
|
||||
put(f"{DATA}/fingerprint.json", out, own=own)
|
||||
env["CANTABILE_FINGERPRINT_FILE"] = f"{DATA}/fingerprint.json"
|
||||
|
||||
|
||||
def main():
|
||||
own = owner()
|
||||
with open(f"{DATA}/options.json") as f:
|
||||
@@ -111,11 +252,24 @@ def main():
|
||||
env["CANTABILE_COMMAND_CERT"] = f"{ETC}/commands.pem"
|
||||
if os.path.exists(f"{ETC}/bundles.pem"):
|
||||
env["CANTABILE_BUNDLE_CERT"] = f"{ETC}/bundles.pem"
|
||||
if os.path.exists(f"{ETC}/devices-ca.pem"): # the direct path's CA (docs/direct-link.md)
|
||||
env["CANTABILE_DEVICES_CA"] = f"{ETC}/devices-ca.pem"
|
||||
|
||||
with open(f"{HA_CONFIG}/.storage/core.uuid") as f:
|
||||
put(f"{DATA}/ha-core.uuid", f.read(), own=own)
|
||||
env["CANTABILE_HA_UUID_FILE"] = f"{DATA}/ha-core.uuid"
|
||||
|
||||
if not consent(opts, own):
|
||||
log("no consent to share energy data (the add-on's configuration): not connecting to Cantabile. "
|
||||
"Turn on \"Share energy data with Cantabile\" in the Configuration tab and restart the add-on.")
|
||||
if DRY:
|
||||
print(json.dumps({"consent": False}))
|
||||
return
|
||||
waiting_page(own)
|
||||
return
|
||||
|
||||
fingerprint(env, own)
|
||||
|
||||
code = (opts.get("claim_code") or "").strip()
|
||||
if code:
|
||||
put(f"{DATA}/claim-code", code + "\n", own=own)
|
||||
@@ -125,6 +279,15 @@ def main():
|
||||
|
||||
put(f"{DATA}/config.yaml", CONFIG, 0o644, own, keep=True)
|
||||
put(f"{DATA}/mapping.yaml", MAPPING, 0o644, own, keep=True)
|
||||
env["CANTABILE_PROPOSE"] = "1"
|
||||
try:
|
||||
with open(f"{SHARE}/{IMPORT}") as f:
|
||||
put(f"{DATA}/mapping-import.yaml", f.read(), 0o600, own)
|
||||
log(f"an earlier install's mapping in /share/{IMPORT}: the agent imports it once, consent off")
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
except (OSError, UnicodeDecodeError) as e:
|
||||
log(f"/share/{IMPORT} not read: {e}")
|
||||
os.makedirs(f"{DATA}/state", exist_ok=True)
|
||||
if own:
|
||||
chown_tree(DATA, own)
|
||||
@@ -137,7 +300,21 @@ def main():
|
||||
# Drop to the agent's user and every capability; no way back.
|
||||
cmd = ["setpriv", f"--reuid={own[0]}", f"--regid={own[1]}", "--init-groups",
|
||||
"--inh-caps=-all", "--bounding-set=-all", "--no-new-privs"] + cmd
|
||||
os.execvpe(cmd[0], cmd, env)
|
||||
# 75: the agent asks to start again (a device's consent or controls
|
||||
# changed on its page, as the Hub's devices tool restarts it)
|
||||
child = None
|
||||
|
||||
def forward(sig, _frame):
|
||||
if child is not None:
|
||||
child.send_signal(sig)
|
||||
for sig in (signal.SIGTERM, signal.SIGINT):
|
||||
signal.signal(sig, forward)
|
||||
while True:
|
||||
child = subprocess.Popen(cmd, env=env)
|
||||
rc = child.wait()
|
||||
if rc != RESTART:
|
||||
sys.exit(rc)
|
||||
log("the agent starts again")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# the Hub's, wrapped by addon-run (Dockerfile). ha-addon/build.sh sets
|
||||
# version and arch for each build; the image is prebuilt, per arch.
|
||||
name: Cantabile Edge Agent
|
||||
version: "0.1.307"
|
||||
version: "0.1.389"
|
||||
slug: cantabile_edge
|
||||
description: Plans your home's energy with Cantabile and, with your consent, runs the devices you choose.
|
||||
url: https://cantabile.cloud
|
||||
@@ -18,23 +18,38 @@ homeassistant_api: true
|
||||
hassio_api: true
|
||||
services:
|
||||
- mqtt:want
|
||||
# The Building page (joining a building from home): only through HA's
|
||||
# ingress, in the sidebar for administrators.
|
||||
# The add-on's pages (Devices; Building or community): only through HA's
|
||||
# ingress. Not in the sidebar: the Supervisor's per-install "Show in
|
||||
# sidebar" (ingress_panel) is off unless the owner turns it on; Cantabile's
|
||||
# dashboard links the pages (/app/<slug>#devices, #building). panel_* only
|
||||
# name it if they do; panel_admin hides that entry from other users, and
|
||||
# the pages check themselves that the user is an administrator.
|
||||
ingress: true
|
||||
ingress_port: 8099
|
||||
panel_icon: mdi:office-building
|
||||
panel_icon: mdi:leaf
|
||||
panel_title: Cantabile
|
||||
panel_admin: true
|
||||
# Read once at start, as root, for the site id: .storage/core.uuid (root
|
||||
# only); the agent then runs as its own user (addon-run).
|
||||
# homeassistant_config: read once at start, as root, for the site id
|
||||
# (.storage/core.uuid, root only); the agent then runs as its own user
|
||||
# (addon-run). share: an earlier install's mapping to import, once
|
||||
# (/share/cantabile/mapping.yaml, DOCS.md "Moving from an earlier install").
|
||||
map:
|
||||
- type: homeassistant_config
|
||||
read_only: true
|
||||
- type: share
|
||||
read_only: true
|
||||
# consent_data: the owner's consent, given here when installing (needed: the
|
||||
# add-on connects to Cantabile only with it); consent_control: control,
|
||||
# separately (the Hub's wizard has the same two; DOCS.md "Your consent").
|
||||
options:
|
||||
consent_data: false
|
||||
consent_control: false
|
||||
mode: shadow
|
||||
claim_code: ""
|
||||
dashboards: true
|
||||
schema:
|
||||
consent_data: bool
|
||||
consent_control: bool
|
||||
mode: list(off|shadow)
|
||||
claim_code: password?
|
||||
dashboards: bool
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 12 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 15 KiB |
@@ -1,17 +1,30 @@
|
||||
# Copyright © 2026 Setti Solutions S.R.L, www.setti.md. All rights reserved.
|
||||
configuration:
|
||||
consent_data:
|
||||
name: Energiedaten mit Cantabile teilen
|
||||
description: >-
|
||||
Ihre Einwilligung: Cantabile darf die Energiedaten der dafür
|
||||
ausgewählten Geräte erhalten. Erforderlich: Ohne sie verbindet sich das
|
||||
Add-on nicht mit Cantabile. Sie können sie hier jederzeit widerrufen.
|
||||
consent_control:
|
||||
name: Cantabile darf Geräte steuern
|
||||
description: >-
|
||||
Ihre Einwilligung: Cantabile darf die von Ihnen gewählten Geräte
|
||||
(Heizung, Laden, Batterie, Beschattung) innerhalb der von Ihnen
|
||||
gesetzten Grenzen steuern. Welche Geräte: auf der Seite „Geräte“ des
|
||||
Add-ons.
|
||||
mode:
|
||||
name: Modus
|
||||
description: >-
|
||||
shadow: Der Agent liest Ihre Geräte und plant, steuert aber nichts.
|
||||
off: Er hält nur die Verbindung zu Cantabile. Empfehlen und Steuern
|
||||
werden in Cantabile eingeschaltet, mit Ihrer Zustimmung.
|
||||
werden in Cantabile eingeschaltet, mit Ihrer Einwilligung.
|
||||
claim_code:
|
||||
name: Aktivierungscode
|
||||
description: Der Code auf Ihrer Cantabile-Karte (XXXX-XXXX-XXXX). Er verbindet dieses Zuhause mit Ihrem Cantabile-Konto.
|
||||
dashboards:
|
||||
name: Dashboards
|
||||
description: >-
|
||||
Die Dashboards von Cantabile in Home Assistant (Cantabile, Strom,
|
||||
Solar & Batterie, Heizen & Kühlen, Energie gesamt) und das
|
||||
Das Dashboard von Cantabile in Home Assistant (ein Eintrag in der
|
||||
Seitenleiste: Übersicht, Energie, Geräte, Gebäude) und das
|
||||
Energie-Dashboard, solange Sie kein eigenes haben.
|
||||
@@ -1,5 +1,17 @@
|
||||
# Copyright © 2026 Setti Solutions S.R.L, www.setti.md. All rights reserved.
|
||||
configuration:
|
||||
consent_data:
|
||||
name: Share energy data with Cantabile
|
||||
description: >-
|
||||
Your consent: Cantabile may receive the energy data of the devices
|
||||
chosen for it. Needed: without it the add-on does not connect to
|
||||
Cantabile. You can take it back here at any time.
|
||||
consent_control:
|
||||
name: Cantabile may control devices
|
||||
description: >-
|
||||
Your consent: allow Cantabile to control the devices you choose
|
||||
(heating, charging, battery, shades) within the limits you set. Which
|
||||
devices: on the add-on's Devices page.
|
||||
mode:
|
||||
name: Mode
|
||||
description: >-
|
||||
@@ -12,6 +24,6 @@ configuration:
|
||||
dashboards:
|
||||
name: Dashboards
|
||||
description: >-
|
||||
Cantabile's dashboards in Home Assistant (Cantabile, Electricity, Solar
|
||||
& battery, Heating & cooling, Total energy), and the Energy dashboard
|
||||
while you have none of your own.
|
||||
Cantabile's dashboard in Home Assistant (one sidebar entry: overview,
|
||||
energy, devices, building), and the Energy dashboard while you have
|
||||
none of your own.
|
||||
Reference in new issue
Block a user