{
"actions": [
{
"conditions": [],
"else": [],
"then": [
{
"message": "Попытка проверить наличие обновлений списка пакетов.",
"type": "telegram"
},
{
"delay": "1",
"type": "delay"
},
{
"command": "opkg update > /tmp/opkgupdate.txt",
"type": "shell"
},
{
"delay": "1",
"type": "delay"
},
{
"command": "#!/bin/sh\n\n# Создание уникальных временных файлов\nALL_PKGS=$(mktemp /tmp/opkg_all_pkgs_XXXXXX)\nHOMED_TMP=$(mktemp /tmp/opkg_homed_pkgs_XXXXXX)\nOTHER_TMP=$(mktemp /tmp/opkg_other_pkgs_XXXXXX)\n\n# Получаем список всех пакетов\nopkg list-upgradable | awk '{print $1}' > \"$ALL_PKGS\"\n\n# Параллельная фильтрация\n{\n grep '^homed-' \"$ALL_PKGS\" > \"$HOMED_TMP\"\n grep -v '^homed-' \"$ALL_PKGS\" > \"$OTHER_TMP\"\n} & wait\n\n# Функция для проверки и вывода\nprint_section() {\n echo \"$1\" # Выводим заголовок\n if [ -s \"$2\" ]; then\n sort \"$2\"\n else\n echo \"Нет доступных обновлений. Проверьте актуальность списка пакетов с помощью 'opkg update'\"\n fi\n echo\n}\n\n# Формируем итоговый вывод\n(\n print_section \"Пакеты HOMEd:\" \"$HOMED_TMP\"\n print_section \"Остальные пакеты OpenWRT:\" \"$OTHER_TMP\"\n) | tee /tmp/opkglistupgradable.txt\n\n# Удаление временных файлов\nrm \"$ALL_PKGS\" \"$HOMED_TMP\" \"$OTHER_TMP\"",
"type": "shell"
},
{
"conditions": [
{
"equals": "_NULL_",
"pattern": "{{ shellOutput }}",
"type": "pattern"
}
],
"else": [
{
"file": "/tmp/opkglistupgradable.txt",
"message": "Эти пакеты могут быть обновлены",
"type": "telegram"
}
],
"then": [
{
"file": "/tmp/opkgupdate.txt",
"message": "Нет паектов для обновления",
"type": "telegram"
}
],
"type": "condition"
},
{
"delay": "1",
"type": "delay"
},
{
"keyboard": "Обновление пакетов: UpgradePackages\nПринудительная переустановка пакетов: ReinstallPackages",
"message": "Обновляем пакеты или переустанавливаем?",
"type": "telegram"
}
],
"triggerName": "opkg_update",
"type": "condition"
},
{
"conditions": [],
"else": [],
"then": [
{
"message": "Попытка обновить все пакеты OpenWRT.",
"type": "telegram"
},
{
"command": "opkg list-upgradable | cut -f 1 -d ' ' | grep -v '^homed-automation$' | xargs -r opkg upgrade > /tmp/opkginstallall.txt",
"type": "shell"
},
{
"delay": "2",
"type": "delay"
},
{
"file": "/tmp/opkginstallall.txt",
"message": "Эти пакеты обновлены\nЕсли в списке обновления был homed-automaton, то сейчас начнётся его обновление.",
"type": "telegram"
},
{
"command": "opkg list-upgradable | cut -f1 -d ' ' | grep -q '^homed-automation$' && opkg upgrade homed-automation",
"type": "shell"
},
{
"conditions": [
{
"equals": "_NULL_",
"pattern": "{{ shellOutput }}",
"type": "pattern"
}
],
"else": [
{
"message": "{{ shellOutput }}",
"type": "telegram"
}
],
"then": [],
"type": "condition"
}
],
"triggerName": "all_packages",
"type": "condition"
},
{
"conditions": [],
"else": [],
"then": [
{
"command": "opkg list-upgradable | awk '/^homed-/ && $1 !~ /^(homed-common|homed-qt)$/ {\n sub(/^homed-/, \"\", $1); \n packages = packages (packages ? \", \" : \"\") $1; \n count++\n if (count % 3 == 0) {\n print packages; \n packages = \"\"\n }\n} \nEND {\n if (packages != \"\") print packages\n}'",
"type": "shell"
},
{
"conditions": [
{
"equals": null,
"pattern": "{{ shellOutput }}",
"type": "pattern"
}
],
"else": [
{
"keyboard": "{{ shellOutput }}\nОбновить все пакеты HOMEd: all HOMEd\nОбновить все пакеты OpenWRT: all packages",
"message": "Что обновить?",
"type": "telegram"
}
],
"then": [
{
"keyboard": "Обновить список пакетов: /opkgupdate\nОбновить все пакеты HOMEd: all HOMEd\nОбновить все пакеты OpenWRT: all packages",
"message": "Похоже, пакеты HOMEd для обновления отсутствуют. Пожалуйста, нажмите кнопку \"Обновить список пакетов\", чтобы проверить наличие актуальных версий. Либо нажмите \"Обновить все пакеты OpenWRT\", если они были доступны в файле opkglistupgradable.txt , что был отправлен ранее.",
"type": "telegram"
}
],
"type": "condition"
}
],
"triggerName": "opkg_update_upgrade",
"type": "condition"
},
{
"conditions": [],
"else": [],
"then": [
{
"command": "opkg list-installed | awk '/^homed-/ && $1 !~ /^(homed-common|homed-qt)$/ {\n sub(/^homed-/, \"\", $1);\n pkg = $1 \": \" $1 \" reinstall\";\n if (packages == \"\") {\n packages = pkg\n } else {\n packages = packages \", \" pkg\n }\n count++\n if (count % 3 == 0) {\n print packages;\n packages = \"\"\n }\n}\nEND {\n if (packages != \"\") print packages\n}'",
"type": "shell"
},
{
"keyboard": "{{ shellOutput }}\nвсе пакеты HOMEd кроме automation: all homed reinstall",
"message": "Что принудительно переустановить?",
"type": "telegram"
}
],
"triggerName": "opkg_update_reinstall",
"type": "condition"
},
{
"conditions": [],
"else": [],
"then": [
{
"message": "Попытка обновить пакет homed-zigbee.",
"type": "telegram"
},
{
"command": "#!/bin/sh\nLOG_FILE=\"/tmp/opkg_zigbee_update.txt\"\n{\n echo \"[$(date +%H:%M:%S)] Проверка обновлений homed-zigbee\"\n if opkg list-upgradable | grep -q '^homed-zigbee '; then\n echo \"Найдено обновление\"\n opkg upgrade homed-zigbee\n echo \"Статус: успешно\"\n else\n echo \"Доступных обновлений homed-zigbee в списке пакетов нет. Попробуйте обновить список пакетов!\"\n fi\n echo \"[$(date +%H:%M:%S)] Завершено\"\n} | tee -a \"$LOG_FILE\"\nsed 's/[][*_`#]/\\\\&/g; s/^\\[[0-9:]*\\] //' \"$LOG_FILE\" > \"${LOG_FILE}.telegram\"",
"type": "shell"
},
{
"message": "`\n{{ shellOutput }}\n`",
"type": "telegram"
}
],
"triggerName": "zigbee",
"type": "condition"
},
{
"conditions": [],
"else": [],
"then": [
{
"message": "Попытка обновить пакет homed-web.",
"type": "telegram"
},
{
"command": "#!/bin/sh\nLOG_FILE=\"/tmp/opkg_web_update.txt\"\n{\n echo \"[$(date +%H:%M:%S)] Проверка обновлений homed-web\"\n if opkg list-upgradable | grep -q '^homed-web '; then\n echo \"Найдено обновление\"\n opkg upgrade homed-web\n echo \"Статус: успешно\"\n else\n echo \"Доступных обновлений homed-web в списке пакетов нет. Попробуйте обновить список пакетов!\"\n fi\n echo \"[$(date +%H:%M:%S)] Завершено\"\n} | tee -a \"$LOG_FILE\"\nsed 's/[][*_`#]/\\\\&/g; s/^\\[[0-9:]*\\] //' \"$LOG_FILE\" > \"${LOG_FILE}.telegram\"",
"type": "shell"
},
{
"message": "`\n{{ shellOutput }}\n`",
"type": "telegram"
}
],
"triggerName": "web",
"type": "condition"
},
{
"conditions": [],
"else": [],
"then": [
{
"message": "Попытка обновить пакет homed-custom.",
"type": "telegram"
},
{
"command": "#!/bin/sh\nLOG_FILE=\"/tmp/opkg_custom_update.txt\"\n{\n echo \"[$(date +%H:%M:%S)] Проверка обновлений homed-custom\"\n if opkg list-upgradable | grep -q '^homed-custom '; then\n echo \"Найдено обновление\"\n opkg upgrade homed-custom\n echo \"Статус: успешно\"\n else\n echo \"Доступных обновлений homed-custom в списке пакетов нет. Попробуйте обновить список пакетов!\"\n fi\n echo \"[$(date +%H:%M:%S)] Завершено\"\n} | tee -a \"$LOG_FILE\"\nsed 's/[][*_`#]/\\\\&/g; s/^\\[[0-9:]*\\] //' \"$LOG_FILE\" > \"${LOG_FILE}.telegram\"",
"type": "shell"
},
{
"message": "`\n{{ shellOutput }}\n`",
"type": "telegram"
}
],
"triggerName": "custom",
"type": "condition"
},
{
"conditions": [],
"else": [],
"then": [
{
"message": "Попытка обновить пакет homed-automation.",
"type": "telegram"
},
{
"command": "#!/bin/sh\n\nLOG_FILE=\"/tmp/opkg_automation_update.txt\"\n\n{\n echo \"[$(date +%H:%M:%S)] Проверка обновлений homed-automation\"\n \n # Проверяем наличие пакета в списке обновлений\n if opkg list-upgradable | grep -q '^homed-automation '; then\n echo \"Найдено обновление\"\n opkg upgrade homed-automation\n echo \"Статус: успешно\"\n else\n echo \"Доступных обновлений homed-automation в списке пакетов нет. Попробуйте обновить список пакетов!\"\n fi\n \n echo \"[$(date +%H:%M:%S)] Завершено\"\n\n} | tee -a \"$LOG_FILE\"\n\n# Создаем версию для Telegram\nsed 's/[][*_`#]/\\\\&/g; s/^\\[[0-9:]*\\] //' \"$LOG_FILE\" > \"${LOG_FILE}.telegram\"",
"type": "shell"
},
{
"message": "`\n{{ shellOutput }}\n`",
"type": "telegram"
}
],
"triggerName": "automation",
"type": "condition"
},
{
"conditions": [],
"else": [],
"then": [
{
"message": "Попытка обновить homed-recorder.",
"type": "telegram"
},
{
"command": "#!/bin/sh\nLOG_FILE=\"/tmp/opkg_recorder_update.txt\"\n{\n echo \"[$(date +%H:%M:%S)] Проверка обновлений homed-recorder\"\n if opkg list-upgradable | grep -q '^homed-recorder '; then\n echo \"Найдено обновление\"\n opkg upgrade homed-recorder\n echo \"Статус: успешно\"\n else\n echo \"Доступных обновлений homed-recorder в списке пакетов нет. Попробуйте обновить список пакетов!\"\n fi\n echo \"[$(date +%H:%M:%S)] Завершено\"\n} | tee -a \"$LOG_FILE\"\nsed 's/[][*_`#]/\\\\&/g; s/^\\[[0-9:]*\\] //' \"$LOG_FILE\" > \"${LOG_FILE}.telegram\"",
"type": "shell"
},
{
"message": "`\n{{ shellOutput }}\n`",
"type": "telegram"
}
],
"triggerName": "recorder",
"type": "condition"
},
{
"conditions": [],
"else": [],
"then": [
{
"message": "Попытка обновить homed-modbus.",
"type": "telegram"
},
{
"command": "#!/bin/sh\nLOG_FILE=\"/tmp/opkg_modbus_update.txt\"\n{\n echo \"[$(date +%H:%M:%S)] Проверка обновлений homed-modbus\"\n if opkg list-upgradable | grep -q '^homed-modbus '; then\n echo \"Найдено обновление\"\n opkg upgrade homed-modbus\n echo \"Статус: успешно\"\n else\n echo \"Доступных обновлений homed-modbus в списке пакетов нет. Попробуйте обновить список пакетов!\"\n fi\n echo \"[$(date +%H:%M:%S)] Завершено\"\n} | tee -a \"$LOG_FILE\"\nsed 's/[][*_`#]/\\\\&/g; s/^\\[[0-9:]*\\] //' \"$LOG_FILE\" > \"${LOG_FILE}.telegram\"",
"type": "shell"
},
{
"message": "`\n{{ shellOutput }}\n`",
"type": "telegram"
}
],
"triggerName": "modbus",
"type": "condition"
},
{
"conditions": [],
"else": [],
"then": [
{
"message": "Попытка обновить homed-cloud.",
"type": "telegram"
},
{
"command": "#!/bin/sh\nLOG_FILE=\"/tmp/opkg_cloud_update.txt\"\n{\n echo \"[$(date +%H:%M:%S)] Проверка обновлений homed-cloud\"\n if opkg list-upgradable | grep -q '^homed-cloud '; then\n echo \"Найдено обновление\"\n opkg upgrade homed-cloud\n echo \"Статус: успешно\"\n else\n echo \"Доступных обновлений homed-cloud в списке пакетов нет. Попробуйте обновить список пакетов!\"\n fi\n echo \"[$(date +%H:%M:%S)] Завершено\"\n} | tee -a \"$LOG_FILE\"\nsed 's/[][*_`#]/\\\\&/g; s/^\\[[0-9:]*\\] //' \"$LOG_FILE\" > \"${LOG_FILE}.telegram\"",
"type": "shell"
},
{
"message": "`\n{{ shellOutput }}\n`",
"type": "telegram"
}
],
"triggerName": "cloud",
"type": "condition"
},
{
"conditions": [],
"else": [],
"then": [
{
"message": "Попытка обновить homed-custom-midea.",
"type": "telegram"
},
{
"command": "#!/bin/sh\nLOG_FILE=\"/tmp/opkg_custom_midea_update.txt\"\n{\n echo \"[$(date +%H:%M:%S)] Проверка обновлений homed-custom-midea\"\n if opkg list-upgradable | grep -q '^homed-custom-midea '; then\n echo \"Найдено обновление\"\n opkg upgrade homed-custom-midea\n echo \"Статус: успешно\"\n else\n echo \"Доступных обновлений homed-custom-midea в списке пакетов нет. Попробуйте обновить список пакетов!\"\n fi\n echo \"[$(date +%H:%M:%S)] Завершено\"\n} | tee -a \"$LOG_FILE\"\nsed 's/[][*_`#]/\\\\&/g; s/^\\[[0-9:]*\\] //' \"$LOG_FILE\" > \"${LOG_FILE}.telegram\"",
"type": "shell"
},
{
"message": "`\n{{ shellOutput }}\n`",
"type": "telegram"
}
],
"triggerName": "custom_midea",
"type": "condition"
},
{
"conditions": [],
"else": [],
"then": [
{
"message": "Попытка обновить пакеты HOMEd.",
"type": "telegram"
},
{
"command": "#!/bin/sh\n\nLOG_FILE=\"/tmp/opkginstallhomedall.txt\"\n\n{\n echo \"[$(date +%H:%M:%S)] Проверка списка обновлений\"\n \n PACKAGES=$(opkg list-upgradable | awk '/^homed-/ && !/homed-automation|homed-common|homed-qt/ {print $1}')\n \n if [ -z \"$PACKAGES\" ]; then\n echo \"Доступных обновлений пакетов HOMEd в списке пакетов нет. Попробуйте обновить список пакетов!\"\n exit 0\n fi\n\n echo \"Обновление:\"\n echo \"$PACKAGES\"\n opkg upgrade $PACKAGES\n echo \"[$(date +%H:%M:%S)] Готово\"\n\n} | tee -a \"$LOG_FILE\"\n\n# Создание версии для Telegram (экранирование + обрезка)\nsed 's/[][*_`#]/\\\\&/g; s/^\\[[0-9:]*\\] //' \"$LOG_FILE\" > \"${LOG_FILE}.telegram\"",
"type": "shell"
},
{
"message": "`\n{{ shellOutput }}\n`",
"type": "telegram"
},
{
"delay": "1",
"type": "delay"
},
{
"message": "Попытка обновления homed-automation",
"type": "telegram"
},
{
"command": "#!/bin/sh\n\nLOG_FILE=\"/tmp/opkg_automation_update.txt\"\n\n{\n echo \"[$(date +%H:%M:%S)] Проверка обновлений homed-automation\"\n \n # Проверяем наличие пакета в списке обновлений\n if opkg list-upgradable | grep -q '^homed-automation '; then\n echo \"Найдено обновление\"\n opkg upgrade homed-automation\n echo \"Статус: успешно\"\n else\n echo \"Доступных обновлений homed-automation в списке пакетов нет. Попробуйте обновить список пакетов!\"\n fi\n \n echo \"[$(date +%H:%M:%S)] Завершено\"\n\n} | tee -a \"$LOG_FILE\"\n\n# Создаем версию для Telegram\nsed 's/[][*_`#]/\\\\&/g; s/^\\[[0-9:]*\\] //' \"$LOG_FILE\" > \"${LOG_FILE}.telegram\"",
"type": "shell"
},
{
"message": "`\n{{ shellOutput }}\n`",
"type": "telegram"
}
],
"triggerName": "all_homed",
"type": "condition"
},
{
"conditions": [],
"else": [],
"then": [
{
"message": "Попытка принудительно переустановить homed-zigbee.",
"type": "telegram"
},
{
"command": "opkg install --force-reinstall homed-zigbee > /tmp/reinstallhomedzigbee.txt",
"type": "shell"
},
{
"file": "/tmp/reinstallhomedzigbee.txt",
"type": "telegram"
}
],
"triggerName": "zigbee_reinstall",
"type": "condition"
},
{
"conditions": [],
"else": [],
"then": [
{
"message": "Попытка принудительно переустановить homed-web.",
"type": "telegram"
},
{
"command": "opkg install --force-reinstall homed-web > /tmp/reinstallhomedweb.txt",
"type": "shell"
},
{
"file": "/tmp/reinstallhomedweb.txt",
"type": "telegram"
}
],
"triggerName": "web_reinstall",
"type": "condition"
},
{
"conditions": [],
"else": [],
"then": [
{
"message": "Попытка принудительно переустановить homed-custom.",
"type": "telegram"
},
{
"command": "opkg install --force-reinstall homed-custom > /tmp/reinstallhomedcustom.txt",
"type": "shell"
},
{
"file": "/tmp/reinstallhomedcustom.txt",
"type": "telegram"
}
],
"triggerName": "custom_reinstall",
"type": "condition"
},
{
"conditions": [],
"else": [],
"then": [
{
"message": "Попытка принудительно переустановить homed-automation.\nЗанимает чуть больше времени, чем с другими пакетами HOMEd.",
"type": "telegram"
},
{
"delay": "30",
"type": "delay"
},
{
"command": "opkg install --force-reinstall homed-automation > /tmp/reinstallhomedautomation.txt",
"type": "shell"
},
{
"file": "/tmp/reinstallhomedautomation.txt",
"type": "telegram"
}
],
"triggerName": "automation_reinstall",
"type": "condition"
},
{
"conditions": [],
"else": [],
"then": [
{
"message": "Попытка принудительно переустановить homed-recorder.",
"type": "telegram"
},
{
"command": "opkg install --force-reinstall homed-recorder > /tmp/reinstallhomedrecorder.txt",
"type": "shell"
},
{
"file": "/tmp/reinstallhomedrecorder.txt",
"type": "telegram"
}
],
"triggerName": "recorder_reinstall",
"type": "condition"
},
{
"conditions": [],
"else": [],
"then": [
{
"message": "Попытка принудительно переустановить homed-modbus.",
"type": "telegram"
},
{
"command": "opkg install --force-reinstall homed-modbus > /tmp/reinstallhomedmodbus.txt",
"type": "shell"
},
{
"file": "/tmp/reinstallhomedmodbus.txt",
"type": "telegram"
}
],
"triggerName": "modbus_reinstall",
"type": "condition"
},
{
"conditions": [],
"else": [],
"then": [
{
"message": "Попытка принудительно переустановить homed-custom-midea.",
"type": "telegram"
},
{
"command": "opkg install --force-reinstall homed-custom-midea > /tmp/reinstallhomedcustommidea.txt",
"type": "shell"
},
{
"file": "/tmp/reinstallhomedcustommidea.txt",
"type": "telegram"
}
],
"triggerName": "custom_midea_reinstall",
"type": "condition"
},
{
"conditions": [],
"else": [],
"then": [
{
"message": "Попытка принудительно переустановить все пакеты HOMEd, кроме homed-automaton.",
"type": "telegram"
},
{
"command": "#!/bin/sh\n\nLOG_FILE=\"/tmp/reinstallhomedall.txt\"\n\n{\n echo \"[$(date +%H:%M:%S)] Поиск HOMEd пакетов (исключая automation)\"\n \n PACKAGES=$(opkg list-installed | awk '/^homed-/ && !/homed-automation|homed-common|homed-qt/ {print $1}')\n \n if [ -z \"$PACKAGES\" ]; then\n echo \"Нет пакетов для переустановки\"\n exit 0\n fi\n\n echo \"Переустановка:\"\n echo \"$PACKAGES\"\n opkg install --force-reinstall $PACKAGES\n echo \"[$(date +%H:%M:%S)] Готово\"\n\n} | tee -a \"$LOG_FILE\"\n\n# Создание версии для Telegram\nsed 's/[][*_`#]/\\\\&/g; s/^\\[[0-9:]*\\] //' \"$LOG_FILE\" > \"${LOG_FILE}.telegram\"",
"type": "shell"
},
{
"file": "/tmp/reinstallhomedall.txt",
"message": "Эти пакеты переустановлены\nПереустановку homed-automation придётся выполнить отдельно, если это необходимо",
"type": "telegram"
}
],
"triggerName": "all_homed_reinstall",
"type": "condition"
}
],
"debounce": 1,
"note": "Обновления командами из телеграм с кнопками.\nОбновление запускается командой /opkgupdate\nБудет предложен вариант переустановки и вариант с принудительным обновлением.",
"restart": false,
"triggers": [
{
"message": "/opkgupdate",
"name": "opkg_update",
"type": "telegram"
},
{
"message": "zigbee",
"name": "zigbee",
"type": "telegram"
},
{
"message": "web",
"name": "web",
"type": "telegram"
},
{
"message": "custom",
"name": "custom",
"type": "telegram"
},
{
"message": "automation",
"name": "automation",
"type": "telegram"
},
{
"message": "recorder",
"name": "recorder",
"type": "telegram"
},
{
"message": "modbus",
"name": "modbus",
"type": "telegram"
},
{
"message": "cloud",
"name": "cloud",
"type": "telegram"
},
{
"message": "all HOMEd",
"name": "all_homed",
"type": "telegram"
},
{
"message": "custom-midea",
"name": "custom_midea",
"type": "telegram"
},
{
"message": "all packages",
"name": "all_packages",
"type": "telegram"
},
{
"message": "UpgradePackages",
"name": "opkg_update_upgrade",
"type": "telegram"
},
{
"message": "ReinstallPackages",
"name": "opkg_update_reinstall",
"type": "telegram"
},
{
"message": "zigbee reinstall",
"name": "zigbee_reinstall",
"type": "telegram"
},
{
"message": "web reinstall",
"name": "web_reinstall",
"type": "telegram"
},
{
"message": "custom reinstall",
"name": "custom_reinstall",
"type": "telegram"
},
{
"message": "automation reinstall",
"name": "automation_reinstall",
"type": "telegram"
},
{
"message": "recorder reinstall",
"name": "recorder_reinstall",
"type": "telegram"
},
{
"message": "modbus reinstall",
"name": "modbus_reinstall",
"type": "telegram"
},
{
"message": "cloud reinstall",
"name": "cloud_reinstall",
"type": "telegram"
},
{
"message": "custom-midea reinstall",
"name": "custom_midea_reinstall",
"type": "telegram"
},
{
"message": "all HOMEd reinstall",
"name": "all_homed_reinstall",
"type": "telegram"
}
],
"conditions": []
}