Python plugin: UPS Monitor
Moderator: leecollings
-
blackie
- Posts: 5
- Joined: Tuesday 19 November 2019 14:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: UPS Monitor
Hello,
I have installed this plugin to my RPi with Domoticz and local NUT installation.
In my home the UPS comes onbattery cca 2x per day for 1-2 seconds.
Seems the plugin is unable to detect these short power outages because plugin reads the actual UPS data every 60s.
I have an idea to use local NUT server script /usr/bin/upssched-cmd triggered after power status change to catch these short outages.
Can this python plugin be called somehow from upssched-cmd script to update Domoticz UPS sensors every time UPS status changes?
If i try to execute plugin manually from a shell i get an error:
root@OMV:/home/domoticz/plugins/NUT_UPS# python3 plugin.py
Traceback (most recent call last):
File "plugin.py", line 36, in <module>
import Domoticz
ModuleNotFoundError: No module named 'Domoticz'
Thanks in advance for help
I have installed this plugin to my RPi with Domoticz and local NUT installation.
In my home the UPS comes onbattery cca 2x per day for 1-2 seconds.
Seems the plugin is unable to detect these short power outages because plugin reads the actual UPS data every 60s.
I have an idea to use local NUT server script /usr/bin/upssched-cmd triggered after power status change to catch these short outages.
Can this python plugin be called somehow from upssched-cmd script to update Domoticz UPS sensors every time UPS status changes?
If i try to execute plugin manually from a shell i get an error:
root@OMV:/home/domoticz/plugins/NUT_UPS# python3 plugin.py
Traceback (most recent call last):
File "plugin.py", line 36, in <module>
import Domoticz
ModuleNotFoundError: No module named 'Domoticz'
Thanks in advance for help
-
Kyrille
- Posts: 14
- Joined: Sunday 19 January 2020 20:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.01
- Location: France
- Contact:
Re: Python plugin: UPS Monitor
Hello,
The plugin is working fine in my environment but I can't succeed in creating a notification for the Status.
When I set a condition for the value "ONBATTERY DISCHARGING" in order for Pushover to warn me about a power shutdown, nothing happen.
I noticed that when I come back to the corresponding notification, the field for Value is empty. It seems that my chain of characters was not accepted when creating it. I tried to put the text between " " but same (no) effect.
Any clue ?
Thank you in advance.
Envoyé de mon Pixel 4a en utilisant Tapatalk
The plugin is working fine in my environment but I can't succeed in creating a notification for the Status.
When I set a condition for the value "ONBATTERY DISCHARGING" in order for Pushover to warn me about a power shutdown, nothing happen.
I noticed that when I come back to the corresponding notification, the field for Value is empty. It seems that my chain of characters was not accepted when creating it. I tried to put the text between " " but same (no) effect.
Any clue ?
Thank you in advance.

Envoyé de mon Pixel 4a en utilisant Tapatalk
Raspberry Pi 4 (8GB) & 3B+ (buster) / Conbee II / Z-Stick Gen 5 / RFXCOM 433 XL / Domoticz 2020.02
Pi zero 2 ordered
Pi zero 2 ordered
-
nico21311
- Posts: 6
- Joined: Thursday 20 December 2018 12:24
- Target OS: Linux
- Domoticz version:
- Contact:
Re: Python plugin: UPS Monitor
Hello
I have installed a fresh installation of Domoticz on the news debian bulleyes with python 3.9.2.
Domoticz works well. However when I installed the plugin NUT UPS or UPS monitor, Domoticz do not start.
According my investigation, the issue come form new python 3.9.2 and the script.
I am not enough skill to solved the issue.
I really appreciate if someone could help me.
Thanks in advance for your support
I have installed a fresh installation of Domoticz on the news debian bulleyes with python 3.9.2.
Domoticz works well. However when I installed the plugin NUT UPS or UPS monitor, Domoticz do not start.
According my investigation, the issue come form new python 3.9.2 and the script.
I am not enough skill to solved the issue.
I really appreciate if someone could help me.
Thanks in advance for your support
-
PieterS
- Posts: 198
- Joined: Wednesday 31 May 2017 16:06
- Target OS: NAS (Synology & others)
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Python plugin: UPS Monitor
For a while (maybe since running Domoticz in Docker??) I am not able to monitor my APC UPS which is connected by USB to my Synology. The error in the logfile: Error reading UPS variables: ERR ACCESS-DENIED
This is the (filtered) logfile:
In Docker I have installed the plugin as described in https://www.domoticz.com/wiki/Plugins/NUT_UPS.html
In the configuration of the container of Domoticz (V14369) I have a problem I cannot solve:
When I fill in port 3493 for the host I get an error because that port is in use by the host...

This is a part of the portsettings of the container of Domoticz in Docker:

So how to configure the software of Docker that port 3493 (which is used by the host) can talk to the plugin in Domoticz??
This is the (filtered) logfile:
- Spoiler: show
In Docker I have installed the plugin as described in https://www.domoticz.com/wiki/Plugins/NUT_UPS.html
In the configuration of the container of Domoticz (V14369) I have a problem I cannot solve:
When I fill in port 3493 for the host I get an error because that port is in use by the host...

This is a part of the portsettings of the container of Domoticz in Docker:

So how to configure the software of Docker that port 3493 (which is used by the host) can talk to the plugin in Domoticz??
Synology with Domoticz build (V2024.7) in Docker
-
Matthias
- Posts: 12
- Joined: Wednesday 09 January 2019 23:32
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: UPS Monitor
Hi,
Thank you for this plugin.
It works perfectly.
But i have a problem with blocky.
What is the parameters i have to use for Status mode in a condition ?
I try "OL", "OB", "ONBATTERY DISCHARGING", panic, alarm...
Nothing works
Thank you for this plugin.
It works perfectly.
But i have a problem with blocky.
What is the parameters i have to use for Status mode in a condition ?
I try "OL", "OB", "ONBATTERY DISCHARGING", panic, alarm...
Nothing works
- Attachments
-
- Capture.PNG (52.25 KiB) Viewed 4859 times
- madpatrick
- Posts: 886
- Joined: Monday 26 December 2016 12:17
- Target OS: Linux
- Domoticz version: 2026.1
- Location: Netherlands
- Contact:
Re: Python plugin: UPS Monitor
On my APC UPS the status is "ONLINE"
-= HP server GEN11 =- ZwaveJS-=- Domoticz v2026.2 -=- Dashticz =-
-= Checkout https://github.com/MadPatrick for the plugins =-
-= Checkout https://github.com/MadPatrick for the plugins =-
-
Matthias
- Posts: 12
- Joined: Wednesday 09 January 2019 23:32
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: UPS Monitor
I d'ont understand why it doesn't work.
I try with everything in my blocky :
I try with everything in my blocky :
- ONLINE CHARGING
- ONLINE
- OL
- 0
- 1
- 2
- 3
- 4...
- ON
- OFF
- OPEN
- CLOSE
- ALARM
- PANIC...
- Attachments
-
- Capture1.PNG (21.36 KiB) Viewed 4832 times
-
- Capture2.PNG (7.43 KiB) Viewed 4832 times
- madpatrick
- Posts: 886
- Joined: Monday 26 December 2016 12:17
- Target OS: Linux
- Domoticz version: 2026.1
- Location: Netherlands
- Contact:
Re: Python plugin: UPS Monitor
It appears that a text input is not working in Blocky
See also:
viewtopic.php?f=62&t=28388&p=217446&hil ... ly#p217438
You can better use a Dzvents script.
I've tried a simplte test script and this is working
I think for your example it looks like this
You need to change the ID number of your devices (290 and 300) in this script
See also:
viewtopic.php?f=62&t=28388&p=217446&hil ... ly#p217438
You can better use a Dzvents script.
I've tried a simplte test script and this is working
Code: Select all
local scriptVar = '-=# TEST #=-'
local testswitch = 290
return
{
on = {
devices = {testswitch,},
},
logging = {
level = domoticz.LOG_ERROR,
marker = scriptVar,
},
execute = function(dz, item)
local UPS_status = dz.devices(560)
if UPS_status.text == 'ONLINE' then
dz.log('APS UPS is : ' ..UPS_status.text, dz.LOG_FORCE)
end
end
}I think for your example it looks like this
You need to change the ID number of your devices (290 and 300) in this script
Code: Select all
local scriptVar = '-=# TEST #=-'
local UPS_status = 290 -- fill in your device ID of the EATON
local Light = 300 -- fill in your device ID of the Le Bureau
return
{
on = {
devices = {UPS_status,},
},
logging = {
level = domoticz.LOG_ERROR,
marker = scriptVar,
},
execute = function(dz, item)
local UPS_status = dz.devices(UPS_status)
local Light = dz.devices(Light)
if UPS_status.text == 'ONLINE CHARGING' or UPS_status.text == 'ONBATTERY DISCHARGING' then
Light.switchOn().checkFirst()
dz.log('APS UPS is : ' ..UPS_status.text, dz.LOG_FORCE)
end
end
}-= HP server GEN11 =- ZwaveJS-=- Domoticz v2026.2 -=- Dashticz =-
-= Checkout https://github.com/MadPatrick for the plugins =-
-= Checkout https://github.com/MadPatrick for the plugins =-
-
tarmacalastair
- Posts: 95
- Joined: Wednesday 30 October 2019 14:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Great Britain
- Contact:
Re: Python plugin: UPS Monitor
Notifications
Well I've only just bought a UPS (Tecnoware) and installed this plugin so let's start by saying a big thanks to the author!
But, as others have reported here, I could not get notifications to work when power was lost/restored with the "NUT - UPS Status Mode" changing between ONLINE and ONBATTERY.
One of the recent comments mentioned using blockly so I started out by looking in there and I noticed (when you look at the current values of devices) that there is a column for the "State" and another for the "Value" for each device.
For my UPS the status mode shows the following:
State as "ONLINE" and Value as "1/ONLINE" when there is AC power (top line below):
or
State as "ONBATTERY" and Value as "4/ONBATTERY" when running on battery: So, under the Domoticz "Utility" tab I went into the Notifications for the "UPS Status Mode" and tried using the numeric "Value" instead of the text status. I powered off my UPS and a minute or so later I powered it back on and both times I received a notification (Pushbullet and Telegram in my case). See screenshot and note below: Important - Make sure you change the "Ignore Interval" to on (green) so that the status change will always send out a notification. (I forgot to show this in the above screenshot)
For testing purposes I lowered the polling interval by editing the plugin.py to 20 seconds but will now increase it back to 1 minute.
Just need to decide now whether to set this to ring the (battery) doorbell when power is lost and risk waking the household at night!
Hope this helps people like me who were struggling with notifications.
Well I've only just bought a UPS (Tecnoware) and installed this plugin so let's start by saying a big thanks to the author!
But, as others have reported here, I could not get notifications to work when power was lost/restored with the "NUT - UPS Status Mode" changing between ONLINE and ONBATTERY.
One of the recent comments mentioned using blockly so I started out by looking in there and I noticed (when you look at the current values of devices) that there is a column for the "State" and another for the "Value" for each device.
For my UPS the status mode shows the following:
State as "ONLINE" and Value as "1/ONLINE" when there is AC power (top line below):
or
State as "ONBATTERY" and Value as "4/ONBATTERY" when running on battery: So, under the Domoticz "Utility" tab I went into the Notifications for the "UPS Status Mode" and tried using the numeric "Value" instead of the text status. I powered off my UPS and a minute or so later I powered it back on and both times I received a notification (Pushbullet and Telegram in my case). See screenshot and note below: Important - Make sure you change the "Ignore Interval" to on (green) so that the status change will always send out a notification. (I forgot to show this in the above screenshot)
For testing purposes I lowered the polling interval by editing the plugin.py to 20 seconds but will now increase it back to 1 minute.
Just need to decide now whether to set this to ring the (battery) doorbell when power is lost and risk waking the household at night!
Hope this helps people like me who were struggling with notifications.
Running Domoticz and Dashticz beta on Raspberry Pi OS 32 bit - has anyone had success with 64 bit?
Desktop access from Ubuntu Linux
Desktop access from Ubuntu Linux
-
betogar
- Posts: 6
- Joined: Saturday 10 December 2022 23:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: UPS Monitor
Sorry for the question, where can I see that?tarmacalastair wrote: Thursday 01 December 2022 12:54 Notifications
Well I've only just bought a UPS (Tecnoware) and installed this plugin so let's start by saying a big thanks to the author!
But, as others have reported here, I could not get notifications to work when power was lost/restored with the "NUT - UPS Status Mode" changing between ONLINE and ONBATTERY.
One of the recent comments mentioned using blockly so I started out by looking in there and I noticed (when you look at the current values of devices) that there is a column for the "State" and another for the "Value" for each device.
For my UPS the status mode shows the following:
State as "ONLINE" and Value as "1/ONLINE" when there is AC power (top line below):
Screenshot 2022-12-01 at 11-32-19 Domoticz.png
or
State as "ONBATTERY" and Value as "4/ONBATTERY" when running on battery:
Screenshot 2022-12-01 at 11-39-47 Domoticz.png
So, under the Domoticz "Utility" tab I went into the Notifications for the "UPS Status Mode" and tried using the numeric "Value" instead of the text status. I powered off my UPS and a minute or so later I powered it back on and both times I received a notification (Pushbullet and Telegram in my case). See screenshot and note below:
Screenshot 2022-12-01 at 11-41-32 Domoticz.png
Important - Make sure you change the "Ignore Interval" to on (green) so that the status change will always send out a notification. (I forgot to show this in the above screenshot)
For testing purposes I lowered the polling interval by editing the plugin.py to 20 seconds but will now increase it back to 1 minute.
Just need to decide now whether to set this to ring the (battery) doorbell when power is lost and risk waking the household at night!
Hope this helps people like me who were struggling with notifications.
- Attachments
-
- Screenshot 2022-12-01 at 11-32-19 Domoticz.png (36.54 KiB) Viewed 4724 times
-
tarmacalastair
- Posts: 95
- Joined: Wednesday 30 October 2019 14:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Great Britain
- Contact:
Re: Python plugin: UPS Monitor
You get to it by clicking on Setup, More Options, Events. This takes you to the automation scripts page where you can see device statuses.
You can also get there with http or https://ipaddress:8080/#/Events (substitute your IP address and change the port if you don't use 8080).
Good luck. I found the device statuses by accident. I'd seen them before but completely forgotten.
You can also get there with http or https://ipaddress:8080/#/Events (substitute your IP address and change the port if you don't use 8080).
Good luck. I found the device statuses by accident. I'd seen them before but completely forgotten.
Running Domoticz and Dashticz beta on Raspberry Pi OS 32 bit - has anyone had success with 64 bit?
Desktop access from Ubuntu Linux
Desktop access from Ubuntu Linux
-
betogar
- Posts: 6
- Joined: Saturday 10 December 2022 23:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: UPS Monitor
tarmacalastair wrote: Sunday 11 December 2022 0:37 You get to it by clicking on Setup, More Options, Events. This takes you to the automation scripts page where you can see device statuses.
You can also get there with http or https://ipaddress:8080/#/Events (substitute your IP address and change the port if you don't use 8080).
Good luck. I found the device statuses by accident. I'd seen them before but completely forgotten.
oh i see, thanxs
-
ssk17051980
- Posts: 112
- Joined: Thursday 08 December 2022 22:15
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: ROMANIA
- Contact:
Re: Python plugin: UPS Monitor
Hi,
so, this plugin is working whit any UPS ?
i see that the plugin is for EATON, but another forum member use this for a UPS Tecnoware.
can i use any USB cable to monitor the UPS ?
thx
so, this plugin is working whit any UPS ?
i see that the plugin is for EATON, but another forum member use this for a UPS Tecnoware.
can i use any USB cable to monitor the UPS ?
thx
- Attachments
-
- AJ7W_1_201910101336456077.jpg (54.76 KiB) Viewed 4654 times
-
barkerg
- Posts: 2
- Joined: Thursday 27 February 2025 0:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: UPS Monitor
The plugin works well using simple notifications sent out on Pushover, however I'm trying to write a Blocky script to report the UPS Backup Time whenever the UPS status mode is offline. When constructing an if statement, only the Backup Time device shows up when clicking Devices>Utility and not Status Mode. Both these devices as well as the UPS Charge device show up when I click the current states icon. Is this a bug or am I doing something wrong? I am using Domoticz 2024/7 on a Raspberry Pi 4B. The UPS is a Cyberpower 1500AVR.
- waltervl
- Posts: 7020
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2026.3
- Location: NL
- Contact:
Re: Python plugin: UPS Monitor
That UPS status device is probably a selector switch and can be found under light/switches.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
barkerg
- Posts: 2
- Joined: Thursday 27 February 2025 0:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: UPS Monitor
Thanks for the quick reply. Nothing was found under switches but ironically it was under Zwave Alarms even though it is not a Zwave device. Sorry for the tunnel vision.
-
manuloup
- Posts: 51
- Joined: Sunday 23 November 2014 16:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: France
- Contact:
Re: Python plugin: UPS monitoring
Hi,
I have errors with this plugin :
https://docs.python.org/3/library/telnetlib.html
I run domoticz on trixie (debian 13)
I have errors with this plugin :
It seems the telnetlib is deprecated.2026-03-17 19:11:11.841 Error: Onduleur baie: (NUT_UPS) failed to load 'plugin.py'.
2026-03-17 19:11:12.389 Error: Onduleur baie: Traceback (most recent call last):
2026-03-17 19:11:12.390 Error: Onduleur baie: File "/home/pi/domoticz/plugins/NUT_UPS/plugin.py", line 37, in <module>
2026-03-17 19:11:12.390 Error: Onduleur baie: import telnetlib
2026-03-17 19:11:12.390 Error: Onduleur baie: ModuleNotFoundError: No module named 'telnetlib'
https://docs.python.org/3/library/telnetlib.html
I run domoticz on trixie (debian 13)
Rapberry PI B+ (RaspBian), RFXtrx433E USB 433.92MHz Transceiver, AEON LABS Controler Z-Wave, Aeon Labs Z-Stick S2, Everspring ST814 Temperature Sensor, Everspring SF812 Smoke Detector, 2x Fibaro Wallplug, Aeon Zwave Miniremote , Xbee Teleinfo USB
- madpatrick
- Posts: 886
- Joined: Monday 26 December 2016 12:17
- Target OS: Linux
- Domoticz version: 2026.1
- Location: Netherlands
- Contact:
Re: Python plugin: UPS monitoring
Can you try
edit plugin.py
# Replace: import telnetlib
Install telnetlib3
Or use this adjusted plugin.py
Rename by removing .txt and place in the plugin directory
edit plugin.py
# Replace: import telnetlib
Code: Select all
import telnetlib3 as telnetlibCode: Select all
pip3 install telnetlib3Rename by removing .txt and place in the plugin directory
-= HP server GEN11 =- ZwaveJS-=- Domoticz v2026.2 -=- Dashticz =-
-= Checkout https://github.com/MadPatrick for the plugins =-
-= Checkout https://github.com/MadPatrick for the plugins =-
-
manuloup
- Posts: 51
- Joined: Sunday 23 November 2014 16:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: France
- Contact:
Re: Python plugin: UPS monitoring
I can not install telnetlib3 :
Code: Select all
root@domoticzvm:/home/pi/domoticz/plugins/NUT_UPS# pip3 install telnetlib3
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.
See /usr/share/doc/python3.13/README.venv for more information.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
Code: Select all
root@domoticzvm:/home/pi/domoticz/plugins/NUT_UPS# apt install python3-telnetlib
Erreur : Impossible de trouver le paquet python3-telnetlib
root@domoticzvm:/home/pi/domoticz/plugins/NUT_UPS# apt install python3-telnetlib3
Erreur : Impossible de trouver le paquet python3-telnetlib3
root@domoticzvm:/home/pi/domoticz/plugins/NUT_UPS# cat plugin.py |grep telnet
import telnetlib3 as telnetlib
Rapberry PI B+ (RaspBian), RFXtrx433E USB 433.92MHz Transceiver, AEON LABS Controler Z-Wave, Aeon Labs Z-Stick S2, Everspring ST814 Temperature Sensor, Everspring SF812 Smoke Detector, 2x Fibaro Wallplug, Aeon Zwave Miniremote , Xbee Teleinfo USB
- madpatrick
- Posts: 886
- Joined: Monday 26 December 2016 12:17
- Target OS: Linux
- Domoticz version: 2026.1
- Location: Netherlands
- Contact:
Re: Python plugin: UPS monitoring
Code: Select all
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.pip install telnetlib3 --break-system-packages
have you tried the new script i've posted ?
-
-= HP server GEN11 =- ZwaveJS-=- Domoticz v2026.2 -=- Dashticz =-
-= Checkout https://github.com/MadPatrick for the plugins =-
-= Checkout https://github.com/MadPatrick for the plugins =-