UNPKG

domotz-remote-pawn

Version:

Domotz Agent

43 lines (38 loc) 1.61 kB
/** This file is part of Domotz Agent. * Copyright (C) 2024 Domotz Ltd * * Domotz Agent is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Domotz Agent is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Domotz Agent. If not, see <http://www.gnu.org/licenses/>. * * Created by NI Team <dev@domotz.com> on 1/02/2024. */ var osInfo = function (resourceLocator) { var host = resourceLocator.discovery.host; var myConsole = resourceLocator.log.decorateLogs(); var info; try { info = resourceLocator.utils.platform.getOsInfo(resourceLocator); } catch (e) { return; } myConsole.info('Retrieved os info: %s', JSON.stringify(info)); var deviceInfo = { name: info.name, version: info.version }; var defaultInterface = host.getDefaultInterface(); if (defaultInterface) { var deviceMac = defaultInterface.mac; resourceLocator.engineRequest.cachedSendWithPromise('/subnet/ip/device/' + deviceMac + '/os-info', 'PUT', deviceInfo, undefined, undefined, { cache_until: resourceLocator.httpOutCache.expirationInNHours(168), }); } }; module.exports.handler = osInfo;