]> git.basschouten.com Git - openhab-addons.git/commitdiff
[networkupstools] Add battery.temperature channel (#15812)
authorlsiepel <leosiepel@gmail.com>
Fri, 3 Nov 2023 17:47:40 +0000 (18:47 +0100)
committerGitHub <noreply@github.com>
Fri, 3 Nov 2023 17:47:40 +0000 (18:47 +0100)
* Add channel battery-temperature

---------

Signed-off-by: Leo Siepel <leosiepel@gmail.com>
bundles/org.openhab.binding.networkupstools/README.md
bundles/org.openhab.binding.networkupstools/src/main/java/org/openhab/binding/networkupstools/internal/NutName.java
bundles/org.openhab.binding.networkupstools/src/main/resources/OH-INF/i18n/networkupstools.properties
bundles/org.openhab.binding.networkupstools/src/main/resources/OH-INF/thing/channels.xml
bundles/org.openhab.binding.networkupstools/src/main/resources/OH-INF/thing/thing-types.xml
bundles/org.openhab.binding.networkupstools/src/main/resources/OH-INF/update/instructions.xml [new file with mode: 0644]
bundles/org.openhab.binding.networkupstools/src/test/java/org/openhab/binding/networkupstools/internal/NutNameChannelsTest.java

index 861abcf07013c8594904490959d8a8a235303ab7..6f7d30aae62171f9b1be4114c7fd3a9aa26cf16a 100644 (file)
@@ -76,6 +76,7 @@ The following channels are available:
 | batteryCharge       | Number:Dimensionless     | %    | Battery charge (percent)                                            | no       |
 | batteryRuntime      | Number:Time              | s    | Battery runtime (seconds)                                           | no       |
 | batteryVoltage      | Number:ElectricPotential | V    | Battery voltage (V)                                                 | yes      |
+| batteryTemperature  | Number:Temperature       | °C   | Battery temperature (degrees C)                                     | yes      |
 
 ### Dynamic Channels
 
index f0453f8f9c494689fdb1cafab4638b4ecfa2b477..dc7039c875c3388c1199e2b76a257c20330e224a 100644 (file)
@@ -64,7 +64,8 @@ enum NutName {
     // Battery
     BATTERY_CHARGE("batteryCharge", "battery.charge", Units.PERCENT),
     BATTERY_RUNTIME("batteryRuntime", "battery.runtime", Units.SECOND),
-    BATTERY_VOLTAGE("batteryVoltage", "battery.voltage", Units.VOLT);
+    BATTERY_VOLTAGE("batteryVoltage", "battery.voltage", Units.VOLT),
+    BATTERY_TEMPERATURE("batteryTemperature", "battery.temperature", SIUnits.CELSIUS);
 
     static final Map<String, NutName> NUT_NAME_MAP = Stream.of(NutName.values())
             .collect(Collectors.toMap(NutName::getChannelId, Function.identity()));
index 4c6f6330f8d3979d6ae9854efa5f57651d5422b1..ee23de1d94c421cce926cade52c900c258f1f55c 100644 (file)
@@ -29,6 +29,8 @@ channel-type.networkupstools.battery-charge.label = Battery Charge
 channel-type.networkupstools.battery-charge.description = Battery charge (percent)
 channel-type.networkupstools.battery-runtime.label = Battery Runtime
 channel-type.networkupstools.battery-runtime.description = Battery runtime (seconds)
+channel-type.networkupstools.battery-temperature.label = Battery Temperature
+channel-type.networkupstools.battery-temperature.description = Battery temperature (degrees C)
 channel-type.networkupstools.battery-voltage.label = Battery Voltage
 channel-type.networkupstools.battery-voltage.description = Battery voltage (V)
 channel-type.networkupstools.input-current-status.label = Input Current Status
index 703fa0b6c103134c27e9039c53d41d3aec104d0d..f88dd7e0725eed23fcd223e19d63f68d47ad41af 100644 (file)
                <description>Battery voltage (V)</description>
                <state pattern="%.0f %unit%" readOnly="true"/>
        </channel-type>
-
+       <channel-type id="battery-temperature" advanced="true">
+               <item-type>Number:Temperature</item-type>
+               <label>Battery Temperature</label>
+               <description>Battery temperature (degrees C)</description>
+               <state pattern="%.1f %unit%" readOnly="true"/>
+       </channel-type>
 </thing:thing-descriptions>
index 3720317e0ace7df0d62529322168d5e20a378b3b..af18867b8845362bdc5f456e6225532a10f16fb5 100644 (file)
@@ -13,6 +13,7 @@
                        <channel id="batteryCharge" typeId="battery-charge"/>
                        <channel id="batteryRuntime" typeId="battery-runtime"/>
                        <channel id="batteryVoltage" typeId="battery-voltage"/>
+                       <channel id="batteryTemperature" typeId="battery-temperature"/>
                        <channel id="inputRealpower" typeId="input-realpower"/>
                        <channel id="inputVoltageStatus" typeId="input-voltage-status"/>
                        <channel id="inputQuality" typeId="input-quality"/>
                        <channel id="upsTestResult" typeId="ups-test-result"/>
                </channels>
 
+               <properties>
+                       <property name="thingTypeVersion">1</property>
+               </properties>
+
                <config-description-ref uri="thing-type:ups:config"/>
        </thing-type>
 
diff --git a/bundles/org.openhab.binding.networkupstools/src/main/resources/OH-INF/update/instructions.xml b/bundles/org.openhab.binding.networkupstools/src/main/resources/OH-INF/update/instructions.xml
new file mode 100644 (file)
index 0000000..8f0234d
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<update:update-descriptions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:update="https://openhab.org/schemas/update-description/v1.0.0"
+       xsi:schemaLocation="https://openhab.org/schemas/update-description/v1.0.0 https://openhab.org/schemas/update-description-1.0.0.xsd">
+
+       <thing-type uid="networkupstools:ups">
+
+               <instruction-set targetVersion="1">
+                       <add-channel id="batteryTemperature">
+                               <type>networkupstools:battery-temperature</type>
+                       </add-channel>
+               </instruction-set>
+
+       </thing-type>
+
+</update:update-descriptions>
index f591b2940883e1ae7b1a9a14e4fba627dc1aad51..f7a888240487fdfe80377ea0d695f4d33b1a3285 100644 (file)
@@ -43,7 +43,7 @@ public class NutNameChannelsTest {
     private static final String THING_TYPES_XML = "thing-types.xml";
     private static final String CHANNELS_XML = "channels.xml";
 
-    private static final int EXPECTED_NUMBER_OF_CHANNELS = 20;
+    private static final int EXPECTED_NUMBER_OF_CHANNELS = 21;
     private static final int EXPECTED_NUMMBER_OF_CHANNEL_XML_LINES = EXPECTED_NUMBER_OF_CHANNELS * 6;
 
     // README table is: | Channel Name | Item Type | Unit | Description | Advanced