feat: add ioBroker REST API integration
- New iobroker_sources + iobroker_states tables - Source manager with discover, test, CRUD - State poller (10s interval, getBulk endpoint) - REST API routes under /api/iobroker - Frontend page with search + pagination - Sidebar link, app route Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e6b366862c
commit
e76082df92
@ -6,6 +6,7 @@ import Dashboard from './pages/Dashboard';
|
||||
import MqttBrokers from './pages/MqttBrokers';
|
||||
import MqttTopics from './pages/MqttTopics';
|
||||
import PgSources from './pages/PgSources';
|
||||
import IoBroker from './pages/IoBroker';
|
||||
import Datapoints from './pages/Datapoints';
|
||||
import Displays from './pages/Displays';
|
||||
import Layouts from './pages/Layouts';
|
||||
@ -31,6 +32,7 @@ export default function App() {
|
||||
<Route path="/mqtt/brokers" element={<ProtectedRoute><MqttBrokers /></ProtectedRoute>} />
|
||||
<Route path="/mqtt/topics/:brokerId" element={<ProtectedRoute><MqttTopics /></ProtectedRoute>} />
|
||||
<Route path="/pg/sources" element={<ProtectedRoute><PgSources /></ProtectedRoute>} />
|
||||
<Route path="/iobroker" element={<ProtectedRoute><IoBroker /></ProtectedRoute>} />
|
||||
<Route path="/datapoints" element={<ProtectedRoute><Datapoints /></ProtectedRoute>} />
|
||||
<Route path="/displays" element={<ProtectedRoute><Displays /></ProtectedRoute>} />
|
||||
<Route path="/layouts" element={<ProtectedRoute><Layouts /></ProtectedRoute>} />
|
||||
|
||||
BIN
display/frontend/src/assets/hero.png
Normal file
BIN
display/frontend/src/assets/hero.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
1
display/frontend/src/assets/react.svg
Normal file
1
display/frontend/src/assets/react.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
1
display/frontend/src/assets/vite.svg
Normal file
1
display/frontend/src/assets/vite.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 8.5 KiB |
@ -5,6 +5,7 @@ const links = [
|
||||
{ to: '/', label: 'Dashboard', exact: true },
|
||||
{ to: '/mqtt/brokers', label: 'MQTT Broker' },
|
||||
{ to: '/pg/sources', label: 'PostgreSQL Quellen' },
|
||||
{ to: '/iobroker', label: 'ioBroker' },
|
||||
{ to: '/datapoints', label: 'Datenpunkte' },
|
||||
{ to: '/displays', label: 'Displays' },
|
||||
{ to: '/layouts', label: 'Layouts' },
|
||||
|
||||
367
display/frontend/src/pages/IoBroker.tsx
Normal file
367
display/frontend/src/pages/IoBroker.tsx
Normal file
@ -0,0 +1,367 @@
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import type { FormEvent } from 'react';
|
||||
import { api } from '../api/client';
|
||||
import StatusBadge from '../components/StatusBadge';
|
||||
|
||||
interface IoBrokerSource {
|
||||
id: number;
|
||||
name: string;
|
||||
host: string;
|
||||
port: number;
|
||||
enabled: number;
|
||||
status: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
interface IoBrokerState {
|
||||
id: number;
|
||||
source_id: number;
|
||||
state_id: string;
|
||||
selected: number;
|
||||
last_value: string | null;
|
||||
last_ts: number | null;
|
||||
discovered_at: string;
|
||||
}
|
||||
|
||||
interface StatesResponse {
|
||||
states: IoBrokerState[];
|
||||
total: number;
|
||||
}
|
||||
|
||||
const emptyForm = { name: '', host: '', port: '8087' };
|
||||
const PAGE_SIZE = 50;
|
||||
|
||||
export default function IoBroker() {
|
||||
const [sources, setSources] = useState<IoBrokerSource[]>([]);
|
||||
const [selectedSource, setSelectedSource] = useState<IoBrokerSource | null>(null);
|
||||
const [form, setForm] = useState(emptyForm);
|
||||
const [error, setError] = useState('');
|
||||
const [testResult, setTestResult] = useState<string | null>(null);
|
||||
const [discoveryMsg, setDiscoveryMsg] = useState('');
|
||||
|
||||
// States panel state
|
||||
const [statesData, setStatesData] = useState<StatesResponse>({ states: [], total: 0 });
|
||||
const [search, setSearch] = useState('');
|
||||
const [searchInput, setSearchInput] = useState('');
|
||||
const [showSelected, setShowSelected] = useState(false);
|
||||
const [page, setPage] = useState(0);
|
||||
|
||||
async function loadSources() {
|
||||
try {
|
||||
setSources(await api.get<IoBrokerSource[]>('/api/iobroker/sources'));
|
||||
} catch (e) {
|
||||
setError((e as Error).message);
|
||||
}
|
||||
}
|
||||
|
||||
const loadStates = useCallback(async () => {
|
||||
if (!selectedSource) return;
|
||||
try {
|
||||
const params = new URLSearchParams();
|
||||
if (search) params.set('search', search);
|
||||
if (showSelected) params.set('selected', '1');
|
||||
params.set('limit', String(PAGE_SIZE));
|
||||
params.set('offset', String(page * PAGE_SIZE));
|
||||
const result = await api.get<StatesResponse>(
|
||||
`/api/iobroker/sources/${selectedSource.id}/states?${params}`
|
||||
);
|
||||
setStatesData(result);
|
||||
} catch (e) {
|
||||
setError((e as Error).message);
|
||||
}
|
||||
}, [selectedSource, search, showSelected, page]);
|
||||
|
||||
useEffect(() => { loadSources(); }, []);
|
||||
useEffect(() => { loadStates(); }, [loadStates]);
|
||||
|
||||
// Debounced search
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(() => { setSearch(searchInput); setPage(0); }, 400);
|
||||
return () => clearTimeout(timer);
|
||||
}, [searchInput]);
|
||||
|
||||
async function handleAdd(e: FormEvent) {
|
||||
e.preventDefault();
|
||||
setError('');
|
||||
try {
|
||||
await api.post('/api/iobroker/sources', { ...form, port: parseInt(form.port) });
|
||||
setForm(emptyForm);
|
||||
loadSources();
|
||||
} catch (e) {
|
||||
setError((e as Error).message);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(id: number) {
|
||||
if (!confirm('Quelle wirklich loeschen?')) return;
|
||||
try {
|
||||
await api.del(`/api/iobroker/sources/${id}`);
|
||||
if (selectedSource?.id === id) {
|
||||
setSelectedSource(null);
|
||||
setStatesData({ states: [], total: 0 });
|
||||
}
|
||||
loadSources();
|
||||
} catch (e) {
|
||||
setError((e as Error).message);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleTest(source: IoBrokerSource) {
|
||||
setTestResult(null);
|
||||
try {
|
||||
const result = await api.post<{ success: boolean }>(
|
||||
`/api/iobroker/sources/${source.id}/test`
|
||||
);
|
||||
setTestResult(result.success ? 'Verbindung erfolgreich' : 'Nicht erreichbar');
|
||||
} catch (e) {
|
||||
setTestResult('Fehler: ' + (e as Error).message);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDiscover(source: IoBrokerSource) {
|
||||
setDiscoveryMsg('Discovery laeuft...');
|
||||
try {
|
||||
await api.post(`/api/iobroker/sources/${source.id}/discover`);
|
||||
setDiscoveryMsg('Discovery gestartet. States werden geladen...');
|
||||
setTimeout(() => {
|
||||
loadStates();
|
||||
setDiscoveryMsg('');
|
||||
}, 3000);
|
||||
} catch (e) {
|
||||
setDiscoveryMsg('Fehler: ' + (e as Error).message);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSelectState(state: IoBrokerState, selected: boolean) {
|
||||
try {
|
||||
await api.put(`/api/iobroker/states/${state.id}`, { selected: selected ? 1 : 0 });
|
||||
loadStates();
|
||||
} catch (e) {
|
||||
setError((e as Error).message);
|
||||
}
|
||||
}
|
||||
|
||||
function handleSelectSource(source: IoBrokerSource) {
|
||||
setSelectedSource(source);
|
||||
setPage(0);
|
||||
setSearch('');
|
||||
setSearchInput('');
|
||||
setShowSelected(false);
|
||||
setDiscoveryMsg('');
|
||||
setTestResult(null);
|
||||
}
|
||||
|
||||
const totalPages = Math.ceil(statesData.total / PAGE_SIZE);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2 className="text-xl font-semibold text-gray-800 mb-6">ioBroker Quellen</h2>
|
||||
{error && (
|
||||
<div className="mb-4 p-3 bg-red-50 border border-red-200 rounded text-red-700 text-sm">
|
||||
{error}
|
||||
<button className="ml-2 font-bold" onClick={() => setError('')}>x</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Sources table */}
|
||||
<div className="bg-white rounded-lg border border-gray-200 overflow-hidden mb-6">
|
||||
<table className="w-full text-sm">
|
||||
<thead className="bg-gray-50">
|
||||
<tr>
|
||||
<th className="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Name</th>
|
||||
<th className="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Host:Port</th>
|
||||
<th className="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Status</th>
|
||||
<th className="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Aktionen</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-gray-100">
|
||||
{sources.length === 0 && (
|
||||
<tr>
|
||||
<td colSpan={4} className="px-4 py-6 text-center text-gray-400">
|
||||
Keine ioBroker Quellen konfiguriert
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
{sources.map((s) => (
|
||||
<tr
|
||||
key={s.id}
|
||||
className={`hover:bg-gray-50 cursor-pointer ${selectedSource?.id === s.id ? 'bg-sky-50 ring-1 ring-inset ring-sky-200' : ''}`}
|
||||
onClick={() => handleSelectSource(s)}
|
||||
>
|
||||
<td className="px-4 py-2 font-medium text-gray-800">{s.name}</td>
|
||||
<td className="px-4 py-2 text-gray-600">{s.host}:{s.port}</td>
|
||||
<td className="px-4 py-2"><StatusBadge status={s.status} /></td>
|
||||
<td className="px-4 py-2 flex gap-2">
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); handleTest(s); }}
|
||||
className="text-sky-500 hover:text-sky-700 text-xs"
|
||||
>
|
||||
Testen
|
||||
</button>
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); handleSelectSource(s); handleDiscover(s); }}
|
||||
className="text-indigo-500 hover:text-indigo-700 text-xs"
|
||||
>
|
||||
Discovery
|
||||
</button>
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); handleDelete(s.id); }}
|
||||
className="text-red-500 hover:text-red-700 text-xs"
|
||||
>
|
||||
Loeschen
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{testResult && (
|
||||
<div className="mb-4 p-3 bg-blue-50 border border-blue-200 rounded text-blue-700 text-sm">
|
||||
{testResult}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Add form */}
|
||||
<div className="bg-white rounded-lg border border-gray-200 p-6 mb-8">
|
||||
<h3 className="font-medium text-gray-700 mb-4">Quelle hinzufuegen</h3>
|
||||
<form onSubmit={handleAdd} className="grid grid-cols-3 gap-4">
|
||||
<div>
|
||||
<label className="block text-xs text-gray-600 mb-1">Name *</label>
|
||||
<input
|
||||
type="text"
|
||||
required
|
||||
className="w-full border border-gray-300 rounded px-3 py-1.5 text-sm"
|
||||
value={form.name}
|
||||
onChange={(e) => setForm({ ...form, name: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-xs text-gray-600 mb-1">Host *</label>
|
||||
<input
|
||||
type="text"
|
||||
required
|
||||
className="w-full border border-gray-300 rounded px-3 py-1.5 text-sm"
|
||||
value={form.host}
|
||||
onChange={(e) => setForm({ ...form, host: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-xs text-gray-600 mb-1">Port</label>
|
||||
<input
|
||||
type="number"
|
||||
className="w-full border border-gray-300 rounded px-3 py-1.5 text-sm"
|
||||
value={form.port}
|
||||
onChange={(e) => setForm({ ...form, port: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
<div className="col-span-3">
|
||||
<button
|
||||
type="submit"
|
||||
className="bg-sky-500 hover:bg-sky-600 text-white text-sm font-medium px-4 py-2 rounded transition-colors"
|
||||
>
|
||||
Hinzufuegen
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{/* States panel */}
|
||||
{selectedSource && (
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold text-gray-700 mb-2">
|
||||
States — {selectedSource.name}
|
||||
</h3>
|
||||
<p className="text-sm text-gray-500 mb-4">
|
||||
{statesData.total} States gefunden
|
||||
</p>
|
||||
|
||||
{discoveryMsg && (
|
||||
<p className="text-sm text-indigo-600 mb-3">{discoveryMsg}</p>
|
||||
)}
|
||||
|
||||
{/* Controls */}
|
||||
<div className="flex gap-3 mb-4 flex-wrap items-center">
|
||||
<input
|
||||
placeholder="States suchen..."
|
||||
className="border border-gray-300 rounded px-3 py-1.5 text-sm w-72"
|
||||
value={searchInput}
|
||||
onChange={(e) => setSearchInput(e.target.value)}
|
||||
/>
|
||||
<label className="flex items-center gap-1.5 text-sm text-gray-600 cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={showSelected}
|
||||
onChange={(e) => { setShowSelected(e.target.checked); setPage(0); }}
|
||||
className="accent-green-500"
|
||||
/>
|
||||
Nur ausgewaehlte
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div className="bg-white rounded-lg border border-gray-200 overflow-hidden">
|
||||
<table className="w-full text-sm">
|
||||
<thead className="bg-gray-50">
|
||||
<tr>
|
||||
<th className="px-3 py-2 text-left text-xs font-medium text-gray-500 w-10">Aktiv</th>
|
||||
<th className="px-3 py-2 text-left text-xs font-medium text-gray-500">State ID</th>
|
||||
<th className="px-3 py-2 text-left text-xs font-medium text-gray-500 w-48">Letzter Wert</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-gray-100">
|
||||
{statesData.states.length === 0 && (
|
||||
<tr>
|
||||
<td colSpan={3} className="px-3 py-6 text-center text-gray-400">
|
||||
{statesData.total === 0
|
||||
? 'Keine States gefunden. Starte Discovery.'
|
||||
: 'Keine States fuer diese Suche.'}
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
{statesData.states.map((s) => (
|
||||
<tr key={s.id} className={`hover:bg-gray-50 ${s.selected ? 'bg-green-50' : ''}`}>
|
||||
<td className="px-3 py-1.5 text-center">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={!!s.selected}
|
||||
onChange={(e) => handleSelectState(s, e.target.checked)}
|
||||
className="w-4 h-4 accent-green-500 cursor-pointer"
|
||||
/>
|
||||
</td>
|
||||
<td className="px-3 py-1.5 font-mono text-xs text-gray-700 truncate max-w-md" title={s.state_id}>
|
||||
{s.state_id}
|
||||
</td>
|
||||
<td className="px-3 py-1.5 text-xs text-gray-500 truncate max-w-48" title={s.last_value ?? ''}>
|
||||
{s.last_value ?? '—'}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{totalPages > 1 && (
|
||||
<div className="flex items-center gap-2 mt-3 text-sm text-gray-600">
|
||||
<button
|
||||
onClick={() => setPage(Math.max(0, page - 1))}
|
||||
disabled={page === 0}
|
||||
className="px-3 py-1 rounded border border-gray-300 disabled:opacity-30 hover:bg-gray-50"
|
||||
>
|
||||
Zurueck
|
||||
</button>
|
||||
<span>Seite {page + 1} von {totalPages}</span>
|
||||
<button
|
||||
onClick={() => setPage(Math.min(totalPages - 1, page + 1))}
|
||||
disabled={page >= totalPages - 1}
|
||||
className="px-3 py-1 rounded border border-gray-300 disabled:opacity-30 hover:bg-gray-50"
|
||||
>
|
||||
Weiter
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@ -6,6 +6,7 @@ import displayApiRouter from './routes/display-api';
|
||||
import mqttBrokersRouter from './routes/mqtt-brokers';
|
||||
import mqttTopicsRouter from './routes/mqtt-topics';
|
||||
import pgSourcesRouter from './routes/pg-sources';
|
||||
import iobrokerRouter from './routes/iobroker';
|
||||
import datapointsRouter from './routes/datapoints';
|
||||
import displaysRouter from './routes/displays';
|
||||
import layoutsRouter from './routes/layouts';
|
||||
@ -30,6 +31,7 @@ export function createApp(): express.Application {
|
||||
app.use('/api/mqtt/brokers/:brokerId/topics', authMiddleware, mqttTopicsRouter);
|
||||
app.use('/api/mqtt/brokers', authMiddleware, mqttBrokersRouter);
|
||||
app.use('/api/pg/sources', authMiddleware, pgSourcesRouter);
|
||||
app.use('/api/iobroker', authMiddleware, iobrokerRouter);
|
||||
app.use('/api/datapoints', authMiddleware, datapointsRouter);
|
||||
app.use('/api/displays', authMiddleware, displaysRouter);
|
||||
app.use('/api/layouts', authMiddleware, layoutsRouter);
|
||||
|
||||
132
display/middleware/src/api/routes/iobroker.ts
Normal file
132
display/middleware/src/api/routes/iobroker.ts
Normal file
@ -0,0 +1,132 @@
|
||||
import { Router } from 'express';
|
||||
import {
|
||||
getAllSources,
|
||||
getSourceById,
|
||||
createSource,
|
||||
updateSource,
|
||||
deleteSource,
|
||||
testSource,
|
||||
discoverStates,
|
||||
getStatesForSource,
|
||||
updateState,
|
||||
} from '../../modules/iobroker/source-manager';
|
||||
import {
|
||||
createDatapointFromIoBroker,
|
||||
getDatapointByIoBrokerStateId,
|
||||
} from '../../modules/datapoints/datapoint-manager';
|
||||
import { startPolling } from '../../modules/iobroker/state-poller';
|
||||
import { getDb } from '../../db/index';
|
||||
|
||||
const router = Router();
|
||||
|
||||
// GET /api/iobroker/sources
|
||||
router.get('/sources', (_req, res): void => {
|
||||
try {
|
||||
res.json(getAllSources());
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: (err as Error).message });
|
||||
}
|
||||
});
|
||||
|
||||
// POST /api/iobroker/sources
|
||||
router.post('/sources', (req, res): void => {
|
||||
try {
|
||||
const { name, host } = req.body;
|
||||
if (!name || !host) {
|
||||
res.status(400).json({ error: 'name and host are required' });
|
||||
return;
|
||||
}
|
||||
res.status(201).json(createSource(req.body));
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: (err as Error).message });
|
||||
}
|
||||
});
|
||||
|
||||
// PUT /api/iobroker/sources/:id
|
||||
router.put('/sources/:id', (req, res): void => {
|
||||
try {
|
||||
const source = updateSource(parseInt(req.params.id), req.body);
|
||||
if (!source) { res.status(404).json({ error: 'Source not found' }); return; }
|
||||
res.json(source);
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: (err as Error).message });
|
||||
}
|
||||
});
|
||||
|
||||
// DELETE /api/iobroker/sources/:id
|
||||
router.delete('/sources/:id', (req, res): void => {
|
||||
try {
|
||||
const deleted = deleteSource(parseInt(req.params.id));
|
||||
if (!deleted) { res.status(404).json({ error: 'Source not found' }); return; }
|
||||
res.status(204).send();
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: (err as Error).message });
|
||||
}
|
||||
});
|
||||
|
||||
// POST /api/iobroker/sources/:id/test
|
||||
router.post('/sources/:id/test', (req, res): void => {
|
||||
const id = parseInt(req.params.id);
|
||||
const source = getSourceById(id);
|
||||
if (!source) { res.status(404).json({ error: 'Source not found' }); return; }
|
||||
|
||||
testSource(source.host, source.port)
|
||||
.then((ok) => res.json({ success: ok }))
|
||||
.catch((err) => res.status(500).json({ error: (err as Error).message }));
|
||||
});
|
||||
|
||||
// POST /api/iobroker/sources/:id/discover
|
||||
router.post('/sources/:id/discover', (req, res): void => {
|
||||
const id = parseInt(req.params.id);
|
||||
|
||||
res.json({ message: 'Discovery started', sourceId: id });
|
||||
|
||||
discoverStates(id).then((count) => {
|
||||
console.log(`ioBroker discovery for source ${id}: found ${count} states`);
|
||||
}).catch((err) => {
|
||||
console.error(`ioBroker discovery error for source ${id}:`, (err as Error).message);
|
||||
});
|
||||
});
|
||||
|
||||
// GET /api/iobroker/sources/:id/states?search=&selected=1&limit=50&offset=0
|
||||
router.get('/sources/:id/states', (req, res): void => {
|
||||
try {
|
||||
const sourceId = parseInt(req.params.id);
|
||||
const search = req.query.search as string | undefined;
|
||||
const selectedOnly = req.query.selected === '1';
|
||||
const limit = parseInt(req.query.limit as string) || 50;
|
||||
const offset = parseInt(req.query.offset as string) || 0;
|
||||
res.json(getStatesForSource(sourceId, { search, selectedOnly, limit, offset }));
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: (err as Error).message });
|
||||
}
|
||||
});
|
||||
|
||||
// PUT /api/iobroker/states/:id
|
||||
router.put('/states/:id', (req, res): void => {
|
||||
try {
|
||||
const stateRowId = parseInt(req.params.id);
|
||||
const stateRow = getDb()
|
||||
.prepare('SELECT * FROM iobroker_states WHERE id = ?')
|
||||
.get(stateRowId) as { id: number; source_id: number; state_id: string; selected: number } | undefined;
|
||||
|
||||
if (!stateRow) { res.status(404).json({ error: 'State not found' }); return; }
|
||||
|
||||
const updated = updateState(stateRowId, req.body);
|
||||
|
||||
// If selecting a state, auto-create a datapoint and ensure poller is running
|
||||
if (req.body.selected === 1 || req.body.selected === true) {
|
||||
const existing = getDatapointByIoBrokerStateId(stateRow.state_id);
|
||||
if (!existing) {
|
||||
createDatapointFromIoBroker(stateRow.source_id, stateRow.state_id, stateRow.state_id);
|
||||
}
|
||||
startPolling(stateRow.source_id);
|
||||
}
|
||||
|
||||
res.json(updated);
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: (err as Error).message });
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
@ -1,5 +1,6 @@
|
||||
import Database from 'better-sqlite3';
|
||||
import { migrate001 } from './migrations/001-initial';
|
||||
import { migrate002 } from './migrations/002-iobroker';
|
||||
|
||||
let dbInstance: Database.Database | null = null;
|
||||
|
||||
@ -11,6 +12,7 @@ export function initDb(path: string): Database.Database {
|
||||
|
||||
// Run migrations
|
||||
migrate001(db);
|
||||
migrate002(db);
|
||||
|
||||
dbInstance = db;
|
||||
return db;
|
||||
|
||||
57
display/middleware/src/db/migrations/002-iobroker.ts
Normal file
57
display/middleware/src/db/migrations/002-iobroker.ts
Normal file
@ -0,0 +1,57 @@
|
||||
import Database from 'better-sqlite3';
|
||||
|
||||
export function migrate002(db: Database.Database): void {
|
||||
// Create ioBroker sources table
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS iobroker_sources (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
host TEXT NOT NULL,
|
||||
port INTEGER DEFAULT 8087,
|
||||
enabled INTEGER DEFAULT 1,
|
||||
status TEXT DEFAULT 'disconnected',
|
||||
created_at TEXT DEFAULT (datetime('now'))
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS iobroker_states (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
source_id INTEGER NOT NULL REFERENCES iobroker_sources(id) ON DELETE CASCADE,
|
||||
state_id TEXT NOT NULL,
|
||||
selected INTEGER DEFAULT 0,
|
||||
last_value TEXT,
|
||||
last_ts INTEGER,
|
||||
discovered_at TEXT DEFAULT (datetime('now'))
|
||||
);
|
||||
`);
|
||||
|
||||
// Update datapoints CHECK constraint to allow 'iobroker'
|
||||
// SQLite does not support ALTER CHECK, so recreate the table if needed
|
||||
const row = db
|
||||
.prepare("SELECT sql FROM sqlite_master WHERE type='table' AND name='datapoints'")
|
||||
.get() as { sql: string } | undefined;
|
||||
|
||||
if (row && !row.sql.includes('iobroker')) {
|
||||
db.exec(`
|
||||
CREATE TABLE datapoints_new (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
label TEXT NOT NULL,
|
||||
unit TEXT,
|
||||
value TEXT,
|
||||
status TEXT DEFAULT 'unknown',
|
||||
source_type TEXT NOT NULL CHECK(source_type IN ('mqtt','postgresql','iobroker')),
|
||||
source_id INTEGER NOT NULL,
|
||||
topic_id INTEGER,
|
||||
query_id INTEGER,
|
||||
transform TEXT,
|
||||
enabled INTEGER DEFAULT 1,
|
||||
updated_at TEXT DEFAULT (datetime('now')),
|
||||
FOREIGN KEY (topic_id) REFERENCES mqtt_topics(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (query_id) REFERENCES pg_queries(id) ON DELETE SET NULL
|
||||
);
|
||||
INSERT INTO datapoints_new SELECT * FROM datapoints;
|
||||
DROP TABLE datapoints;
|
||||
ALTER TABLE datapoints_new RENAME TO datapoints;
|
||||
`);
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,7 @@ import { createApp } from './api/index';
|
||||
import { connectAllEnabledBrokers } from './modules/mqtt/broker-manager';
|
||||
import { connectAllEnabledSources } from './modules/postgres/source-manager';
|
||||
import { startAllQueryTimers } from './modules/postgres/query-scheduler';
|
||||
import { startAllPollers } from './modules/iobroker/state-poller';
|
||||
|
||||
const PORT = process.env.PORT ? parseInt(process.env.PORT) : 4000;
|
||||
const DB_PATH = process.env.DB_PATH ?? './display.db';
|
||||
@ -32,6 +33,9 @@ async function main(): Promise<void> {
|
||||
await connectAllEnabledSources();
|
||||
startAllQueryTimers();
|
||||
|
||||
// Start ioBroker state pollers for all enabled sources
|
||||
startAllPollers();
|
||||
|
||||
// Create and start Express app
|
||||
const app = createApp();
|
||||
|
||||
|
||||
@ -137,3 +137,24 @@ export function getDatapointByQueryId(queryId: number): Datapoint | undefined {
|
||||
.prepare('SELECT * FROM datapoints WHERE query_id = ?')
|
||||
.get(queryId) as Datapoint | undefined;
|
||||
}
|
||||
|
||||
export function createDatapointFromIoBroker(
|
||||
sourceId: number,
|
||||
stateId: string,
|
||||
stateName: string
|
||||
): Datapoint {
|
||||
const db = getDb();
|
||||
const result = db.prepare(
|
||||
`INSERT INTO datapoints (name, label, source_type, source_id, enabled)
|
||||
VALUES (?, ?, 'iobroker', ?, 1)`
|
||||
).run(stateId, stateName, sourceId);
|
||||
const id = result.lastInsertRowid as number;
|
||||
return db.prepare('SELECT * FROM datapoints WHERE id = ?').get(id) as Datapoint;
|
||||
}
|
||||
|
||||
export function getDatapointByIoBrokerStateId(stateId: string): Datapoint | undefined {
|
||||
const db = getDb();
|
||||
return db
|
||||
.prepare("SELECT * FROM datapoints WHERE source_type = 'iobroker' AND name = ?")
|
||||
.get(stateId) as Datapoint | undefined;
|
||||
}
|
||||
|
||||
187
display/middleware/src/modules/iobroker/source-manager.ts
Normal file
187
display/middleware/src/modules/iobroker/source-manager.ts
Normal file
@ -0,0 +1,187 @@
|
||||
import { getDb } from '../../db/index';
|
||||
|
||||
export interface IoBrokerSource {
|
||||
id: number;
|
||||
name: string;
|
||||
host: string;
|
||||
port: number;
|
||||
enabled: number;
|
||||
status: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface CreateSourceData {
|
||||
name: string;
|
||||
host: string;
|
||||
port?: number;
|
||||
enabled?: number;
|
||||
}
|
||||
|
||||
export type UpdateSourceData = Partial<CreateSourceData>;
|
||||
|
||||
export interface IoBrokerState {
|
||||
id: number;
|
||||
source_id: number;
|
||||
state_id: string;
|
||||
selected: number;
|
||||
last_value: string | null;
|
||||
last_ts: number | null;
|
||||
discovered_at: string;
|
||||
}
|
||||
|
||||
export function getAllSources(): IoBrokerSource[] {
|
||||
const db = getDb();
|
||||
return db.prepare('SELECT * FROM iobroker_sources ORDER BY id ASC').all() as IoBrokerSource[];
|
||||
}
|
||||
|
||||
export function getSourceById(id: number): IoBrokerSource | undefined {
|
||||
const db = getDb();
|
||||
return db.prepare('SELECT * FROM iobroker_sources WHERE id = ?').get(id) as IoBrokerSource | undefined;
|
||||
}
|
||||
|
||||
export function createSource(data: CreateSourceData): IoBrokerSource {
|
||||
const db = getDb();
|
||||
const result = db.prepare(
|
||||
`INSERT INTO iobroker_sources (name, host, port, enabled)
|
||||
VALUES (?, ?, ?, ?)`
|
||||
).run(
|
||||
data.name,
|
||||
data.host,
|
||||
data.port ?? 8087,
|
||||
data.enabled ?? 1,
|
||||
);
|
||||
const id = result.lastInsertRowid as number;
|
||||
return db.prepare('SELECT * FROM iobroker_sources WHERE id = ?').get(id) as IoBrokerSource;
|
||||
}
|
||||
|
||||
export function updateSource(id: number, data: UpdateSourceData): IoBrokerSource | undefined {
|
||||
const db = getDb();
|
||||
const fields: string[] = [];
|
||||
const values: unknown[] = [];
|
||||
|
||||
if (data.name !== undefined) { fields.push('name = ?'); values.push(data.name); }
|
||||
if (data.host !== undefined) { fields.push('host = ?'); values.push(data.host); }
|
||||
if (data.port !== undefined) { fields.push('port = ?'); values.push(data.port); }
|
||||
if (data.enabled !== undefined) { fields.push('enabled = ?'); values.push(data.enabled); }
|
||||
|
||||
if (fields.length === 0) return getSourceById(id);
|
||||
|
||||
values.push(id);
|
||||
db.prepare(`UPDATE iobroker_sources SET ${fields.join(', ')} WHERE id = ?`).run(...values);
|
||||
return getSourceById(id);
|
||||
}
|
||||
|
||||
export function deleteSource(id: number): boolean {
|
||||
const db = getDb();
|
||||
const result = db.prepare('DELETE FROM iobroker_sources WHERE id = ?').run(id);
|
||||
return (result.changes as number) > 0;
|
||||
}
|
||||
|
||||
function setStatus(id: number, status: string): void {
|
||||
const db = getDb();
|
||||
db.prepare('UPDATE iobroker_sources SET status = ? WHERE id = ?').run(status, id);
|
||||
}
|
||||
|
||||
export async function testSource(host: string, port: number): Promise<boolean> {
|
||||
try {
|
||||
const url = `http://${host}:${port}/get/system.adapter.admin.0.alive`;
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => controller.abort(), 5000);
|
||||
const res = await fetch(url, { signal: controller.signal });
|
||||
clearTimeout(timeout);
|
||||
return res.ok;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function getStatesForSource(
|
||||
sourceId: number,
|
||||
opts?: { search?: string; selectedOnly?: boolean; limit?: number; offset?: number }
|
||||
): { states: IoBrokerState[]; total: number } {
|
||||
const db = getDb();
|
||||
const conditions = ['source_id = ?'];
|
||||
const params: unknown[] = [sourceId];
|
||||
|
||||
if (opts?.search) {
|
||||
conditions.push('state_id LIKE ?');
|
||||
params.push(`%${opts.search}%`);
|
||||
}
|
||||
if (opts?.selectedOnly) {
|
||||
conditions.push('selected = 1');
|
||||
}
|
||||
|
||||
const where = conditions.join(' AND ');
|
||||
const total = (db.prepare(`SELECT count(*) as c FROM iobroker_states WHERE ${where}`).get(...params) as { c: number }).c;
|
||||
|
||||
const limit = opts?.limit ?? 50;
|
||||
const offset = opts?.offset ?? 0;
|
||||
params.push(limit, offset);
|
||||
|
||||
const states = db
|
||||
.prepare(`SELECT * FROM iobroker_states WHERE ${where} ORDER BY selected DESC, state_id ASC LIMIT ? OFFSET ?`)
|
||||
.all(...params) as IoBrokerState[];
|
||||
|
||||
return { states, total };
|
||||
}
|
||||
|
||||
export function updateState(id: number, data: { selected?: number; last_value?: string; last_ts?: number }): IoBrokerState | undefined {
|
||||
const db = getDb();
|
||||
const fields: string[] = [];
|
||||
const values: unknown[] = [];
|
||||
|
||||
if (data.selected !== undefined) { fields.push('selected = ?'); values.push(data.selected); }
|
||||
if (data.last_value !== undefined) { fields.push('last_value = ?'); values.push(data.last_value); }
|
||||
if (data.last_ts !== undefined) { fields.push('last_ts = ?'); values.push(data.last_ts); }
|
||||
|
||||
if (fields.length === 0) {
|
||||
return db.prepare('SELECT * FROM iobroker_states WHERE id = ?').get(id) as IoBrokerState | undefined;
|
||||
}
|
||||
|
||||
values.push(id);
|
||||
db.prepare(`UPDATE iobroker_states SET ${fields.join(', ')} WHERE id = ?`).run(...values);
|
||||
return db.prepare('SELECT * FROM iobroker_states WHERE id = ?').get(id) as IoBrokerState | undefined;
|
||||
}
|
||||
|
||||
export async function discoverStates(sourceId: number): Promise<number> {
|
||||
const source = getSourceById(sourceId);
|
||||
if (!source) throw new Error(`ioBroker source ${sourceId} not found`);
|
||||
|
||||
const db = getDb();
|
||||
|
||||
try {
|
||||
setStatus(sourceId, 'discovering');
|
||||
|
||||
const url = `http://${source.host}:${source.port}/objects?type=state&pattern=*`;
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => controller.abort(), 15000);
|
||||
const res = await fetch(url, { signal: controller.signal });
|
||||
clearTimeout(timeout);
|
||||
|
||||
if (!res.ok) {
|
||||
setStatus(sourceId, 'error');
|
||||
throw new Error(`ioBroker API returned ${res.status}`);
|
||||
}
|
||||
|
||||
const data = await res.json() as Record<string, unknown>;
|
||||
const stateIds = Object.keys(data).slice(0, 5000);
|
||||
|
||||
const insertStmt = db.prepare(
|
||||
`INSERT OR IGNORE INTO iobroker_states (source_id, state_id) VALUES (?, ?)`
|
||||
);
|
||||
|
||||
const insertMany = db.transaction((ids: string[]) => {
|
||||
for (const sid of ids) {
|
||||
insertStmt.run(sourceId, sid);
|
||||
}
|
||||
});
|
||||
|
||||
insertMany(stateIds);
|
||||
setStatus(sourceId, 'connected');
|
||||
|
||||
return stateIds.length;
|
||||
} catch (err) {
|
||||
setStatus(sourceId, 'error');
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
86
display/middleware/src/modules/iobroker/state-poller.ts
Normal file
86
display/middleware/src/modules/iobroker/state-poller.ts
Normal file
@ -0,0 +1,86 @@
|
||||
import { getDb } from '../../db/index';
|
||||
import { getAllSources, getSourceById, type IoBrokerState } from './source-manager';
|
||||
import {
|
||||
getDatapointByIoBrokerStateId,
|
||||
updateDatapointValue,
|
||||
} from '../datapoints/datapoint-manager';
|
||||
|
||||
const pollerTimers = new Map<number, ReturnType<typeof setInterval>>();
|
||||
|
||||
const POLL_INTERVAL_MS = 10_000;
|
||||
|
||||
async function pollSource(sourceId: number): Promise<void> {
|
||||
const source = getSourceById(sourceId);
|
||||
if (!source || !source.enabled) return;
|
||||
|
||||
const db = getDb();
|
||||
const selectedStates = db
|
||||
.prepare('SELECT * FROM iobroker_states WHERE source_id = ? AND selected = 1')
|
||||
.all(sourceId) as IoBrokerState[];
|
||||
|
||||
if (selectedStates.length === 0) return;
|
||||
|
||||
const stateIds = selectedStates.map((s) => s.state_id).join(',');
|
||||
const url = `http://${source.host}:${source.port}/getBulk/${encodeURIComponent(stateIds)}`;
|
||||
|
||||
try {
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => controller.abort(), 8000);
|
||||
const res = await fetch(url, { signal: controller.signal });
|
||||
clearTimeout(timeout);
|
||||
|
||||
if (!res.ok) return;
|
||||
|
||||
const results = await res.json() as Array<{ id: string; val: unknown; ts?: number }>;
|
||||
|
||||
for (const item of results) {
|
||||
if (item.val === null || item.val === undefined) continue;
|
||||
const rawValue = String(item.val);
|
||||
|
||||
// Update last_value in iobroker_states
|
||||
db.prepare(
|
||||
'UPDATE iobroker_states SET last_value = ?, last_ts = ? WHERE source_id = ? AND state_id = ?'
|
||||
).run(rawValue, item.ts ?? null, sourceId, item.id);
|
||||
|
||||
// Update datapoint value if one exists
|
||||
const dp = getDatapointByIoBrokerStateId(item.id);
|
||||
if (dp) {
|
||||
updateDatapointValue(dp.id, rawValue);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
// Silently ignore polling errors — source may be temporarily unreachable
|
||||
console.warn(`ioBroker poll error for source ${sourceId}:`, (err as Error).message);
|
||||
}
|
||||
}
|
||||
|
||||
export function startPolling(sourceId: number): void {
|
||||
if (pollerTimers.has(sourceId)) return; // already running
|
||||
|
||||
const timer = setInterval(() => {
|
||||
pollSource(sourceId).catch((err) =>
|
||||
console.error(`ioBroker poller ${sourceId}:`, (err as Error).message)
|
||||
);
|
||||
}, POLL_INTERVAL_MS);
|
||||
|
||||
pollerTimers.set(sourceId, timer);
|
||||
console.log(`ioBroker poller started for source ${sourceId}`);
|
||||
}
|
||||
|
||||
export function stopPolling(sourceId: number): void {
|
||||
const timer = pollerTimers.get(sourceId);
|
||||
if (timer) {
|
||||
clearInterval(timer);
|
||||
pollerTimers.delete(sourceId);
|
||||
console.log(`ioBroker poller stopped for source ${sourceId}`);
|
||||
}
|
||||
}
|
||||
|
||||
export function startAllPollers(): void {
|
||||
const sources = getAllSources();
|
||||
for (const source of sources) {
|
||||
if (source.enabled) {
|
||||
startPolling(source.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user