Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bc8bec6aa9 | |||
| 058c5dd015 |
@@ -105,6 +105,7 @@ _CONTEXT_DOMAINS = frozenset({
|
|||||||
"input_datetime",
|
"input_datetime",
|
||||||
"input_number",
|
"input_number",
|
||||||
"input_select",
|
"input_select",
|
||||||
|
"input_text",
|
||||||
"person",
|
"person",
|
||||||
"sun",
|
"sun",
|
||||||
"weather",
|
"weather",
|
||||||
@@ -122,6 +123,29 @@ _NUMERIC_STATE_CLASSES = frozenset({"measurement", "total", "total_increasing"})
|
|||||||
|
|
||||||
|
|
||||||
def classify_entity(entity: HaEntitySummary) -> DiscoveredEntity:
|
def classify_entity(entity: HaEntitySummary) -> DiscoveredEntity:
|
||||||
|
if entity.domain in _ACTUATOR_DOMAINS:
|
||||||
|
return _result(
|
||||||
|
entity,
|
||||||
|
EntityRole.ACTUATOR,
|
||||||
|
category=_actuator_category(entity),
|
||||||
|
learnable=False,
|
||||||
|
reason="Aktor ist ein mögliches Automationsziel, aber kein Trainingssensor.",
|
||||||
|
)
|
||||||
|
|
||||||
|
if entity.domain in _CONTEXT_DOMAINS:
|
||||||
|
learnable = entity.domain in _LEARNABLE_CONTEXT_DOMAINS
|
||||||
|
return _result(
|
||||||
|
entity,
|
||||||
|
EntityRole.CONTEXT,
|
||||||
|
category=_context_category(entity),
|
||||||
|
learnable=learnable,
|
||||||
|
reason=(
|
||||||
|
"Kontextquelle für Training und Erklärungen."
|
||||||
|
if learnable
|
||||||
|
else "Kontextquelle ohne direkte Trainingsfreigabe."
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
if entity.domain == "sensor" and (
|
if entity.domain == "sensor" and (
|
||||||
entity.state_class in _NUMERIC_STATE_CLASSES
|
entity.state_class in _NUMERIC_STATE_CLASSES
|
||||||
or entity.device_class in _MEASUREMENT_CLASSES
|
or entity.device_class in _MEASUREMENT_CLASSES
|
||||||
@@ -144,29 +168,6 @@ def classify_entity(entity: HaEntitySummary) -> DiscoveredEntity:
|
|||||||
reason="Binärer Kontextsensor für Zustands- und Anwesenheitsmuster.",
|
reason="Binärer Kontextsensor für Zustands- und Anwesenheitsmuster.",
|
||||||
)
|
)
|
||||||
|
|
||||||
if entity.domain in _CONTEXT_DOMAINS:
|
|
||||||
learnable = entity.domain in _LEARNABLE_CONTEXT_DOMAINS
|
|
||||||
return _result(
|
|
||||||
entity,
|
|
||||||
EntityRole.CONTEXT,
|
|
||||||
category=_context_category(entity),
|
|
||||||
learnable=learnable,
|
|
||||||
reason=(
|
|
||||||
"Kontextquelle für Training und Erklärungen."
|
|
||||||
if learnable
|
|
||||||
else "Kontextquelle ohne direkte Trainingsfreigabe."
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
if entity.domain in _ACTUATOR_DOMAINS:
|
|
||||||
return _result(
|
|
||||||
entity,
|
|
||||||
EntityRole.ACTUATOR,
|
|
||||||
category=_actuator_category(entity),
|
|
||||||
learnable=False,
|
|
||||||
reason="Aktor ist ein mögliches Automationsziel, aber kein Trainingssensor.",
|
|
||||||
)
|
|
||||||
|
|
||||||
return _result(
|
return _result(
|
||||||
entity,
|
entity,
|
||||||
EntityRole.UNSUPPORTED,
|
EntityRole.UNSUPPORTED,
|
||||||
@@ -226,26 +227,33 @@ def _actuator_category(entity: HaEntitySummary) -> str:
|
|||||||
if entity.domain == "lock":
|
if entity.domain == "lock":
|
||||||
return "lock"
|
return "lock"
|
||||||
if entity.domain == "fan":
|
if entity.domain == "fan":
|
||||||
return "fan"
|
return "ventilation"
|
||||||
|
if entity.domain == "humidifier":
|
||||||
|
return "climate"
|
||||||
if entity.domain in {"media_player", "remote"}:
|
if entity.domain in {"media_player", "remote"}:
|
||||||
return "media_tv"
|
return "media_tv"
|
||||||
if entity.domain in {"input_boolean", "number"}:
|
if entity.domain == "input_boolean" or entity.domain == "number" or entity.domain == "input_button":
|
||||||
return "helper"
|
return "helper"
|
||||||
|
if entity.domain == "sensor" and (entity.device_class or entity.unit_of_measurement):
|
||||||
|
return "measurement"
|
||||||
return entity.domain
|
return entity.domain
|
||||||
|
|
||||||
|
|
||||||
def _measurement_category(entity: HaEntitySummary) -> str:
|
def _measurement_category(entity: HaEntitySummary) -> str:
|
||||||
device_class = entity.device_class or ""
|
device_class = entity.device_class or ""
|
||||||
if device_class == "illuminance":
|
unit = (entity.unit_of_measurement or "").lower()
|
||||||
|
if device_class == "illuminance" or unit == "lx":
|
||||||
return "brightness"
|
return "brightness"
|
||||||
if device_class == "temperature":
|
if device_class == "temperature" or unit in {"°c", "°f", "k"}:
|
||||||
return "temperature"
|
return "temperature"
|
||||||
if device_class in {"humidity", "moisture"}:
|
if device_class in {"humidity", "moisture"} or unit in {"%", "rh", "g/m³", "kg/m³"}:
|
||||||
return "humidity"
|
return "humidity"
|
||||||
if device_class in {"power", "energy", "current", "voltage"}:
|
if device_class in {"power", "energy", "current", "voltage"} or unit in {"w", "kw", "kwh", "a", "v", "va", "var"}:
|
||||||
return "energy_power"
|
return "energy_power"
|
||||||
if device_class in {"battery", "signal_strength"}:
|
if device_class in {"battery", "signal_strength"} or unit in {"%", "dbm"}:
|
||||||
return "diagnostic"
|
return "diagnostic"
|
||||||
|
if unit:
|
||||||
|
return f"measurement:{unit}"
|
||||||
return "measurement"
|
return "measurement"
|
||||||
|
|
||||||
|
|
||||||
@@ -253,7 +261,7 @@ def _binary_category(entity: HaEntitySummary) -> str:
|
|||||||
device_class = entity.device_class or ""
|
device_class = entity.device_class or ""
|
||||||
if device_class in {"motion", "occupancy", "presence"}:
|
if device_class in {"motion", "occupancy", "presence"}:
|
||||||
return "presence_motion"
|
return "presence_motion"
|
||||||
if device_class in {"door", "garage_door", "opening", "window"}:
|
if device_class in {"door", "garage_door", "opening", "window", "button"}:
|
||||||
return "opening"
|
return "opening"
|
||||||
if device_class in {"smoke", "safety", "problem"}:
|
if device_class in {"smoke", "safety", "problem"}:
|
||||||
return "safety"
|
return "safety"
|
||||||
@@ -265,4 +273,8 @@ def _context_category(entity: HaEntitySummary) -> str:
|
|||||||
return "helper"
|
return "helper"
|
||||||
if entity.domain in {"person", "device_tracker", "zone"}:
|
if entity.domain in {"person", "device_tracker", "zone"}:
|
||||||
return "presence_location"
|
return "presence_location"
|
||||||
|
if entity.domain == "sun":
|
||||||
|
return "weather"
|
||||||
|
if entity.domain == "weather":
|
||||||
|
return "weather"
|
||||||
return entity.domain
|
return entity.domain
|
||||||
|
|||||||
@@ -285,14 +285,15 @@ function optionGroups(entities, selectedIds = new Set()) {
|
|||||||
async function loadOverview() {
|
async function loadOverview() {
|
||||||
const status = document.getElementById("status");
|
const status = document.getElementById("status");
|
||||||
const chips = document.getElementById("status-chips");
|
const chips = document.getElementById("status-chips");
|
||||||
|
let reconciliation = null;
|
||||||
try {
|
try {
|
||||||
const [health, websocket, ml, reconciliation, actuators] = await Promise.all([
|
const [health, websocket, ml] = await Promise.all([
|
||||||
api("health"),
|
api("health"),
|
||||||
api("health/websocket"),
|
api("health/websocket"),
|
||||||
api("ml/health"),
|
api("ml/health"),
|
||||||
api("v1/actuators/reconciliation/state"),
|
|
||||||
api("v1/actuators"),
|
|
||||||
]);
|
]);
|
||||||
|
reconciliation = await api("v1/actuators/reconciliation/state");
|
||||||
|
const actuators = await api("v1/actuators");
|
||||||
status.innerHTML = `<p class="ok">System bereit</p><p>Letzte automatische Prüfung: ${escapeHtml(reconciliation.last_completed_at || "noch nie")}</p>`;
|
status.innerHTML = `<p class="ok">System bereit</p><p>Letzte automatische Prüfung: ${escapeHtml(reconciliation.last_completed_at || "noch nie")}</p>`;
|
||||||
chips.innerHTML = [
|
chips.innerHTML = [
|
||||||
`<span class="chip">API: ${escapeHtml(health.status)}</span>`,
|
`<span class="chip">API: ${escapeHtml(health.status)}</span>`,
|
||||||
@@ -313,12 +314,8 @@ async function loadActuatorDiscovery() {
|
|||||||
const options = document.getElementById("actuator-options");
|
const options = document.getElementById("actuator-options");
|
||||||
const select = document.getElementById("actuator-select");
|
const select = document.getElementById("actuator-select");
|
||||||
try {
|
try {
|
||||||
const [available, configured] = await Promise.all([
|
const available = await api("v1/actuators/discovery");
|
||||||
api("v1/actuators/discovery"),
|
actuatorChoices = available;
|
||||||
api("v1/actuators"),
|
|
||||||
]);
|
|
||||||
const configuredIds = new Set(configured.map(record => record.actuator_entity_id));
|
|
||||||
actuatorChoices = available.filter(entity => !configuredIds.has(entity.entity_id));
|
|
||||||
options.innerHTML = actuatorChoices.slice(0, 120).map(entity =>
|
options.innerHTML = actuatorChoices.slice(0, 120).map(entity =>
|
||||||
`<option value="${escapeHtml(entity.entity_id)}">${escapeHtml(entity.friendly_name || entity.entity_id)}${entity.area_name ? ` (${escapeHtml(entity.area_name)})` : ""}</option>`
|
`<option value="${escapeHtml(entity.entity_id)}">${escapeHtml(entity.friendly_name || entity.entity_id)}${entity.area_name ? ` (${escapeHtml(entity.area_name)})` : ""}</option>`
|
||||||
).join("");
|
).join("");
|
||||||
@@ -357,20 +354,17 @@ async function loadActuatorSuggestions() {
|
|||||||
|
|
||||||
function actuatorGroupLabel(domain) {
|
function actuatorGroupLabel(domain) {
|
||||||
const labels = {
|
const labels = {
|
||||||
button: "Buttons",
|
|
||||||
climate: "Heizungen / Klima",
|
|
||||||
light: "Lichter",
|
light: "Lichter",
|
||||||
input_boolean: "Helper-Schalter",
|
switch_socket: "Steckdosen / Schalter",
|
||||||
input_button: "Helper-Buttons",
|
button: "Buttons",
|
||||||
|
cover_shutter: "Rollläden / Fenster",
|
||||||
|
heating: "Heizungen / Klima",
|
||||||
|
ventilation: "Lüftung / Ventilatoren",
|
||||||
|
climate: "Klima",
|
||||||
|
helper: "Helper",
|
||||||
|
measurement: "Sensoren / Messung",
|
||||||
lock: "Schlösser",
|
lock: "Schlösser",
|
||||||
media_player: "TV / Medien",
|
media_tv: "TV / Medien",
|
||||||
number: "Numerische Helper",
|
|
||||||
remote: "Fernbedienungen",
|
|
||||||
switch: "Schalter / Steckdosen",
|
|
||||||
cover: "Rollläden / Cover",
|
|
||||||
fan: "Lüftung / Ventilatoren",
|
|
||||||
humidifier: "Befeuchter / Entfeuchter",
|
|
||||||
valve: "Ventile",
|
|
||||||
};
|
};
|
||||||
return labels[domain] || domain;
|
return labels[domain] || domain;
|
||||||
}
|
}
|
||||||
@@ -818,3 +812,31 @@ loadOverview();
|
|||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
||||||
|
function categoryLabel(category) {
|
||||||
|
const labels = {
|
||||||
|
light: "Licht",
|
||||||
|
switch_socket: "Steckdosen / Schalter",
|
||||||
|
button: "Buttons",
|
||||||
|
cover_shutter: "Rollläden / Cover",
|
||||||
|
heating: "Heizungen / Klima",
|
||||||
|
fan: "Lüftung / Ventilatoren",
|
||||||
|
ventilation: "Lüftung / Ventilatoren",
|
||||||
|
media_tv: "TV / Medien",
|
||||||
|
helper: "Helper",
|
||||||
|
presence_motion: "Bewegung / Präsenz",
|
||||||
|
opening: "Fenster / Türen",
|
||||||
|
weather: "Wetter",
|
||||||
|
brightness: "Helligkeit",
|
||||||
|
temperature: "Temperatur",
|
||||||
|
humidity: "Feuchtigkeit",
|
||||||
|
energy_power: "Strom / Energie",
|
||||||
|
diagnostic: "Diagnose",
|
||||||
|
measurement: "Messung",
|
||||||
|
binary: "Binär",
|
||||||
|
presence_location: "Anwesenheit / Ort",
|
||||||
|
climate: "Klima",
|
||||||
|
};
|
||||||
|
return labels[category] || category;
|
||||||
|
}
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
# Locale Dev-Umgebung — sillyhome-next-dev
|
|
||||||
|
|
||||||
Ziel: Repo lokal klonen, Backend starten und Änderungen entwickeln, ohne das produktive Add-on direkt zu beeinflussen.
|
|
||||||
|
|
||||||
## Voraussetzungen
|
|
||||||
|
|
||||||
- Git
|
|
||||||
- Python 3.10+
|
|
||||||
- `pip`
|
|
||||||
- Optional: Nginx als Reverse-Proxy
|
|
||||||
|
|
||||||
## 1. Repo klonen
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone http://192.168.6.31:3000/Otto/sillyhome-next-dev.git
|
|
||||||
cd sillyhome-next-dev
|
|
||||||
```
|
|
||||||
|
|
||||||
## 2. Abhängigkeiten installieren
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y git python3 python3-pip uvicorn
|
|
||||||
pip3 install -r requirements.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
## 3. Backend starten (temporär)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
uvicorn app.main:app --reload
|
|
||||||
```
|
|
||||||
|
|
||||||
## 4. Backend dauerhaft per systemd starten
|
|
||||||
|
|
||||||
Datei `/etc/systemd/system/sillyhome-dev.service`:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[Unit]
|
|
||||||
Description=Sillyhome Next Dev
|
|
||||||
After=network.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
WorkingDirectory=/home/otto/sillyhome-next-dev
|
|
||||||
Environment="PATH=/home/otto/.local/bin:/usr/local/bin:/usr/bin:/bin"
|
|
||||||
ExecStart=/usr/local/bin/uvicorn app.main:app --host 0.0.0.0 --port 8000
|
|
||||||
Restart=on-failure
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
```
|
|
||||||
|
|
||||||
Aktivieren:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
sudo systemctl enable --now sillyhome-dev.service
|
|
||||||
```
|
|
||||||
|
|
||||||
## 5. Optional: Nginx Reverse-Proxy
|
|
||||||
|
|
||||||
Datei `/etc/nginx/sites-available/sillyhome-dev`:
|
|
||||||
|
|
||||||
```nginx
|
|
||||||
server {
|
|
||||||
listen 8080;
|
|
||||||
server_name sillyhome-dev.local;
|
|
||||||
location / {
|
|
||||||
proxy_pass http://127.0.0.1:8000/;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Aktivieren:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo ln -sf /etc/nginx/sites-available/sillyhome-dev /etc/nginx/sites-enabled/
|
|
||||||
sudo nginx -t && sudo systemctl reload nginx
|
|
||||||
```
|
|
||||||
|
|
||||||
## 6. Nur Frontend testen
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd /home/otto/sillyhome-next-dev/app/static
|
|
||||||
python3 -m http.server 8080 --directory .
|
|
||||||
```
|
|
||||||
|
|
||||||
Danach im Browser `http://127.0.0.1:8080` öffnen.
|
|
||||||
|
|
||||||
## Hinweis für Weiterentwicklung
|
|
||||||
|
|
||||||
Dieser Branch ist für lokale Entwicklungsiterationen gedacht. Änderungen hier sollen einzeln reviewt und danach in den passenden Produktiv-Branch übernommen werden.
|
|
||||||
Reference in New Issue
Block a user