]> git.basschouten.com Git - openhab-addons.git/commitdiff
[tibber] Add accumulatedReward channel (#14277)
authorlsiepel <leosiepel@gmail.com>
Fri, 27 Jan 2023 09:36:40 +0000 (10:36 +0100)
committerGitHub <noreply@github.com>
Fri, 27 Jan 2023 09:36:40 +0000 (10:36 +0100)
* Add channel, fix warning

Signed-off-by: lsiepel <leosiepel@gmail.com>
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

index 3b8bd9abc8837e9d8f1425d5ab94827749bf5acb..836abfa0551ccae630c3793f8209d02f097be594 100644 (file)
@@ -44,6 +44,7 @@ Tibber Pulse (optional):
 | Last Meter Consumption  | Last Recorded Meter Consumption          | True      |
 | Accumulated Consumption | Accumulated Consumption since Midnight   | True      |
 | Accumulated Cost        | Accumulated Cost since Midnight          | True      |
+| Accumulated Reward      | Accumulated Reward since Midnight        | True      |
 | Currency                | Currency of Cost                         | True      |
 | Min Power               | Min Power Consumption since Midnight     | True      |
 | Average Power           | Average Power Consumption since Midnight | True      |
@@ -231,6 +232,7 @@ Number:Power               TibberAPILivePower                    "Live Power Con
 Number:Energy              TibberAPILiveLastMeterConsumption     "Last Meter Consumption [%.2f kWh]"         {channel="tibber:tibberapi:7cfae492:live_lastMeterConsumption"}
 Number:Energy              TibberAPILiveAccumulatedConsumption   "Accumulated Consumption [%.2f kWh]"        {channel="tibber:tibberapi:7cfae492:live_accumulatedConsumption"}
 Number:Dimensionless       TibberAPILiveAccumulatedCost          "Accumulated Cost [%.2f NOK]"               {channel="tibber:tibberapi:7cfae492:live_accumulatedCost"}
+Number:Dimensionless       TibberAPILiveAccumulatedReward        "Accumulated Reward [%.2f NOK]"             {channel="tibber:tibberapi:7cfae492:live_accumulatedReward"}
 String                     TibberAPILiveCurrency                 "Currency"                                  {channel="tibber:tibberapi:7cfae492:live_currency"}
 Number:Power               TibberAPILiveMinPower                 "Min Power Consumption [%.0f W]"            {channel="tibber:tibberapi:7cfae492:live_minPower"}
 Number:Power               TibberAPILiveAveragePower             "Average Power Consumption [%.0f W]"        {channel="tibber:tibberapi:7cfae492:live_averagePower"}
index d1dd24e4cd9bc42dac04e971499995c973fbf609..810731853a92303d9c9d2c713a32f09b5a8f247c 100644 (file)
@@ -60,6 +60,7 @@ public class TibberBindingConstants {
     public static final String LIVE_LASTMETERCONSUMPTION = "live_lastMeterConsumption";
     public static final String LIVE_ACCUMULATEDCONSUMPTION = "live_accumulatedConsumption";
     public static final String LIVE_ACCUMULATEDCOST = "live_accumulatedCost";
+    public static final String LIVE_ACCUMULATEREWARD = "live_accumulatedReward";
     public static final String LIVE_CURRENCY = "live_currency";
     public static final String LIVE_MINPOWER = "live_minPower";
     public static final String LIVE_AVERAGEPOWER = "live_averagePower";
index 64565af2e7a639f5da59074d113c43a81322c7a7..241599ee148cf303ff71a9bf35d80b55c3f846ef 100644 (file)
@@ -428,7 +428,6 @@ public class TibberHandler extends BaseThingHandler {
     }
 
     @WebSocket
-    @NonNullByDefault
     public class TibberWebSocketListener {
 
         @OnWebSocketConnect
@@ -498,6 +497,9 @@ public class TibberHandler extends BaseThingHandler {
                 if (myObject.has("accumulatedCost")) {
                     updateChannel(LIVE_ACCUMULATEDCOST, myObject.get("accumulatedCost").toString());
                 }
+                if (myObject.has("accumulatedReward")) {
+                    updateChannel(LIVE_ACCUMULATEREWARD, myObject.get("accumulatedReward").toString());
+                }
                 if (myObject.has("currency")) {
                     updateState(LIVE_CURRENCY, new StringType(myObject.get("currency").toString()));
                 }
@@ -556,7 +558,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 currency\\n minPower\\n averagePower\\n maxPower\\n"
+                    + "\\\") {\\n timestamp\\n power\\n lastMeterConsumption\\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 c79af77bbb04704e64a52a9ccc0f8c302d0efc40..a33f72ba88931a3149fec124bdcff2504cf3b731 100644 (file)
@@ -35,11 +35,13 @@ 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.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
 channel-type.tibber.timestamp.description = Timestamp for measurement/change
+channel-type.tibber.today_prices.label = Prices for today as a JSON array
+channel-type.tibber.today_prices.description = JSON array of tuples startsAt,total, e.g. {["startsAt": "2022-09-10T00:00:00+02:00", "total": 5.332}, {"startsAt": ...}]. See binding documentation for full example.
+channel-type.tibber.tomorrow_prices.label = Prices for tomorrow as a JSON array
+channel-type.tibber.tomorrow_prices.description = JSON array of tuples startsAt,total, e.g. {["startsAt": "2022-09-10T00:00:00+02:00", "total": 5.332}, {"startsAt": ...}]. See binding documentation for full example.
 channel-type.tibber.voltage.label = Voltage
 channel-type.tibber.voltage.description = Voltage on given Phase
-channel-type.tibber.tomorrow_prices.label = Prices for tomorrow as a JSON array
-channel-type.tibber.tomorrow_prices.description = JSON array of tuples startsAt,total, e.g. {["startsAt": "2022-09-10T00:00:00+02:00", "total": 5.332}, {"startsAt": ...}]}. See binding documentation for full example.
-channel-type.tibber.today_prices.label = Prices for today as a JSON array
-channel-type.tibber.today_prices.description = JSON array of tuples startsAt,total, e.g. {["startsAt": "2022-09-10T00:00:00+02:00", "total": 5.332}, {"startsAt": ...}]}. See binding documentation for full example.
index 9118147f3dbdbacaf3ab3bf94970bd032cc05c62..b08e544e47a1c6745965f6d3acc33b5db13be858 100644 (file)
@@ -26,6 +26,7 @@
                        <channel id="live_lastMeterConsumption" typeId="consumption"/>
                        <channel id="live_accumulatedConsumption" typeId="consumption"/>
                        <channel id="live_accumulatedCost" typeId="cost"/>
+                       <channel id="live_accumulatedReward" typeId="reward"/>
                        <channel id="live_currency" typeId="currency"/>
                        <channel id="live_minPower" typeId="power"/>
                        <channel id="live_averagePower" typeId="power"/>
                <description>Cost at given time interval (e.g. hourly, daily, accumulated since midnight)</description>
                <state pattern="%.3f"></state>
        </channel-type>
+       <channel-type id="reward">
+               <item-type>Number:Dimensionless</item-type>
+               <label>Total Reward</label>
+               <description>Reward at given time interval (e.g. hourly, daily, accumulated since midnight)</description>
+               <state pattern="%.3f"></state>
+       </channel-type>
        <channel-type id="consumption">
                <item-type>Number:Energy</item-type>
                <label>Total Consumption</label>