Add channel for lastMeterProduction (#14583)

Signed-off-by: kjoglum <stiankj@online.no>
This commit is contained in:
Stian Kjoglum 2023-03-14 08:34:48 +01:00 committed by GitHub
parent a6a801c28f
commit 596324635d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 6 deletions

View 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"}
```

View 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";

View 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;

View 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

View 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">
@ -121,7 +123,7 @@
<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">

View File

@ -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>