Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tibber] Add accumulatedReward channel #14277

Merged
merged 7 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bundles/org.openhab.binding.tibber/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ public boolean isConnected() {
}

@WebSocket
@NonNullByDefault
public class TibberWebSocketListener {

@OnWebSocketConnect
Expand Down Expand Up @@ -498,6 +497,9 @@ public void onMessage(String message) {
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()));
}
Expand Down Expand Up @@ -556,7 +558,7 @@ private void sendMessage(String message) throws IOException {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down Expand Up @@ -82,6 +83,12 @@
<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>
Expand Down