]> git.basschouten.com Git - openhab-addons.git/commitdiff
Add channel for lastMeterProduction (#14583)
authorStian Kjoglum <47720690+kjoglum@users.noreply.github.com>
Tue, 14 Mar 2023 07:34:48 +0000 (08:34 +0100)
committerGitHub <noreply@github.com>
Tue, 14 Mar 2023 07:34:48 +0000 (08:34 +0100)
Signed-off-by: kjoglum <stiankj@online.no>
bundles/org.openhab.binding.tibber/README.md
bundles/org.openhab.binding.tibber/src/main/java/org/openhab/binding/tibber/internal/TibberBindingConstants.java
bundles/org.openhab.binding.tibber/src/main/java/org/openhab/binding/tibber/internal/handler/TibberHandler.java
bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/i18n/tibber.properties
bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/thing/thing-types.xml
bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/update/instructions.xml [new file with mode: 0644]

index 32131d98d6986be44067e1553fb86fc887282ccb..8b5a0f82918bc6dfe984911e798b06e92a321181 100644 (file)
@@ -53,6 +53,7 @@ Tibber Pulse (optional):
 | Current 1-3             | Current per Phase                        | True      |
 | Power Production        | Live Power Production                    | True      |
 | Accumulated Production  | Accumulated Production since Midnight    | True      |
+| Last Meter Production   | Last Recorded Meter Production           | True      |
 | Min Power Production    | Min Power Production since Midnight      | True      |
 | Max Power Production    | Max Power Production since Midnight      | True      |
 
@@ -227,6 +228,8 @@ DateTime                   TibberAPIHourlyFrom                   "Timestamp - Ho
 DateTime                   TibberAPIHourlyTo                     "Timestamp - Hourly To"                     {channel="tibber:tibberapi:7cfae492:hourly_to"}
 Number:Dimensionless       TibberAPIHourlyCost                   "Total Hourly Cost [%.2f NOK]"              {channel="tibber:tibberapi:7cfae492:hourly_cost"}
 Number:Energy              TibberAPIHourlyConsumption            "Total Hourly Consumption [%.2f kWh]"       {channel="tibber:tibberapi:7cfae492:hourly_consumption"}
+String                     TibberAPITomorrowPrices               "Price per hour tomorrow JSON array"        {channel="tibber:tibberapi:7cfae492:tomorrow_prices"}
+String                     TibberAPITodayPrices                  "Price per hour today JSON array"           {channel="tibber:tibberapi:7cfae492:today_prices"}
 DateTime                   TibberAPILiveTimestamp                "Timestamp - Live Measurement"              {channel="tibber:tibberapi:7cfae492:live_timestamp"}
 Number:Power               TibberAPILivePower                    "Live Power Consumption [%.0f W]"           {channel="tibber:tibberapi:7cfae492:live_power"}
 Number:Energy              TibberAPILiveLastMeterConsumption     "Last Meter Consumption [%.2f kWh]"         {channel="tibber:tibberapi:7cfae492:live_lastMeterConsumption"}
@@ -244,9 +247,8 @@ Number:ElectricCurrent     TibberAPILiveCurrent1                 "Live Current P
 Number:ElectricCurrent     TibberAPILiveCurrent2                 "Live Current Phase 2 [%.1 A]"              {channel="tibber:tibberapi:7cfae492:live_current2"}
 Number:ElectricCurrent     TibberAPILiveCurrent3                 "Live Current Phase 3 [%.1 A]"              {channel="tibber:tibberapi:7cfae492:live_current3"}
 Number:Power               TibberAPILivePowerProduction          "Live Power Production [%.0f W]"            {channel="tibber:tibberapi:7cfae492:live_powerProduction"}
+Number:Energy              TibberAPILiveAccumulatedProduction    "Accumulated Production [%.2f kWh]"         {channel="tibber:tibberapi:7cfae492:live_accumulatedProduction"}
+Number:Energy              TibberAPILiveLastMeterProduction      "Min Power Production [%.0f W]"             {channel="tibber:tibberapi:7cfae492:live_lastMeterProduction"}
 Number:Power               TibberAPILiveMinPowerproduction       "Min Power Production [%.0f W]"             {channel="tibber:tibberapi:7cfae492:live_minPowerproduction"}
 Number:Power               TibberAPILiveMaxPowerproduction       "Max Power Production [%.0f W]"             {channel="tibber:tibberapi:7cfae492:live_maxPowerproduction"}
-Number:Energy              TibberAPILiveAccumulatedProduction    "Accumulated Production [%.2f kWh]"         {channel="tibber:tibberapi:7cfae492:live_accumulatedProduction"}
-String                     TibberAPITomorrowPrices               "Price per hour tomorrow JSON array"        {channel="tibber:tibberapi:7cfae492:tomorrow_prices"}
-String                     TibberAPITodayPrices                  "Price per hour today JSON array"           {channel="tibber:tibberapi:7cfae492:today_prices"}
 ```
index 810731853a92303d9c9d2c713a32f09b5a8f247c..54b1207f89bcd3ee2f0c0ad1fc7c94eee76f15ff 100644 (file)
@@ -58,6 +58,7 @@ public class TibberBindingConstants {
     public static final String LIVE_TIMESTAMP = "live_timestamp";
     public static final String LIVE_POWER = "live_power";
     public static final String LIVE_LASTMETERCONSUMPTION = "live_lastMeterConsumption";
+    public static final String LIVE_LASTMETERPRODUCTION = "live_lastMeterProduction";
     public static final String LIVE_ACCUMULATEDCONSUMPTION = "live_accumulatedConsumption";
     public static final String LIVE_ACCUMULATEDCOST = "live_accumulatedCost";
     public static final String LIVE_ACCUMULATEREWARD = "live_accumulatedReward";
index 59e8e1b8cdb742817803db25f784954a17c89237..d53cb58cc25afaf23a3523f8ec92e58dd87820c5 100644 (file)
@@ -530,6 +530,9 @@ public class TibberHandler extends BaseThingHandler {
                 if (myObject.has("lastMeterConsumption")) {
                     updateChannel(LIVE_LASTMETERCONSUMPTION, myObject.get("lastMeterConsumption").toString());
                 }
+                if (myObject.has("lastMeterProduction")) {
+                    updateChannel(LIVE_LASTMETERPRODUCTION, myObject.get("lastMeterProduction").toString());
+                }
                 if (myObject.has("accumulatedConsumption")) {
                     updateChannel(LIVE_ACCUMULATEDCONSUMPTION, myObject.get("accumulatedConsumption").toString());
                 }
@@ -597,7 +600,7 @@ public class TibberHandler extends BaseThingHandler {
         public void startSubscription() {
             String query = "{\"id\":\"1\",\"type\":\"subscribe\",\"payload\":{\"variables\":{},\"extensions\":{},\"operationName\":null,\"query\":\"subscription {\\n liveMeasurement(homeId:\\\""
                     + tibberConfig.getHomeid()
-                    + "\\\") {\\n timestamp\\n power\\n lastMeterConsumption\\n accumulatedConsumption\\n accumulatedCost\\n accumulatedReward\\n currency\\n minPower\\n averagePower\\n maxPower\\n"
+                    + "\\\") {\\n timestamp\\n power\\n lastMeterConsumption\\n lastMeterProduction\\n accumulatedConsumption\\n accumulatedCost\\n accumulatedReward\\n currency\\n minPower\\n averagePower\\n maxPower\\n"
                     + "voltagePhase1\\n voltagePhase2\\n voltagePhase3\\n currentL1\\n currentL2\\n currentL3\\n powerProduction\\n accumulatedProduction\\n minPowerProduction\\n maxPowerProduction\\n }\\n }\\n\"}}";
             try {
                 TibberWebSocketListener socket = TibberHandler.this.socket;
index a33f72ba88931a3149fec124bdcff2504cf3b731..ff5e4b1c8ab71f866b9fd898e742d256c5102aaa 100644 (file)
@@ -34,7 +34,7 @@ channel-type.tibber.power.description = Power consumption/production for given t
 channel-type.tibber.price.label = Current Total Price
 channel-type.tibber.price.description = Total Price: Energy + Tax
 channel-type.tibber.production.label = Total Production
-channel-type.tibber.production.description = Accumulated Production since Midnight
+channel-type.tibber.production.description = Production at given time interval (e.g. last meter reading, accumulated since midnight)
 channel-type.tibber.reward.label = Total Reward
 channel-type.tibber.reward.description = Reward at given time interval (e.g. hourly, daily, accumulated since midnight)
 channel-type.tibber.timestamp.label = Timestamp
index b08e544e47a1c6745965f6d3acc33b5db13be858..ce809c5ea4e9bbbb3d6e909658f3544e7a9926a1 100644 (file)
@@ -24,6 +24,7 @@
                        <channel id="live_timestamp" typeId="timestamp"/>
                        <channel id="live_power" typeId="power"/>
                        <channel id="live_lastMeterConsumption" typeId="consumption"/>
+                       <channel id="live_lastMeterProduction" typeId="production"/>
                        <channel id="live_accumulatedConsumption" typeId="consumption"/>
                        <channel id="live_accumulatedCost" typeId="cost"/>
                        <channel id="live_accumulatedReward" typeId="reward"/>
@@ -44,6 +45,7 @@
                </channels>
                <properties>
                        <property name="vendor">Tibber</property>
+                       <property name="thingTypeVersion">1</property>
                </properties>
                <config-description>
                        <parameter name="token" type="text" required="true">
        <channel-type id="production">
                <item-type>Number:Energy</item-type>
                <label>Total Production</label>
-               <description>Accumulated Production since Midnight</description>
+               <description>Production at given time interval (e.g. last meter reading, accumulated since midnight)</description>
                <state pattern="%.3f %unit%"></state>
        </channel-type>
        <channel-type id="tomorrow_prices" advanced="true">
diff --git a/bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/update/instructions.xml b/bundles/org.openhab.binding.tibber/src/main/resources/OH-INF/update/instructions.xml
new file mode 100644 (file)
index 0000000..e01fe51
--- /dev/null
@@ -0,0 +1,14 @@
+<?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="tibber:tibberapi">
+               <instruction-set targetVersion="1">
+                       <add-channel id="live_lastMeterProduction">
+                               <type>tibber:production</type>
+                       </add-channel>
+               </instruction-set>
+       </thing-type>
+
+</update:update-descriptions>