UNPKG

matterbridge-tado-hw

Version:

A Matterbridge plugin that connects Tado° V2/V3/V3+ hot water control to the Matter smart home ecosystem

33 lines 1.65 kB
// Matterbridge plugin for Tado hot water control // Copyright © 2025 Alexander Thoukydides import { checkers } from './ti/config-types.js'; import { deepMerge, getValidationTree } from './utils.js'; import { DEFAULT_CONFIG, PLUGIN_NAME } from './settings.js'; // Check that the configuration is valid export function checkConfiguration(log, config) { // Apply default values Object.assign(config, deepMerge(DEFAULT_CONFIG, config)); // Ensure that all required fields are provided and are of suitable types const checker = checkers.Config; checker.setReportedPath('<PLATFORM_CONFIG>'); const strictValidation = checker.strictValidate(config); if (!checker.test(config)) { log.error('Plugin unable to start due to configuration errors:'); logCheckerValidation(log, config, "error" /* LogLevel.ERROR */, strictValidation); throw new Error('Invalid plugin configuration'); } // Warn of extraneous fields in the configuration if (strictValidation) { log.warn('Unsupported fields in plugin configuration will be ignored:'); logCheckerValidation(log, config, "warn" /* LogLevel.WARN */, strictValidation); } } // Log configuration checker validation errors function logCheckerValidation(log, config, level, errors) { const errorLines = errors ? getValidationTree(errors) : []; errorLines.forEach(line => { log.log(level, line); }); log.info(`${PLUGIN_NAME}.config.json:`); const configLines = JSON.stringify(config, null, 4).split('\n'); configLines.forEach(line => { log.info(` ${line}`); }); } //# sourceMappingURL=check-configuration.js.map