Skip to content

Commit

Permalink
(simatec) ESPHome Backup added
Browse files Browse the repository at this point in the history
  • Loading branch information
simatec committed Nov 1, 2023
1 parent e31afb5 commit 956f654
Show file tree
Hide file tree
Showing 22 changed files with 233 additions and 6 deletions.
1 change: 1 addition & 0 deletions admin/i18n/de/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"Dropbox-API Type": "Dropbox-API Typ",
"Dropbox: Yes": "Dropbox: Ja",
"E-Mail": "E-Mail",
"ESPHome": "ESPHome",
"Enable / disable log": "Log aktivieren / deaktivieren",
"Enable Notifications": "Benachrichtigungen aktivieren",
"Enable debug": "Debug aktivieren",
Expand Down
1 change: 1 addition & 0 deletions admin/i18n/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"Dropbox-API Type": "Dropbox-API Type",
"Dropbox: Yes": "Dropbox: Yes",
"E-Mail": "E-mail",
"ESPHome": "ESPHome",
"Enable / disable log": "Enable / disable log",
"Enable Notifications": "Enable Notifications",
"Enable debug": "Enable debug",
Expand Down
1 change: 1 addition & 0 deletions admin/i18n/es/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"Dropbox-API Type": "Tipo de API de Dropbox",
"Dropbox: Yes": "Dropbox: si",
"E-Mail": "Correo electrónico",
"ESPHome": "ESPHome",
"Enable / disable log": "Activar / desactivar registro",
"Enable Notifications": "Permitir notificaciones",
"Enable debug": "Habilitar depuración",
Expand Down
1 change: 1 addition & 0 deletions admin/i18n/fr/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"Dropbox-API Type": "Type d'API Dropbox",
"Dropbox: Yes": "Dropbox: oui",
"E-Mail": "Email",
"ESPHome": "ESPHome",
"Enable / disable log": "Activer / désactiver le journal",
"Enable Notifications": "Activer les notifications",
"Enable debug": "Activer le débogage",
Expand Down
1 change: 1 addition & 0 deletions admin/i18n/it/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"Dropbox-API Type": "Tipo di API Dropbox",
"Dropbox: Yes": "Dropbox: Sì",
"E-Mail": "E-mail",
"ESPHome": "ESPHIO",
"Enable / disable log": "Attiva / disattiva registro",
"Enable Notifications": "Attivare le notifiche",
"Enable debug": "Abilita debug",
Expand Down
1 change: 1 addition & 0 deletions admin/i18n/nl/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"Dropbox-API Type": "Dropbox-API-type",
"Dropbox: Yes": "Dropbox: Ja",
"E-Mail": "E-mail",
"ESPHome": "ESPHome",
"Enable / disable log": "Activeer / deactiveer log",
"Enable Notifications": "Notificaties aanzetten",
"Enable debug": "Foutopsporing inschakelen",
Expand Down
1 change: 1 addition & 0 deletions admin/i18n/pl/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"Dropbox-API Type": "Typ Dropbox-API",
"Dropbox: Yes": "Dropbox: Tak",
"E-Mail": "E-mail",
"ESPHome": "ESPHom",
"Enable / disable log": "Aktywuj / dezaktywuj dziennik",
"Enable Notifications": "Włącz powiadomienia",
"Enable debug": "Włącz debugowanie",
Expand Down
1 change: 1 addition & 0 deletions admin/i18n/pt/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"Dropbox-API Type": "Tipo de API do Dropbox",
"Dropbox: Yes": "Dropbox: sim",
"E-Mail": "O email",
"ESPHome": "ESPHome",
"Enable / disable log": "Ativar / desativar log",
"Enable Notifications": "Ativar notificações",
"Enable debug": "Ativar depuração",
Expand Down
1 change: 1 addition & 0 deletions admin/i18n/ru/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"Dropbox-API Type": "Тип Dropbox-API",
"Dropbox: Yes": "Dropbox: Да",
"E-Mail": "Эл. почта",
"ESPHome": "ESPГлавная",
"Enable / disable log": "Включение / отключение логирования",
"Enable Notifications": "Включить уведомления",
"Enable debug": "Включить отладку",
Expand Down
1 change: 1 addition & 0 deletions admin/i18n/uk/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"Dropbox-API Type": "Тип Dropbox-API",
"Dropbox: Yes": "Dropbox: Так",
"E-Mail": "Електронна пошта",
"ESPHome": "ESPбудинки",
"Enable / disable log": "Увімкнути/вимкнути журнал",
"Enable Notifications": "Увімкнути сповіщення",
"Enable debug": "Увімкнути налагодження",
Expand Down
1 change: 1 addition & 0 deletions admin/i18n/zh-cn/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"Dropbox-API Type": "Dropbox-API 类型",
"Dropbox: Yes": "保管箱:是的",
"E-Mail": "电子邮件",
"ESPHome": "ESPHome",
"Enable / disable log": "启用/禁用日志",
"Enable Notifications": "启用通知",
"Enable debug": "启用调试",
Expand Down
4 changes: 4 additions & 0 deletions admin/index_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ <h6 class="translate title" style="background-color:#174475; font-size: 0.9rem;
<input class="value" id="jarvisEnabled" type="checkbox"/>
<label for="jarvisEnabled" class="translate">Jarvis Backup</label>
</div>
<div class="input-field col s6 l2">
<input class="value" id="esphomeEnabled" type="checkbox"/>
<label for="esphomeEnabled" class="translate">ESPHome</label>
</div>
</div>
<div class="row" style="padding: 2px;">
<h6 class="translate title" style="background-color:#174475; font-size: 0.9rem; border-radius: 4px;">Storage location</h6>
Expand Down
14 changes: 12 additions & 2 deletions admin/index_m.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var storageTyp = '';

var oldJavascriptsEnabled;
var oldZigbeeEnabled;
var oldesphomeEnabled;
var oldNoderedEnabled;
var oldJarvisEnabled;
var oldHistoryEnabled;
Expand Down Expand Up @@ -311,13 +312,13 @@ function checkAdapterInstall(name, backitupHost) {
for (var i = 0; i < res.rows.length; i++) {
var common = res.rows[i].value.common;

if (common.host !== backitupHost && (adapterName == 'zigbee' || adapterName == 'zigbee2mqtt' || adapterName == 'node-red' || adapterName == 'yahka' || adapterName == 'jarvis' || adapterName == 'history')) {
if (common.host !== backitupHost && (adapterName == 'zigbee' || adapterName == 'esphome' || adapterName == 'zigbee2mqtt' || adapterName == 'node-red' || adapterName == 'yahka' || adapterName == 'jarvis' || adapterName == 'history')) {
showMessage(_("No %s Instance found on this host. Please check your System", adapterName), _('Backitup Warning!'), 'info');
ignoreMessage.push(name);
break;
}
}
} else if (res.rows.length == 0 && (adapterName == 'zigbee' || adapterName == 'zigbee2mqtt' || adapterName == 'node-red' || adapterName == 'yahka' || adapterName == 'jarvis' || adapterName == 'history')) {
} else if (res.rows.length == 0 && (adapterName == 'zigbee' || adapterName == 'esphome' || adapterName == 'zigbee2mqtt' || adapterName == 'node-red' || adapterName == 'yahka' || adapterName == 'jarvis' || adapterName == 'history')) {
showMessage(_("No %s Instance found on this host. Please check your System", adapterName), _('Backitup Warning!'), 'info');
ignoreMessage.push(name);
}
Expand Down Expand Up @@ -401,6 +402,7 @@ function load(settings, onChange) {

oldJavascriptsEnabled = settings.javascriptsEnabled;
oldZigbeeEnabled = settings.zigbeeEnabled;
oldesphomeEnabled = settings.esphomeEnabled;
oldZigbee2MQTTEnabled = settings.zigbee2mqttEnabled;
oldNoderedEnabled = settings.noderedEnabled;
oldJarvisEnabled = settings.jarvisEnabled;
Expand Down Expand Up @@ -805,6 +807,7 @@ function load(settings, onChange) {
file.search('influxDB') == -1 &&
file.search('pgsql') == -1 &&
file.search('zigbee') == -1 &&
file.search('esphome') == -1 &&
file.search('zigbee2mqtt') == -1 &&
file.search('nodered') == -1 &&
file.search('yahka') == -1 &&
Expand Down Expand Up @@ -1767,6 +1770,13 @@ function showHideSettings(settings) {
} else {
cleanIgnoreMessage('zigbee');
}
if ($('#esphomeEnabled').prop('checked')) {
if (!oldesphomeEnabled) {
checkAdapterInstall('esphome', common.host);
}
} else {
cleanIgnoreMessage('esphome');
}
if ($('#zigbee2mqttEnabled').prop('checked')) {
if (!oldZigbee2MQTTEnabled) {
checkAdapterInstall('zigbee2mqtt', common.host);
Expand Down
2 changes: 2 additions & 0 deletions admin/tab_m.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ function load(settings, onChange) {
file.search('influxDB') == -1 &&
file.search('pgsql') == -1 &&
file.search('zigbee') == -1 &&
file.search('esphome') == -1 &&
file.search('zigbee2mqtt') == -1 &&
file.search('nodered') == -1 &&
file.search('yahka') == -1 &&
Expand Down Expand Up @@ -648,6 +649,7 @@ function fillBackupOptions(settings) {
if (settings.redisEnabled) _options.push(_('Save Redis state'));
if (settings.javascriptsEnabled) _options.push(_('Javascripts Backup'));
if (settings.zigbeeEnabled) _options.push(_('Save Zigbee database'));
if (settings.esphomeEnabled) _options.push(_('ESPHome'));
if (settings.zigbee2mqttEnabled) _options.push(_('Zigbee2MQTT'));
if (settings.noderedEnabled) _options.push(_('Node-Red Backup'));
if (settings.yahkaEnabled) _options.push(_('Yahka (Homekit) Backup'));
Expand Down
1 change: 1 addition & 0 deletions admin/words.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[11:20:37] Using gulpfile /opt/iobroker/node_modules/iobroker.backitup/gulpfile.js
[12:50:21] Using gulpfile /opt/iobroker/node_modules/iobroker.backitup/gulpfile.js
1 change: 1 addition & 0 deletions io-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@
"historyPath": "media/usb/history",
"javascriptsEnabled": false,
"zigbeeEnabled": false,
"esphomeEnabled": false,
"yahkaEnabled": false,
"jarvisEnabled": false,
"notificationEnabled": false,
Expand Down
8 changes: 8 additions & 0 deletions lib/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ function executeScripts(adapter, config, callback, scripts, code) {
options = Object.assign({}, config[name]);
}
break;
case 'esphome':
if (config.name === 'iobroker' && config[name] && config[name].enabled) {
func = scripts[name];
options = Object.assign({}, config[name]);
}
break;
case 'zigbee2mqtt':
if (config.name === 'iobroker' && config[name] && config[name].enabled) {
func = scripts[name];
Expand Down Expand Up @@ -318,6 +324,7 @@ function executeScripts(adapter, config, callback, scripts, code) {
if (_options.javascripts && !_options.javascripts.enabled) delete _options.javascripts;
if (_options.jarvis && !_options.jarvis.enabled) delete _options.jarvis;
if (_options.zigbee && !_options.zigbee.enabled) delete _options.zigbee;
if (_options.esphome && !_options.esphome.enabled) delete _options.esphome;
if (_options.zigbee2mqtt && !_options.zigbee2mqtt.enabled) delete _options.zigbee2mqtt;
if (_options.nodered && !_options.nodered.enabled) delete _options.nodered;
if (_options.yahka && !_options.yahka.enabled) delete _options.yahka;
Expand All @@ -333,6 +340,7 @@ function executeScripts(adapter, config, callback, scripts, code) {
if (_options.grafana && _options.grafana.backupDir !== undefined) delete _options.grafana.backupDir;
if (_options.jarvis && _options.jarvis.backupDir !== undefined) delete _options.jarvis.backupDir;
if (_options.zigbee && _options.zigbee.backupDir !== undefined) delete _options.zigbee.backupDir;
if (_options.esphome && _options.esphome.backupDir !== undefined) delete _options.esphome.backupDir;
if (_options.zigbee2mqtt && _options.zigbee2mqtt.backupDir !== undefined) delete _options.zigbee2mqtt.backupDir;
if (_options.nodered && _options.nodered.backupDir !== undefined) delete _options.nodered.backupDir;
if (_options.yahka && _options.yahka.backupDir !== undefined) delete _options.yahka.backupDir;
Expand Down
6 changes: 3 additions & 3 deletions lib/restore.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function getFile(options, storageType, fileName, toSaveName, log, callback) {
} else {
const name = fileName.split('/').pop();
let backupType = name.split('.')[0];
if (backupType !== 'nodered' && backupType !== 'zigbee' && backupType !== 'jarvis' && backupType !== 'yahka') {
if (backupType !== 'nodered' && backupType !== 'zigbee' && backupType !== 'jarvis' && backupType !== 'yahka' && backupType !== 'esphome') {
backupType = name.split('_')[0];
}

Expand Down Expand Up @@ -126,7 +126,7 @@ function restore(adapter, options, storageType, fileName, currentTheme, bashDir,
if (!err && fs.existsSync(toSaveName)) {
let backupType = name.split('.')[0];

if (backupType !== 'nodered' && backupType !== 'zigbee' && backupType !== 'jarvis' && backupType !== 'yahka') {
if (backupType !== 'nodered' && backupType !== 'zigbee' && backupType !== 'jarvis' && backupType !== 'yahka' && backupType !== 'esphome') {
backupType = name.split('_')[0];
}

Expand Down Expand Up @@ -336,7 +336,7 @@ if (typeof module !== "undefined" && module.parent) {
},
exit: function (exitCode) {
writeIntoFile(logName, `[EXIT] ${exitCode}`);
if (exitCode == 0 || exitCode == 'mysql restore done' || exitCode == 'sqlite restore done' || exitCode == 'redis restore done' || exitCode == 'historyDB restore done' || exitCode == 'zigbee database restore done' || exitCode == 'node-red restore done' || exitCode == 'yahka database restore done' || exitCode == 'jarvis database restore done' || exitCode == 'influxDB restore done' || exitCode == 'postgresql restore done' || exitCode == 'Grafana restore done' || exitCode == 'javascript restore done') {
if (exitCode == 0 || exitCode == 'mysql restore done' || exitCode == 'sqlite restore done' || exitCode == 'redis restore done' || exitCode == 'historyDB restore done' || exitCode == 'zigbee database restore done' || exitCode == 'ESPHome data restore done' || exitCode == 'node-red restore done' || exitCode == 'yahka database restore done' || exitCode == 'jarvis database restore done' || exitCode == 'influxDB restore done' || exitCode == 'postgresql restore done' || exitCode == 'Grafana restore done' || exitCode == 'javascript restore done') {
logWebIF += `[EXIT] ${exitCode} **** Restore completed successfully!! ****\n`;
statusColor = '#7fff00';
restoreStatus = 'Restore completed successfully!! Starting iobroker... Please wait!';
Expand Down
Loading

0 comments on commit 956f654

Please sign in to comment.