Open DrScr3w opened 6 months ago
This issue has been mentioned on openHAB Community. There might be relevant details there:
Hello, is it possible to include this in the next release please?
Hello, is it possible to include this in the next release please?
If these are available by the API it should not be that hard to implement. Do you have the JSON or schema details? If these are not available, it might be better to calculate this using rules and persistence.
@lsiepel I hope that I have determined it correctly ;) https://developer.tibber.com/explorer
Under “Consumptions” you can see the “cost” and "consumption" and there you can switch from “hourly” to “monthly” or "annual".
Wouldn't it “only” be necessary to add more IFs with monthly and annual?
Line 234
if (jsonResponse.contains("daily") && !jsonResponse.contains("\"daily\":{\"nodes\":[]")
&& !jsonResponse.contains("\"daily\":null")) {
try {
JsonObject myObject = (JsonObject) rootJsonObject.getAsJsonObject("data").getAsJsonObject("viewer")
.getAsJsonObject("home").getAsJsonObject("daily").getAsJsonArray("nodes").get(0);
String timestampDailyFrom = myObject.get("from").toString().substring(1, 20);
updateState(DAILY_FROM, new DateTimeType(timestampDailyFrom));
String timestampDailyTo = myObject.get("to").toString().substring(1, 20);
updateState(DAILY_TO, new DateTimeType(timestampDailyTo));
updateChannel(DAILY_COST, myObject.get("cost").toString());
updateChannel(DAILY_CONSUMPTION, myObject.get("consumption").toString());
} catch (JsonSyntaxException e) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"Error communicating with Tibber API: " + e.getMessage());
}
}
You are right, it is not a complicated change. But there is more to it: the README.md and the thing-structure.xml need to be adapted and don't forget the thing upgrade instructions.
Do you think you can include these things in the next release?
Please add the following channels to the binding for getting monthly and annual information.