As part of my quest to write a tutorial on how to migrate an openHAB1 binding to an openHAB 2 binding I’ve picked up the openHAB1 networkupstools binding to migrate. The actual code is very small and easy to migrate. However the biggest challenge is to define things and channels. With the openHAB 1 binding this is all free format. So you as a user must specify the items that link directly to the information of the network ups tool. With openHAB 2 the intention is to define a set of channels. This would make it possible to configure the channels from a user interface.
To do so I’d like to have some input from actual users. I have the following questions:
- UPS can be daisychained, linking multiple UPS. Is this something that should be supported by the binding?
- UPS can report information about several outlet’s. Should outlets be supported?
- The list of information provided by the UPS is very long. Can we make a selection of channels to support? Here is the complete list of possible channels: https://github.com/networkupstools/nut/blob/master/docs/nut-names.txt
- It seems also possible to send commands. I don’t know if that works. But is this of interest? And if so, which commands?
Alpha version available Binding merged and will be available in 2.5 M4
The binding is available from 2.5 Milestone 4 . For bug fixes or older 2.5.0 versions a jar file can be downloaded from: https://github.com/Hilbrand/openhab2-addons/releases/tag/networkupstools Place the jar file in your addons folder.
If you want any nut variable as channel available in the binding or have any other feedback let me know in the comments.
openHAB 1 migration guide:
If you used the openHAB 1 version of this binding. Here is the information to help you migrate to the new version.
The networkupstools.cfg
needs to be migrated to a thing in a .things file or added via PaperUI:
oh1 binding config:
ups1.device=ups
ups1.host=192.168.1.10
ups1.login=admin
ups1.pass=pass
refresh=60000
oh2 thing configuration:
(Out-of-the-box channels don’t need to be configured. But it’s also possible to add additional channels. The configuration below makes use of this feature. See the readme for more information)
Thing networkupstools:ups:ups1 [ device="ups", host="192.168.1.10", username="admin", password="pass", refresh=60 ] {
Channels:
Number:ElectricPotential : upsOutputVoltage "UPS Output Voltage" [networkupstools="output.voltage", unit="V"]
}
Note:
-
refresh
time changed from milliseconds to seconds: 60000 => 60 -
login
changed tousername
as that better reflects how it’s called in network ups tools -
pass
changed topassword
Items
oh1 items:
Number Ups_Realpower "UPS Power [%d W]" (Ups) {networkupstools="ups1:ups.realpower"}
Number Ups_Output_Voltage "UPS output voltage [%.1f V]" (Ups) {networkupstools="ups1:output.voltage"}
String Ups_Status "UPS status [%s]" (Ups) {networkupstools="ups1:ups.status"}
oh2 items:
Number:Power Ups_Realpower "UPS Power [%d W]" (Ups) {channel="networkupstools:ups:ups1:upsRealpower"}
Number:ElectricPotential Ups_Output_Voltage "UPS output voltage [%.1f V]" (Ups) {channel="networkupstools:ups:ups1:upsOutputVoltage"}
String Ups_Status "UPS status [%s]" (Ups) {channel="networkupstools:ups:ups1:status"}
String Ups_Status_Text "UPS status [%s]" (Ups) {channel="networkupstools:ups:ups1:statusText"}