|--------------------|-----------------------------------------|-----------|
| Current Total | Current Total Price (energy + tax) | True |
| Starts At | Current Price Timestamp | True |
+| Current Level | Current Price Level | True |
| Daily Cost | Daily Cost (last/previous day) | True |
| Daily Consumption | Daily Consumption (last/previous day) | True |
| Daily From | Timestamp (daily from) | True |
```
Number:Dimensionless TibberAPICurrentTotal "Current Total Price [%.2f NOK]" {channel="tibber:tibberapi:7cfae492:current_total"}
DateTime TibberAPICurrentStartsAt "Timestamp - Current Price" {channel="tibber:tibberapi:7cfae492:current_startsAt"}
+String TibberAPICurrentLevel "Price Level" {channel="tibber:tibberapi:7cfae492:current_level"}
DateTime TibberAPIDailyFrom "Timestamp - Daily From" {channel="tibber:tibberapi:7cfae492:daily_from"}
DateTime TibberAPIDailyTo "Timestamp - Daily To" {channel="tibber:tibberapi:7cfae492:daily_to"}
Number:Dimensionless TibberAPIDailyCost "Total Daily Cost [%.2f NOK]" {channel="tibber:tibberapi:7cfae492:daily_cost"}
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"}
DateTime TibberAPILiveTimestamp "Timestamp - Live Measurement" {channel="tibber:tibberapi:7cfae492:live_timestamp"}
-Number:Power TibberAPILivePower "Live Power Consumption [W]" {channel="tibber:tibberapi:7cfae492:live_power"}
+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"}
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"}
String TibberAPILiveCurrency "Currency" {channel="tibber:tibberapi:7cfae492:live_currency"}
-Number:Power TibberAPILiveMinPower "Min Power Consumption [W]" {channel="tibber:tibberapi:7cfae492:live_minPower"}
-Number:Power TibberAPILiveAveragePower "Average Power Consumption [W]" {channel="tibber:tibberapi:7cfae492:live_averagePower"}
-Number:Power TibberAPILiveMaxPower "Max Power Consumption [W]" {channel="tibber:tibberapi:7cfae492:live_maxPower"}
-Number:ElectricPotential TibberAPILiveVoltage1 "Live Voltage Phase 1 [V]" {channel="tibber:tibberapi:7cfae492:live_voltage1"}
-Number:ElectricPotential TibberAPILiveVoltage2 "Live Voltage Phase 2 [V]" {channel="tibber:tibberapi:7cfae492:live_voltage2"}
-Number:ElectricPotential TibberAPILiveVoltage3 "Live Voltage Phase 3 [V]" {channel="tibber:tibberapi:7cfae492:live_voltage3"}
-Number:ElectricCurrent TibberAPILiveCurrent1 "Live Current Phase 1 [A]" {channel="tibber:tibberapi:7cfae492:live_current1"}
-Number:ElectricCurrent TibberAPILiveCurrent2 "Live Current Phase 2 [A]" {channel="tibber:tibberapi:7cfae492:live_current2"}
-Number:ElectricCurrent TibberAPILiveCurrent3 "Live Current Phase 3 [A]" {channel="tibber:tibberapi:7cfae492:live_current3"}
-Number:Power TibberAPILivePowerProduction "Live Power Production [W]" {channel="tibber:tibberapi:7cfae492:live_powerProduction"}
-Number:Power TibberAPILiveMinPowerproduction "Min Power Production [W]" {channel="tibber:tibberapi:7cfae492:live_minPowerproduction"}
-Number:Power TibberAPILiveMaxPowerproduction "Max Power Production [W]" {channel="tibber:tibberapi:7cfae492:live_maxPowerproduction"}
+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"}
+Number:Power TibberAPILiveMaxPower "Max Power Consumption [%.0f W]" {channel="tibber:tibberapi:7cfae492:live_maxPower"}
+Number:ElectricPotential TibberAPILiveVoltage1 "Live Voltage Phase 1 [%.0 V]" {channel="tibber:tibberapi:7cfae492:live_voltage1"}
+Number:ElectricPotential TibberAPILiveVoltage2 "Live Voltage Phase 2 [%.0 V]" {channel="tibber:tibberapi:7cfae492:live_voltage2"}
+Number:ElectricPotential TibberAPILiveVoltage3 "Live Voltage Phase 3 [%.0 V]" {channel="tibber:tibberapi:7cfae492:live_voltage3"}
+Number:ElectricCurrent TibberAPILiveCurrent1 "Live Current Phase 1 [%.1 A]" {channel="tibber:tibberapi:7cfae492:live_current1"}
+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: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"}
```
}
public void getTibberParameters() {
+ String response = "";
try {
httpHeader.put("cache-control", "no-cache");
httpHeader.put("content-type", JSON_CONTENT_TYPE);
TibberPriceConsumptionHandler tibberQuery = new TibberPriceConsumptionHandler();
InputStream connectionStream = tibberQuery.connectionInputStream(tibberConfig.getHomeid());
- String response = HttpUtil.executeUrl("POST", BASE_URL, httpHeader, connectionStream, null,
- REQUEST_TIMEOUT);
+ response = HttpUtil.executeUrl("POST", BASE_URL, httpHeader, connectionStream, null, REQUEST_TIMEOUT);
if (!response.contains("error") && !response.contains("<html>")) {
updateStatus(ThingStatus.ONLINE);
-
getURLInput(BASE_URL);
InputStream inputStream = tibberQuery.getRealtimeInputStream(tibberConfig.getHomeid());
}
public void getURLInput(String url) throws IOException {
+ String jsonResponse = "";
TibberPriceConsumptionHandler tibberQuery = new TibberPriceConsumptionHandler();
InputStream inputStream = tibberQuery.getInputStream(tibberConfig.getHomeid());
- String jsonResponse = HttpUtil.executeUrl("POST", url, httpHeader, inputStream, null, REQUEST_TIMEOUT);
+ jsonResponse = HttpUtil.executeUrl("POST", url, httpHeader, inputStream, null, REQUEST_TIMEOUT);
logger.debug("API response: {}", jsonResponse);
if (!jsonResponse.contains("error") && !jsonResponse.contains("<html>")) {
updateState(CURRENT_TOTAL, new DecimalType(myObject.get("total").toString()));
String timestamp = myObject.get("startsAt").toString().substring(1, 20);
updateState(CURRENT_STARTSAT, new DateTimeType(timestamp));
+ updateState(CURRENT_LEVEL, new StringType(myObject.get("level").toString()));
} catch (JsonSyntaxException e) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"Error communicating with Tibber API: " + e.getMessage());
}
}
- if (jsonResponse.contains("daily")) {
+ if (jsonResponse.contains("daily") && !jsonResponse.contains("\"daily\":{\"nodes\":[]")
+ && !jsonResponse.contains("\"daily\":null")) {
try {
JsonObject myObject = (JsonObject) object.getAsJsonObject("data").getAsJsonObject("viewer")
.getAsJsonObject("home").getAsJsonObject("daily").getAsJsonArray("nodes").get(0);
"Error communicating with Tibber API: " + e.getMessage());
}
}
- if (jsonResponse.contains("hourly")) {
+ if (jsonResponse.contains("hourly") && !jsonResponse.contains("\"hourly\":{\"nodes\":[]")
+ && !jsonResponse.contains("\"hourly\":null")) {
try {
JsonObject myObject = (JsonObject) object.getAsJsonObject("data").getAsJsonObject("viewer")
.getAsJsonObject("home").getAsJsonObject("hourly").getAsJsonArray("nodes").get(0);
updateState(channelID, new QuantityType<>(new BigDecimal(channelValue), Units.WATT));
} else if (channelID.contains("voltage")) {
updateState(channelID, new QuantityType<>(new BigDecimal(channelValue), Units.VOLT));
- } else if (channelID.contains("live_current")) {
+ } else if (channelID.contains("current")) {
updateState(channelID, new QuantityType<>(new BigDecimal(channelValue), Units.AMPERE));
} else {
updateState(channelID, new DecimalType(channelValue));
WebSocketClient client = this.client;
if (client == null) {
client = new WebSocketClient(sslContextFactory, websocketExecutor);
+ client.setMaxIdleTimeout(600 * 1000);
this.client = client;
}
} catch (IOException e) {
logger.warn("Websocket Close Exception: {}", e.getMessage());
}
- session.close(0, "Tibber websocket disposed");
+ session.close();
this.session = null;
this.socket = null;
}
if (myObject.has("voltagePhase3")) {
updateChannel(LIVE_VOLTAGE3, myObject.get("voltagePhase3").toString());
}
- if (myObject.has("currentPhase1")) {
- updateChannel(LIVE_CURRENT1, myObject.get("currentPhase1").toString());
+ if (myObject.has("currentL1")) {
+ updateChannel(LIVE_CURRENT1, myObject.get("currentL1").toString());
}
- if (myObject.has("currentPhase2")) {
- updateChannel(LIVE_CURRENT2, myObject.get("currentPhase2").toString());
+ if (myObject.has("currentL2")) {
+ updateChannel(LIVE_CURRENT2, myObject.get("currentL2").toString());
}
- if (myObject.has("currentPhase3")) {
- updateChannel(LIVE_CURRENT3, myObject.get("currentPhase3").toString());
+ if (myObject.has("currentL3")) {
+ updateChannel(LIVE_CURRENT3, myObject.get("currentL3").toString());
}
if (myObject.has("powerProduction")) {
updateChannel(LIVE_POWERPRODUCTION, myObject.get("powerProduction").toString());
String query = "{\"id\":\"1\",\"type\":\"start\",\"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"
- + "voltagePhase1\\n voltagePhase2\\n voltagePhase3\\n currentPhase1\\n currentPhase2\\n currentPhase3\\n powerProduction\\n accumulatedProduction\\n minPowerProduction\\n maxPowerProduction\\n }\\n }\\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;
if (socket != null) {