-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[linky] Add support for reading index instead of basic value #19147
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
base: main
Are you sure you want to change the base?
Conversation
…ournisseur and distributor dispatch like heure creuse / heure pleine or tempo tarif). Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
1fc1544
to
a5b1bfc
Compare
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
remove unnecessary code after last fixes Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
…the binding Signed-off-by: Laurent ARNAL <laurent@clae.net>
- Will create channel dynamically to represent each available tarif. - Will split the dataset result to the bound of tarif change. - Will update each time series accordly. - Graph will be able to display silmutaneous tarif on the same graph. Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
… set to 0. Signed-off-by: Laurent ARNAL <laurent@clae.net>
add verification for tarif change Signed-off-by: Laurent ARNAL <laurent@clae.net>
Hello @lsiepel, Can I ask you to relaunch a Copilot review on this PR. Also, I think the PR is now ready for final review. @lolodomo, @clinique: fill free to test on your side, and make any comment if need. Laurent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 20 out of 21 changed files in this pull request and generated 12 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/dto/MeterReading.java
Outdated
Show resolved
Hide resolved
....linky/src/main/java/org/openhab/binding/linky/internal/handler/ThingLinkyRemoteHandler.java
Outdated
Show resolved
Hide resolved
....linky/src/main/java/org/openhab/binding/linky/internal/handler/ThingLinkyRemoteHandler.java
Show resolved
Hide resolved
....linky/src/main/java/org/openhab/binding/linky/internal/handler/ThingLinkyRemoteHandler.java
Outdated
Show resolved
Hide resolved
....linky/src/main/java/org/openhab/binding/linky/internal/handler/ThingLinkyRemoteHandler.java
Outdated
Show resolved
Hide resolved
...rg.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/dto/IndexInfo.java
Outdated
Show resolved
Hide resolved
Thanks @lsiepel, I fixed the errors from the last copilot review. Laurent. |
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Is this still WIP? If not, please remove the label. |
No, this is ready for merge. Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review part 1 of 2, all except README and class ThingLinkyRemoteHandler
bundles/org.openhab.binding.linky/src/main/resources/OH-INF/thing/group-linky-remote-daily.xml
Outdated
Show resolved
Hide resolved
...les/org.openhab.binding.linky/src/main/resources/OH-INF/thing/group-linky-remote-monthly.xml
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.linky/src/main/resources/OH-INF/thing/group-linky-remote-weekly.xml
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.linky/src/main/resources/OH-INF/thing/group-linky-remote-yearly.xml
Outdated
Show resolved
Hide resolved
...g.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/dto/Calendrier.java
Outdated
Show resolved
Hide resolved
...openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/dto/MeterReading.java
Outdated
Show resolved
Hide resolved
...openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/dto/MeterReading.java
Outdated
Show resolved
Hide resolved
...rg.openhab.binding.linky/src/main/java/org/openhab/binding/linky/internal/dto/IndexMode.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review of README
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Hello @lolodomo, Thanks for the review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review changes in class ThingLinkyRemoteHandler until line 902
....linky/src/main/java/org/openhab/binding/linky/internal/handler/ThingLinkyRemoteHandler.java
Outdated
Show resolved
Hide resolved
* | ||
* @param channels | ||
* @param chanTypeUid | ||
* @param channelGroup | ||
* @param channelName | ||
* @param channelLabel | ||
* @param channelDesc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the parameters or comment them fully.
Same for other methods in that class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you provide Javadoc, you have to do it fully, that means mentioning all parameters and describe them.
You have now added a description to parameters but you only mentioned some of them and not all.
So either provide all parameters (with a description) or provider no parameters at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've completed all existing javadoc with all parameters
....linky/src/main/java/org/openhab/binding/linky/internal/handler/ThingLinkyRemoteHandler.java
Outdated
Show resolved
Hide resolved
if (getThing().getChannel(channelUid) != null) { | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this test before line 550.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You did not move it as expected. My idea was to do this test even before building the channel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, this make sense. So in this order:
private void addChannel(List channels, ChannelTypeUID chanTypeUid, String channelGroup, String channelName,
String channelLabel, @nullable String channelDesc) {
ChannelUID channelUid = new ChannelUID(this.getThing().getUID(), channelGroup, channelName);
if (getThing().getChannel(channelUid) != null) {
return;
}
ChannelBuilder builder = ChannelBuilder.create(channelUid).withType(chanTypeUid).withLabel(channelLabel);
if (channelDesc != null) {
builder = builder.withDescription(channelDesc);
}
Channel channel = builder.build();
if (channels.contains(channel)) {
return;
}
channels.add(channel);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that was my suggestion.
....linky/src/main/java/org/openhab/binding/linky/internal/handler/ThingLinkyRemoteHandler.java
Outdated
Show resolved
Hide resolved
....linky/src/main/java/org/openhab/binding/linky/internal/handler/ThingLinkyRemoteHandler.java
Outdated
Show resolved
Hide resolved
....linky/src/main/java/org/openhab/binding/linky/internal/handler/ThingLinkyRemoteHandler.java
Outdated
Show resolved
Hide resolved
....linky/src/main/java/org/openhab/binding/linky/internal/handler/ThingLinkyRemoteHandler.java
Show resolved
Hide resolved
....linky/src/main/java/org/openhab/binding/linky/internal/handler/ThingLinkyRemoteHandler.java
Show resolved
Hide resolved
....linky/src/main/java/org/openhab/binding/linky/internal/handler/ThingLinkyRemoteHandler.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Hello @lolodomo, I've pushed the fixes for your review of this morning. Laurent. |
Yes, you're probably right. I have commented as a response to the original comment. I would prefer to avoid the ERROR log level for the unexpected index mode. Look at my 3 comments that are not yet marked as resolved. |
IntervalReading[] iv = meterReading.baseValue; | ||
|
||
logData(iv, "Last day", DateTimeFormatter.ISO_LOCAL_DATE, Target.LAST); | ||
return iv != null && iv.length != 0 && iv[iv.length - 1] != null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, it was checked that the last value is not NaN.
You changed that to only check if the value is not null.
Is it because the API changed and NaN is no more happening ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I correctly remember, the API returns NaN for the consumption for yesterday in the early hours of the day. We detected that to know that the currently retrieved data is not yet ready and that we will have to retry later in the day.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same there, I'm not totally sure of the reason of this change.
It's perhaps related to the previous comment.
I will need more time to check it, and be sure I don't brake anything.
if (!isDataLastDayAvailable(meterReading)) { | ||
logger.debug("Data including yesterday are not yet available"); | ||
return null; | ||
return meterReading; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure of the impact of this change.
If I correctly remember, returning null was intentional and was a trigger that we don't have the data yet.
Can you explain please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I correctly remember, returning null when data is missing was to not store any data in the cache and then to be sure that the API will be requested again the next hour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've remembered have introduce this because data for new index are never available on last day.
Always have a one day difference for this index,
I've also remembered have ask Enedis team about this behavior, but I far as I remember, have no response from there so far.
And yes, previously returning null was a way to be sure to re-request the data in next hours to be sure to have them.
So I definitively need to do some more check on this point to be sure that I've not broke something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not using a different method for indexes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes perhaps a solution, or handle the return value differently base on the face we are handling index or consumption value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @lolodomo,
I've finally revert this change.
I need it at the first place because the entry for meterReading array have 1095 entries, but when reading index we have only 1094 entries, and so the last value of the array was always empty when reading index.
But at the same time, I've done some modification in MeterReading on commit (925585e / review data array bound when using index).
This modification allocate only 1094 entries in the array when we are in index mode.
So with this modification, isDataLastDayAvailable return correctly even in IndexMode.
So the hack on ThingLinlyRemoteHandler don't have any reason to persist !
I've done some test, and everything works ok like this.
Laurent
Signed-off-by: Laurent ARNAL <laurent@clae.net>
Signed-off-by: Laurent ARNAL <laurent@clae.net>
I've push the changed about this morning review. Laurent |
We don't need anymore this modification, as was already fixed by commit * review data array bound when using index (925585e ) on MeterReading. Signed-off-by: Laurent ARNAL <laurent@clae.net>
Hello @lolodomo, See my comment about the two remaining point. Laurent. |
…ly support index Signed-off-by: Laurent ARNAL <laurent@clae.net>
Support for reading index instead of basic value,
Description
This PR is about to get consumption index from the api instead of consumption value.
With consumption index, we will be able to dispatch the consumption to a specific tarif, and have graph where you can see consumption of different time area in the day.
For exemple, it will support tarif like:
Heure pleine / Heure creuse.
Tempo tariff with 6 dispatch cadran : Red, White, Blue & HP/HC.
And the first version only implement EnedisWeb gateway.