Network UPS Tools. Synology. How to run the NUT client in OS Home Assistant

The essence of the problem and why is it necessary?

On Synology, usb and upscmd interact with upsd using a client/server model. Unfortunately, pscd is not available in the Synology Disk Station Manager (DSM) operating system. Reading Synology NAS Beep or Problems with the UPS server after updating DSM 6.2.4-25556.

To use such a command, connecting with OS Home Assistant to NAS Synology, we will not be able to call the command. We will be notified of the error.

ssh [email protected] -p 330 upscmd -u hassmon -p 12345678 ups@localhost:3493 beeper.enable

You can only get the sensor status

ssh [email protected] -p 330 upsc ups@localhost

If you try in OS Home Assistant, run upsc via SSH [email protected], then you will receive a similar message that there is no such command

image

When you try to install the net package apc add nut, you will receive a message that there is no such package

image


A solution to the problem

In order to install the nut client, you need to open repositories at the path /etc/apt/repositories and add links to test and edge repositories

image
image

http://nl.alpinelinux.org/alpine/edge/main
http://nl.alpinelinux.org/alpine/edge/community
http://nl.alpinelinux.org/alpine/edge/testing

After the links have been added, you can now install the NUT package with the apt add nut command

Important! After you add the links to '/etc/apt/repositories` and install the ‘nut’ package, then it will work until you completely restart the OS Home Assistant. For understanding: when we completely reboot OS Home Assistant, OS Home Assistant restores everything to the original and all our settings and packages will be erased and deleted, and we will have to perform the procedure again. The problem can be solved by running the script, but we will run the script not using shell_command, but using the SSH & Web Terminal addon itself.

Let’s create a script that will check the repositories file along the path /etc/apk/repositories and if there are no links from the extreme version, then it will add 3 links to the extreme and test versions for downloading and installing the `nut’ package, and also check whether the ‘nut’ package is installed, if the ‘nut’ package is installed, the script will skip this step and will not install the ‘nut’ package. This script should be placed in automation when loading Home Assistant. He will check it every time and if the Home Assistant will overwrite everything, then the script will install everything.

1) Create the scripts folder in the config folder

mkdir /config/scripts

2) Create a file with the name install_nut.sh

touch /config/scripts/install_nut.sh

3) Open the file install_nut.sh

nano /config/scripts/install_nut.sh

4) Add the following to the file

#!/bin/bash

FILENAME=/etc/apk/repositories
if [ `grep -l "nl.alpinelinux.org" $FILENAME` ]; then
  echo "Everything is fine. There is no need to add links to the repository"
else
  echo "Oops. Home Assistant deleted everything. Now we will add links to the repository"
  sleep 2
cat <<_EOF_ >> /etc/apk/repositories
http://nl.alpinelinux.org/alpine/edge/main
http://nl.alpinelinux.org/alpine/edge/community
http://nl.alpinelinux.org/alpine/edge/testing
_EOF_
  echo "Done"
fi


apk -e info nut > /etc/apk/packages.txt
FILENAME=/etc/apk/packages.txt
if [ `grep -w "nut" $FILENAME` ]; then
  echo "Everything is fine. You do not need to install the NUT package"
else
  echo "Oops. Home Assistant deleted everything. Now we will install the NUT package"
  apk add nut
  echo "Done"
fi

5) Let’s create a script to run the script install_nut.sh using the SSH & Web Terminal addon

alias: Installing NUT
sequence:
  - service: hassio.addon_stdin
    data:
      addon: a0d7b954_ssh
      input: /config/scripts/install_nut.sh
mode: single

Before creating a script, you can check the script launch install_nut.sh through the service using the addon SSH & Web Terminal


Sound alert switch

Examples of how to use these services to turn on or off the sound

Turn on the sound

service: hassio.addon_stdin
data:
  addon: a0d7b954_ssh
  input: upscmd -u hassmon -p 12345678 [email protected]:3493 beeper.enable

Turn off the sound

service: hassio.addon_stdin
data:
  addon: a0d7b954_ssh
  input: upscmd -u hassmon -p 12345678 [email protected]:3493 beeper.disable

Example of a switch using integration Template Switch

switch: 
  - platform: template
    switches:
      ups_beeper:
        friendly_name: 'Sound notification'
        value_template: '{{ is_state("sensor.ups_beeper_status","enabled") }}'
        turn_on:
          service: hassio.addon_stdin
          data:
            addon: a0d7b954_ssh
            input: upscmd -u hassmon -p 12345678 [email protected]:3493 beeper.enable
        turn_off:
          service: hassio.addon_stdin
          data:
            addon: a0d7b954_ssh
            input: upscmd -u hassmon -p 12345678 [email protected]:3493 beeper.disable
        icon_template: >-
          {% if is_state("sensor.ups_beeper_status","enabled") %}
            mdi:volume-high
          {% else %}
            mdi:volume-off
          {% endif %}

Let’s add a card to Lovelace

I created this card for the UPS using several custom integrations

type: entities
entities:
  - type: custom:fold-entity-row
    head:
      entity: sensor.ups_cyberpower_livingroom
      name: UPS
      type: custom:multiple-entity-row
      secondary_info:
        attribute: Charge level
        name: Battery
        unit: '%'
      state_header: Status
      entities:
        - entity: group.livingroom_ups
          name: Sensors
          icon: mdi:information-outline
        - entity: sensor.ups_load
          name: Load
        - entity: sensor.ups_load_watts
          name: Load
    entities:
      - entity: switch.ups_beeper
        secondary_info: last-changed
        icon: mdi:volume-high
      - entity: switch.ups_test_battery_quick
        secondary_info: last-changed
        icon: mdi:battery
      - entity: switch.ups_test_battery_deep
        secondary_info: last-changed
        icon: mdi:battery

Let’s create sensors

Important! These sensors as an addition and are not mandatory, we do it at our discretion

  • The first sensor UPS Load Watts shows the load in watts, instead of %
  • The second sensor was created with the battery level attribute to display in the card as an attribute using custom integration Home Assistant. Multiple Entity Row

To understand what attribute we are talking about

  - type: custom:fold-entity-row
    head:
      entity: sensor.ups_cyberpower_livingroom
      name: ИБП
      type: custom:multiple-entity-row
      secondary_info:
        attribute: Charge level
        name: Battery
        unit: '%'

The sensors themselves

Important! In the line value_template: "{{ states('sensor.ups_load') | float(default=0) / 100 * 720 | round(0) }}" there is a figure 720.This figure means the power of your UPS. See the line ups.realpower.nominal: 720

To find out the power of the UPS, you can use the command

upsc [email protected] ups.realpower.nominal

Check the load sensor readings, for example, with the program WinNUTClient. You can download the WinNUTClient here

sensor:
  - platform: template
    sensors:
      ups_load_watts:
        friendly_name: UPS Load Watts
        unit_of_measurement: "W"
        value_template: "{{ states('sensor.ups_load') | float(default=0) / 100 * 720 | round(0) }}"

  - platform: template
    sensors:
      ups_cyberpower_livingroom:
        friendly_name: 'Room: UPS'
        icon_template: mdi:battery
        value_template: "{{ states('sensor.ups_status') }}"
        attribute_templates:
          Уровень заряда: "{{ states('sensor.ups_battery_charge') }}"

Let’s create a group of sensors

This group of sensors will be used in the UPS card, where it is enough to tap on the sensors icon and a list of UPS sensors will be displayed, which is very convenient.

livingroom_ups:
  name: "Room: UPS. Sensors"
  icon: mdi:battery
  all: false
  entities:
    - sensor.ups_battery_charge
    - sensor.ups_status
    - sensor.ups_beeper_status
    - sensor.ups_load
    - sensor.ups_load_watts
    - sensor.ups_nominal_real_power
    - sensor.ups_low_battery_setpoint
    - sensor.ups_warning_battery_setpoint
    - sensor.ups_input_voltage
    - sensor.ups_output_voltage
    - sensor.ups_low_voltage_transfer
    - sensor.ups_high_voltage_transfer
    - sensor.ups_battery_voltage
    - sensor.ups_nominal_battery_voltage
    - sensor.ups_nominal_input_voltage
    - sensor.ups_ups_shutdown_delay
    - sensor.ups_load_restart_delay
    - sensor.ups_battery_runtime
    - sensor.ups_self_test_result
    - sensor.ups_low_battery_runtime
    - sensor.ups_load_start_timer
    - sensor.ups_load_shutdown_timer
    - sensor.ups_battery_chemistry
    - sensor.ups_status_data
    - sensor.ups_battery_manuf_date
Текст на русском (Text in Russian)

Network UPS Tools. Как запустить в OS Home Assistant клиент NUT

Суть проблемы и зачем это нужно?

На Synology upsc и upscmd взаимодействуют с upsd, используя модель клиент/сервер. К сожалению, upsmcd недоступен в операционной системе Synology DiskStation Manager (DSM). Читаем Synology NAS beeper или Problems with UPS Server after DSM 6.2.4-25556 update.

Использовать такую команду, подключившись с OS Home Assistant к NAS Synology, у нас не получится вызвать команду. Нам сообщат об ошибке.

ssh [email protected] -p 330 upscmd -u hassmon -p 12345678 ups@localhost:3493 beeper.enable

Можно получить только статус сенсора

ssh [email protected] -p 330 upsc ups@localhost

Если попытаетесь в OS Home Assistant, через SSH запустить upsc [email protected], то получите подобное сообщение, что такой команды нет

image

При попытке установить пакет nut apk add nut получите сообщение, что такого пакета нет

image


Вариант решения проблемы

Для того, чтобы установить клиента nut, необходимо открыть repositories по пути /etc/apk/repositories и добавить ссылки на тестовые и крайние репозитории

image
image

http://nl.alpinelinux.org/alpine/edge/main
http://nl.alpinelinux.org/alpine/edge/community
http://nl.alpinelinux.org/alpine/edge/testing

После того как добавили ссылки, можно теперь установить пакет NUT командой apk add nut

Важно! После того, как вы добавите ссылки в /etc/apk/repositories и установите пакет nut, то это будет работать до тех пор, пока вы полностью не перезагрузите OS Home Assistant. Для понимания: когда мы полностью перезагружаем OS Home Assistant, то OS Home Assistant восстанавливает все к исходному и все наши настройки и пакеты будут стерты и удалены, и придется по новой выполнять процедуру. Проблему можно решить запуском скрипта, но, скрипт будем запускать не с помощью shell_command, а с помощью самого аддона SSH & Web Terminal.

Создадим скрипт который будет проверять файлик repositories по пути /etc/apk/repositories и если там не будут ссылки с крайней версии, то добавит добавит 3 ссылки на крайние и тестовые версии для скачивания и установки пакета nut, а также проверит установлен ли пакет nut, если пакет nut установлен, то скрипт пропустит этот шаг и не будет ставить пакет nut. Этот скрипт нужно поместить в автоматизацию при загрузке Home Assistant. Он будет каждый раз сверять и если Home Assistant все затрет, то скрипт все установит.

1) Создадим папку scripts в папке config

mkdir /config/scripts

2) Создадим файлик и именуем install_nut.sh

touch /config/scripts/install_nut.sh

3) Откроем файлик install_nut.sh

nano /config/scripts/install_nut.sh

4) Добавим в файлик следующее

#!/bin/bash

FILENAME=/etc/apk/repositories
if [ `grep -l "nl.alpinelinux.org" $FILENAME` ]; then
  echo "Все отлично. Ссылки в репозитории добавлять не нужно"
else
  echo "Упс. Home Assistant все удалил. Сейчас добавим ссылки в репозитории"
  sleep 2
cat <<_EOF_ >> /etc/apk/repositories
http://nl.alpinelinux.org/alpine/edge/main
http://nl.alpinelinux.org/alpine/edge/community
http://nl.alpinelinux.org/alpine/edge/testing
_EOF_
  echo "Готово"
fi


apk -e info nut > /etc/apk/packages.txt
FILENAME=/etc/apk/packages.txt
if [ `grep -w "nut" $FILENAME` ]; then
  echo "Все отлично. Cтавить пакет NUT не требуется"
else
  echo "Упс. Home Assistant все удалил. Сейчас установим пакет NUT"
  apk add nut
  echo "Готово"
fi

5) Создадим скрипт на запуск скрипта install_nut.sh используя аддон SSH & Web Terminal

alias: Установка NUT
sequence:
  - service: hassio.addon_stdin
    data:
      addon: a0d7b954_ssh
      input: /config/scripts/install_nut.sh
mode: single

Перед созданием скрипта, можно проверить запуск скрипта install_nut.sh через службу, используя аддон SSH & Web Terminal


Выключатель звукового оповещения

Примеры как использовать данные службы для включения или выключения звука

Включаем звук

service: hassio.addon_stdin
data:
  addon: a0d7b954_ssh
  input: upscmd -u hassmon -p 12345678 [email protected]:3493 beeper.enable

Выключаем звук

service: hassio.addon_stdin
data:
  addon: a0d7b954_ssh
  input: upscmd -u hassmon -p 12345678 [email protected]:3493 beeper.disable

Пример выключателя с помощью интеграции Template Switch

switch: 
  - platform: template
    switches:
      ups_beeper:
        friendly_name: 'Звуковое оповещение'
        value_template: '{{ is_state("sensor.ups_beeper_status","enabled") }}'
        turn_on:
          service: hassio.addon_stdin
          data:
            addon: a0d7b954_ssh
            input: upscmd -u hassmon -p 12345678 [email protected]:3493 beeper.enable
        turn_off:
          service: hassio.addon_stdin
          data:
            addon: a0d7b954_ssh
            input: upscmd -u hassmon -p 12345678 [email protected]:3493 beeper.disable
        icon_template: >-
          {% if is_state("sensor.ups_beeper_status","enabled") %}
            mdi:volume-high
          {% else %}
            mdi:volume-off
          {% endif %}

Добавим карточку в Lovelace

Данную карточку для ИБП я создал с использованием нескольких пользовательских интеграции

type: entities
entities:
  - type: custom:fold-entity-row
    head:
      entity: sensor.ups_cyberpower_livingroom
      name: ИБП
      type: custom:multiple-entity-row
      secondary_info:
        attribute: Уровень заряда
        name: Батарея
        unit: '%'
      state_header: Статус
      entities:
        - entity: group.livingroom_ups
          name: Сенсоры
          icon: mdi:information-outline
        - entity: sensor.ups_load
          name: Нагрузка
        - entity: sensor.ups_load_watts
          name: Нагрузка
    entities:
      - entity: switch.ups_beeper
        secondary_info: last-changed
        icon: mdi:volume-high
      - entity: switch.ups_test_battery_quick
        secondary_info: last-changed
        icon: mdi:battery
      - entity: switch.ups_test_battery_deep
        secondary_info: last-changed
        icon: mdi:battery

Создадим сенсоры

Важно! Данные сенсоры как дополнение и не являются обязательными, делаем на свое усмотрение

  • Первый сенсор UPS Load Watts показывает нагрузку в ваттах, вместо %
  • Второй сенсор создал с аттрибутом уровня заряда батареи, чтобы вывести в карточке как аттрибут, используя пользовательскую интеграцию Home Assistant. Multiple Entity Row

Для понимания о каком аттрибуте идет речь

  - type: custom:fold-entity-row
    head:
      entity: sensor.ups_cyberpower_livingroom
      name: ИБП
      type: custom:multiple-entity-row
      secondary_info:
        attribute: Уровень заряда
        name: Батарея
        unit: '%'

Сами сенсоры

Важно! В строке value_template: "{{ states('sensor.ups_load') | float(default=0) / 100 * 720 | round(0) }}" есть цифра 720. Это цифра означает мощность вашего ИБП. Смотрите строку ups.realpower.nominal: 720

Узнать мощность ИБП можно командой

upsc [email protected] ups.realpower.nominal

Сверяйте показания сенсора нагрузки, например с программой WinNUT-Client. Скачать WinNUT-Client можно здесь

sensor:
  - platform: template
    sensors:
      ups_load_watts:
        friendly_name: UPS Load Watts
        unit_of_measurement: "W"
        value_template: "{{ states('sensor.ups_load') | float(default=0) / 100 * 720 | round(0) }}"

  - platform: template
    sensors:
      ups_cyberpower_livingroom:
        friendly_name: 'Гостиная: ИБП'
        icon_template: mdi:battery
        value_template: "{{ states('sensor.ups_status') }}"
        attribute_templates:
          Уровень заряда: "{{ states('sensor.ups_battery_charge') }}"

Создадим группу сенсоров

Это группа сенсоров будет применяться в карточке для ИБП, где достаточно тапнуть на иконку сенсоры и будет отображаться список сеноров ИБП, что очень удобно.

livingroom_ups:
  name: "Гостиная: ИБП. Сенсоры"
  icon: mdi:battery
  all: false
  entities:
    - sensor.ups_battery_charge
    - sensor.ups_status
    - sensor.ups_beeper_status
    - sensor.ups_load
    - sensor.ups_load_watts
    - sensor.ups_nominal_real_power
    - sensor.ups_low_battery_setpoint
    - sensor.ups_warning_battery_setpoint
    - sensor.ups_input_voltage
    - sensor.ups_output_voltage
    - sensor.ups_low_voltage_transfer
    - sensor.ups_high_voltage_transfer
    - sensor.ups_battery_voltage
    - sensor.ups_nominal_battery_voltage
    - sensor.ups_nominal_input_voltage
    - sensor.ups_ups_shutdown_delay
    - sensor.ups_load_restart_delay
    - sensor.ups_battery_runtime
    - sensor.ups_self_test_result
    - sensor.ups_low_battery_runtime
    - sensor.ups_load_start_timer
    - sensor.ups_load_shutdown_timer
    - sensor.ups_battery_chemistry
    - sensor.ups_status_data
    - sensor.ups_battery_manuf_date
2 Likes

Rather than doing all of that, as you are using Home Assistant OS, just install and configure the NUT addon. Then install the NUT integration.

Integration of Network UPS Tools does not know how to control the UPS, only receive data from sensors. The Network UPS Tools addon itself also does not know how to control the UPS, only data from sensors, which was reported by the author of the addon himself addon-nut. The UPS has commands that can be sent and controlled by the UPS, but you can’t put the nat client on CHAOS, because there are no links to the repo and all this is erased after a full reboot of the host.

There is not even a load sensor in watts, which is also the authors unsubscribed, that they say, do the sensor yourself in the templates

List of commands
  • load.off - Turn off the load immediately
  • load.on - Turn on the load immediately
  • load.off.delay - Turn off the load possibly after a delay
  • load.on.delay - Turn on the load possibly after a delay
  • shutdown.return - Turn off the load possibly after a delay and return when power is back
  • shutdown.stayoff - Turn off the load possibly after a delay and remain off even if power returns
  • shutdown.stop - Stop a shutdown in progress
  • shutdown.reboot - Shut down the load briefly while rebooting the UPS
  • shutdown.reboot.graceful - After a delay, shut down the load briefly while rebooting the UPS
  • test.panel.start - Start testing the UPS panel
  • test.panel.stop - Stop a UPS panel test
  • test.failure.start - Start a simulated power failure
  • test.failure.stop - Stop simulating a power failure
  • test.battery.start - Start a battery test
  • test.battery.start.quick - Start a “quick” battery test
  • test.battery.start.deep - Start a “deep” battery test
  • test.battery.stop - Stop the battery test
  • calibrate.start - Start runtime calibration
  • calibrate.stop - Stop runtime calibration
  • beeper.disable - Disable UPS beeper/buzzer
  • beeper.enable - Enable UPS beeper/buzzer
  • beeper.mute - Temporarily mute UPS beeper/buzzer
  • beeper.off - Turn off UPS beeper/buzzer
  • beeper.on - Turn on UPS beeper/buzzer
  • bypass.start - Put the UPS in bypass mode
  • bypass.stop - Take the UPS out of bypass mode

If you have another way to control the UPS. then I ask you to share your version

Documentation about commands

https://networkupstools.org

1 Like

From the addon documentation:

Maybe I misunderstood the author, but as the author of the addon, I was informed that in my case it does not work.

Answers from the author

Answers from the author №1

Answers from the author №2

I have a UPS connected to Synology via USB, and Home Assistant runs on a virtual machine on Synology and I can’t use one USB UPS on two machines at the same time, here we either transfer USB to Synology or transfer it to Home Assistant. I chose to connect to Synology because Synology is more important and Synology itself puts Synology into safe mode there, and since I want to control the UPS and I can control many functions, and not just turn the sound on and off, I can’t use the addon as a server and use the usbhid-ups driver, because the UPS is not connected to the Home Assistant via USB

Below I attach options for the NUT addon settings and logs. I do not know already where to dig and how it can be made to work on the addon and where are these services in the Home Assistant that would allow sending commands to the UPS? Where is this upscmd? Do you have any thoughts on how you can send a command to the UPS with Home Assistant? Can you show a working example?

If I specify such configurations in the addon using the server mode, then there will be such entries in the logs

Configurations in the NUT addon

devices:
  - config: []
    driver: snmp-ups
    name: ups
    port: 192.168.1.200
mode: netserver
shutdown_host: 'false'
users:
  - actions: []
    instcmds:
      - all
    password: nutuser
    username: nut2user

Log entries

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] nut: applying... 
[fix-attrs.d] nut: exited 0.
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Add-on: Network UPS Tools
 Manage battery backup (UPS) devices
-----------------------------------------------------------
 Add-on version: 0.9.0
 You are running the latest version of this add-on.
 System: Home Assistant OS 6.6  (amd64 / qemux86-64)
 Home Assistant Core: 2021.11.5
 Home Assistant Supervisor: 2021.10.8
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] nut.sh: executing... 
[15:42:49] INFO: Setting mode to netserver...
[15:42:49] INFO: Generating /etc/nut/upsd.users...
[15:42:49] INFO: Configuring user: nut2user
[15:42:49] INFO: Password is NOT in the Have I Been Pwned database! Nice!
[15:42:49] INFO: Configuring Device named ups...
[15:42:50] INFO: Starting the UPS drivers...
Created directory: /var/lib/snmp/cert_indexes
Startup timer elapsed, continuing...
Network UPS Tools - UPS driver controller 2.7.4
[cont-init.d] nut.sh: exited 1.
[cont-finish.d] executing container finish scripts...
[cont-finish.d] 99-message.sh: executing... 
-----------------------------------------------------------
                Oops! Something went wrong.

 We are so sorry, but something went terribly wrong when
 starting or running this add-on.
 
 Be sure to check the log above, line by line, for hints.
-----------------------------------------------------------
[cont-finish.d] 99-message.sh: exited 0.
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
If I specify such configurations in the addon using client mode, then there will be such entries in the logs

Configurations in the NUT addon

As I read that by specifying ‘remote_ups_’ in the config, then everything above 'remote_ups_’ is ignored

devices:
  - config: []
    driver: snmp-ups
    name: ups
    port: 192.168.1.200
mode: netclient
shutdown_host: 'false'
users:
  - actions:
      - set
      - fsd
    instcmds:
      - all
    password: nutuser
    username: nut!user
remote_ups_host: 192.168.1.200
remote_ups_name: ups
remote_ups_user: hassmon
remote_ups_password: '12345678'

Log entries

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] nut: applying... 
[fix-attrs.d] nut: exited 0.
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Add-on: Network UPS Tools
 Manage battery backup (UPS) devices
-----------------------------------------------------------
 Add-on version: 0.9.0
 You are running the latest version of this add-on.
 System: Home Assistant OS 6.6  (amd64 / qemux86-64)
 Home Assistant Core: 2021.11.5
 Home Assistant Supervisor: 2021.10.8
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] nut.sh: executing... 
[15:47:49] INFO: Setting mode to netclient...
[cont-init.d] nut.sh: exited 0.
[cont-init.d] nutclient.sh: executing... 
[cont-init.d] nutclient.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[15:47:49] INFO: Starting the UPS monitor and shutdown controller...
   0.000000	fopen /run/nut/upsmon.pid: No such file or directory
   0.000243	Using power down flag file /etc/killpower
   0.000403	UPS: [email protected] (slave) (power value 1)
   0.000515	debug level is '1'
   0.000597	Warning: running as one big root process by request (upsmon -p)
   0.000846	Init SSL without certificate database
   0.001785	Trying to connect to UPS [[email protected]]
   0.081460	Logged into UPS [email protected]

I check access to the UPS via the SSH console, there is no nut package and I can’t connect


Текст на русском (Text in Russian)

Может я неправильно понял автора, но как автор аддона мне сообщил, что в моем случае это не работает.

Ответы от автора

Ответ от автора №1

Ответ от автора №2

У меня ИБП подключен к Synology по USB, а Home Assistant работает на виртуальной машине на Synology и я не могу использовать одновременно один USB ИБП на двух машинах, тут или USB перекидываем в Synology или перекидываем в Home Assistant. Я выбрал подключить к Synology, потому что Synology важнее и там Synology сама переводит Synology в безопасный режим, а так как мне хочется управлять ИБП и я могу управлять множествами функции, а не только включать и выключать звук, то я не могу использовать в аддоне как сервер и использовать драйвер usbhid-ups, потому что ИБП не подключен к Home Assistant по USB

Ниже прикладываю варианты настроек аддона NUT и логи. Я не знаю уже куда копать и как это можно заставить работать на аддоне и где эти службы в Home Assistant, которые бы позволили отправлять команды в ИБП? Где этот upscmd? Есть ли у вас мысли, как можно с Home Assistant отправить команду на ИБП? Можете показать рабочий пример?

Если я указываю такие конфигурации в аддоне, используя режим сервера, то в логах будут такие записи

Конфигурации в аддоне NUT

devices:
  - config: []
    driver: snmp-ups
    name: ups
    port: 192.168.1.200
mode: netserver
shutdown_host: 'false'
users:
  - actions: []
    instcmds:
      - all
    password: nutuser
    username: nut2user

Записи в журнале

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] nut: applying... 
[fix-attrs.d] nut: exited 0.
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Add-on: Network UPS Tools
 Manage battery backup (UPS) devices
-----------------------------------------------------------
 Add-on version: 0.9.0
 You are running the latest version of this add-on.
 System: Home Assistant OS 6.6  (amd64 / qemux86-64)
 Home Assistant Core: 2021.11.5
 Home Assistant Supervisor: 2021.10.8
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] nut.sh: executing... 
[15:42:49] INFO: Setting mode to netserver...
[15:42:49] INFO: Generating /etc/nut/upsd.users...
[15:42:49] INFO: Configuring user: nut2user
[15:42:49] INFO: Password is NOT in the Have I Been Pwned database! Nice!
[15:42:49] INFO: Configuring Device named ups...
[15:42:50] INFO: Starting the UPS drivers...
Created directory: /var/lib/snmp/cert_indexes
Startup timer elapsed, continuing...
Network UPS Tools - UPS driver controller 2.7.4
[cont-init.d] nut.sh: exited 1.
[cont-finish.d] executing container finish scripts...
[cont-finish.d] 99-message.sh: executing... 
-----------------------------------------------------------
                Oops! Something went wrong.

 We are so sorry, but something went terribly wrong when
 starting or running this add-on.
 
 Be sure to check the log above, line by line, for hints.
-----------------------------------------------------------
[cont-finish.d] 99-message.sh: exited 0.
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
Если я указываю такие конфигурации в аддоне, используя режим клиент, то в логах будут такие записи

Конфигурации в аддоне NUT

Как я прочел, что указав в конфиге remote_ups_*, то все, что выше remote_ups_*, это все игнорируется

devices:
  - config: []
    driver: snmp-ups
    name: ups
    port: 192.168.1.200
mode: netclient
shutdown_host: 'false'
users:
  - actions:
      - set
      - fsd
    instcmds:
      - all
    password: nutuser
    username: nut!user
remote_ups_host: 192.168.1.200
remote_ups_name: ups
remote_ups_user: hassmon
remote_ups_password: '12345678'

Записи в журнале

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] nut: applying... 
[fix-attrs.d] nut: exited 0.
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Add-on: Network UPS Tools
 Manage battery backup (UPS) devices
-----------------------------------------------------------
 Add-on version: 0.9.0
 You are running the latest version of this add-on.
 System: Home Assistant OS 6.6  (amd64 / qemux86-64)
 Home Assistant Core: 2021.11.5
 Home Assistant Supervisor: 2021.10.8
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] nut.sh: executing... 
[15:47:49] INFO: Setting mode to netclient...
[cont-init.d] nut.sh: exited 0.
[cont-init.d] nutclient.sh: executing... 
[cont-init.d] nutclient.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[15:47:49] INFO: Starting the UPS monitor and shutdown controller...
   0.000000	fopen /run/nut/upsmon.pid: No such file or directory
   0.000243	Using power down flag file /etc/killpower
   0.000403	UPS: [email protected] (slave) (power value 1)
   0.000515	debug level is '1'
   0.000597	Warning: running as one big root process by request (upsmon -p)
   0.000846	Init SSL without certificate database
   0.001785	Trying to connect to UPS [[email protected]]
   0.081460	Logged into UPS [email protected]

Проверяю доступ к ИБП через консоль SSH, пакета nut нет и подключиться не могу

You may need access to NUT container

It seems to me that you do not understand the essence of why I posted such a solution. I’m not going to connect the UPS to Home Assistnat, because Home Assistnat is running on a virtual machine in Synology and in case of a power outage Synology will turn off the virtual machine with Home Assistnat and put Synology in safe mode, and then turn off. This is the correct and safe shutdown of the NAS. If I connect the UPS directly to the NUT addon, then it will be stupid and in the event of a power outage Synology will not be able to put everything into safe mode and shut down

If you have something else, then please give it with examples and how do you think it will work?

Nut server in synology.

Nut client in HA (not the addon).

If it work I dont know

In my case HA NUT shutdown VM, then release the usb driver. And my server Windows take control of UPS…

Please read everything here from beginning to end and you will understand that the integration of NUT through the GUI does not send commands, but only receives sensors

Yes I know. For that your solution or other is needed.

I dont know how containers work.

But you can modify NUT container for your needs

Or do a feature request and wait…

I miss that too

At least do a self test…

I just tried to help

Any change to “nut docker container” will be lost in update.