-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[energidataservice] Fix @ActionOutput annotations #17679
Conversation
Actions 1 & 2: output annotation unchanged, I don't know what to do. Action 3: proper output annotation. Should be ok once the new core PR is merged. Actions 4 & 5: proper outputs annotation. Should work. Actions 6 & 7: proper outputs annotation. Should not be visible in Main UI due to incompatible type in input parameters. |
@lolodomo - thanks! I'll give this a test later, hopefully in the evening. |
...ain/java/org/openhab/binding/energidataservice/internal/action/EnergiDataServiceActions.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.
Annotations look good to me, just one question.
Wrt to actions 1 & 2: If core serialises the return value to a object with Instants as keys and prices as values, the UI will render it. It should be serialisable, but not sure how to do that exactly in core.
...ain/java/org/openhab/binding/energidataservice/internal/action/EnergiDataServiceActions.java
Outdated
Show resolved
Hide resolved
...ain/java/org/openhab/binding/energidataservice/internal/action/EnergiDataServiceActions.java
Outdated
Show resolved
Hide resolved
...ain/java/org/openhab/binding/energidataservice/internal/action/EnergiDataServiceActions.java
Outdated
Show resolved
Hide resolved
...ain/java/org/openhab/binding/energidataservice/internal/action/EnergiDataServiceActions.java
Outdated
Show resolved
Hide resolved
...ain/java/org/openhab/binding/energidataservice/internal/action/EnergiDataServiceActions.java
Outdated
Show resolved
Hide resolved
...ain/java/org/openhab/binding/energidataservice/internal/action/EnergiDataServiceActions.java
Outdated
Show resolved
Hide resolved
@lolodomo - just a note: You can easily test the binding by creating a Thing and selecting one of the price areas, and optionally a grid company. Example configuration: UID: energidataservice:service:energidataservice
label: Energi Data Service
thingTypeUID: energidataservice:service
configuration:
gridCompanyGLN: "5790001089030"
energinetGLN: "5790000432752"
priceArea: DK1
currencyCode: DKK
reducedElectricityTax: false As file: Thing energidataservice:service:energidataservice "Energi Data Service" [ priceArea="DK1", currencyCode="DKK", gridCompanyGLN="5790001089030" ] {
} |
First, use the API explorer and the GET endpoint to know what is returned to Main UI. This will help to know if not visible actions are due to core framework or Main UI. |
But I believe @florian-h05 already told us that different actions cannot have the same label. That is very probably why some are not visible in UI. |
Probably, yes. So for now there is no reason to change/annotate any of those. |
We just have to change labels. I will try to make this work during the weekend. |
Technically I think this should work fine, but it is quite confusing for the user. |
It is not possible to have several actions with the same method name and the same scope because they will have same id in the registry. |
@jlaur : do you prefer renaming the methods (breaking change) or keeping the current method names but without the ability to run them from Main UI ? For the two first actions (get prices) with their atypical return type, maybe the best to simply to fully remove annotations so that they are simply not shown in Main UI ? |
As mentioned here, the only real use-case of these actions is to be used in rules. When I created them, I tested in both Rules DSL and JavaScript, and all actions were working. Unless support for method overloads will be removed from core, I would prefer to not change the names:
Agreed. Price calculations could be nice as a kind of demo of the power of the actions, but besides letting users trying the actions before implementing them in rules, it's not important. |
Ok so I close this PR. |
So what remains now is to simply remove annotations - and they are only used by the REST API?
|
They are only used for invoking Thing actions through the UI or adding them to UI-based rules, where you can select them from the all actions list. |
I reopen the PR as I implemented the solution in core framework to distinguish actions with the same method name. |
It sounds like the actions provided by this binding have been broken right from the start, since I never tested UI-based rules. 😢 |
To be fair, UI support for them was added just a few weeks ago so you could not test that before. |
Phew, thanks. 😀 I thought you could do the same in UI rules as in file-based, but it never crossed my mind to test rules and actions from the UI. |
Related to openhab#17636 Signed-off-by: Laurent Garnier <[email protected]>
63bbe4a
to
ce61286
Compare
I pushed new code but we need the merge of core PRs first. |
...ain/java/org/openhab/binding/energidataservice/internal/action/EnergiDataServiceActions.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Laurent Garnier <[email protected]>
Could someone link the PR that this depends on? |
For sure openhab/openhab-core#4438. I think the others are now merged. |
Signed-off-by: Laurent Garnier <[email protected]>
Signed-off-by: Laurent Garnier <[email protected]>
@lolodomo - I will test this again when the new milestone is available. |
Tests with snapshot build 4374 and binding built from this PR: I guess the "get prices" method should not have been shown since they are both marked as hidden? First "calculate cheapest period":
Now corrected to "PT60M":
I then realized this is because my development time-zone is currently set to US/Alaska, so it seems these times are converted (correctly) from local datetime to UTC ( When having no deserialization of The next "calculate cheapest period" method: Here the prices are available, so this method makes sense to expose. Method "calculate price" is perfect: Btw, in Firefox (no time selection): in Chrome: FYI @florian-h05 I see a lot of good progress - cool! |
The visibility field is not used by the UI yet, thanks for reminding me to implement that. Wrt to proper Instant serialisation: This should be added IMO. Wrt to Firefox not displaying a time picker: This is a Firefox bug, see https://bugzilla.mozilla.org/show_bug.cgi?id=1726108. |
Do you think anything should be added for providing/selecting and/or validating |
Hmm AFAIK nothing is provided by Framework7 or the browser, so we would have to build this ourselves. |
I agree, but had to ask. 😄 From a rule context, e.g. from JavaScript, it's straight-forward and logical to provide a |
Hmm, our date time library in the UI, dayjs(), supports Duration construction and parsing. We could provide a picker where one could select seconds, minutes, hours, days, weeks, months (whatever) and build a duration string from it or parse a duration string to validate it, see https://day.js.org/docs/en/durations/creating. |
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.
LGTM
Related to #17636
Depends on openhab/openhab-core/pull/4438