Files
signalk-plugin/plugin/telegram/commands/data.js
Giuseppe Raffa c2c1598226 feat: Implement rulesets and layout management for kiosk plugin
- Added rulesets manager to handle various data types and updates via HTTP and WebSocket.
- Introduced layout store for managing kiosk layouts with caching and server synchronization.
- Enhanced dashboard and data routes to support new layout and ruleset features.
- Updated kiosk HTML and JavaScript to utilize new layout rendering and data binding.
- Removed obsolete map route and integrated map functionality into the new tile renderer.
- Improved Telegram commands to reflect changes in data structure and logging.
- Refactored weather fetching intervals to prevent multiple instances.
- Added SSE stream for real-time layout updates in the kiosk.
2026-05-12 10:17:54 +02:00

60 lines
2.0 KiB
JavaScript

const skFlow = require('../../config/skFlow');
const { liveMarkup } = require('../utility/live');
const logsPaths = [
"navigation.position",
"navigation.headingTrue",
"navigation.speedOverGround",
"propulsion.p1.temperature"
];
module.exports = {
command: 'data',
handler: (bot, msg) => {
const chatId = msg.chat.id;
let text = '';
// Telemetria
const logs = skFlow.getFrom(logsPaths);
text += '*Telemetria di Bordo*\n\n';
if (logs && Object.keys(logs).length > 0) {
for (const [path, value] of Object.entries(logs)) {
const displayValue = typeof value === 'object' ? JSON.stringify(value) : value;
text += `*${path}*: ${displayValue}\n`;
}
} else {
text += 'Nessun dato disponibile.\n';
}
// Meteo
const weather = skFlow.getWithFilter('meb.forecast');
text += '\n*Dati Meteo*\n\n';
if (weather && Object.keys(weather).length > 0) {
for (const [path, value] of Object.entries(weather)) {
const displayValue = typeof value === 'object' ? JSON.stringify(value) : value;
text += `*${path}*: ${displayValue}\n`;
}
} else {
text += 'Nessun dato disponibile.\n';
}
// Mare
const marine = skFlow.getWithFilter('meb.waves');
text += '\n*Dati Meteo del mare*\n\n';
if (marine && Object.keys(marine).length > 0) {
for (const [path, value] of Object.entries(marine)) {
const displayValue = typeof value === 'object' ? JSON.stringify(value) : value;
text += `*${path}*: ${displayValue}\n`;
}
} else {
text += 'Nessun dato disponibile.\n';
}
return bot.sendMessage(chatId, text, {
parse_mode: 'Markdown',
reply_to_message_id: msg.message_id,
reply_markup: liveMarkup(msg.message_id, 'data')
});
}
};