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

[ferroamp] Binding for Ferroamp 20241010 #17536

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

basse04
Copy link
Contributor

@basse04 basse04 commented Oct 10, 2024

This is the binding for local connection to the Ferroamp Energy System

This is the binding for local connection to the Ferroamp Energy System

Signed-off-by: Örjan Backsell <[email protected]>
@basse04 basse04 requested a review from a team as a code owner October 10, 2024 10:17
Changes done in FerroampHandlerFactory.java

Signed-off-by: Örjan Backsell <[email protected]>
@lsiepel lsiepel added enhancement An enhancement or new feature for an existing add-on new binding If someone has started to work on a binding. For a new binding PR. and removed enhancement An enhancement or new feature for an existing add-on labels Oct 10, 2024
@basse04
Copy link
Contributor Author

basse04 commented Oct 10, 2024

Hi @lsiepel ,
I have had an system-disc crach, mine SSD got full without telling me before it went totally out of order. So I had to install an entire new OS ( Linux Mint 21.3) and everything else I need. So I thought that the best then was to also create a new branch ( ferroamp_v4).
There was initially problems with Maven, I had an old version installed that mvn locally liked but not the checks as above, this is now solved.
And then a question regarded to that, mvn locally complained and said I shold use Maven 3.8.1, I have now installed Maven 3.8.8 and it seems to work, do you think I should use any later version or will this one be fine?
BR Basse

Copy link
Contributor

@lsiepel lsiepel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it had some passes before i keep this short. Left comments mainly looking at the readme. Some suggestions need to be adapted on multiple places. The binding is improving, so good to see progress.

bundles/org.openhab.binding.ferroamp/README.md Outdated Show resolved Hide resolved
bundles/org.openhab.binding.ferroamp/README.md Outdated Show resolved Hide resolved
bundles/org.openhab.binding.ferroamp/README.md Outdated Show resolved Hide resolved
bundles/org.openhab.binding.ferroamp/README.md Outdated Show resolved Hide resolved
bundles/org.openhab.binding.ferroamp/README.md Outdated Show resolved Hide resolved
bundles/org.openhab.binding.ferroamp/README.md Outdated Show resolved Hide resolved
bundles/org.openhab.binding.ferroamp/README.md Outdated Show resolved Hide resolved
bundles/org.openhab.binding.ferroamp/README.md Outdated Show resolved Hide resolved
bundles/pom.xml Show resolved Hide resolved

The following configuration parameters are available.

| Name | Type | Description | Default | Required | Advanced |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the thing-types.xml the eso and esm parameters are missing.

Would be nice if these setting scould be auto detected by the binding instead of manually configuring.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in README.
I will think about auto detect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eso and Esm modules seems not to be so very common so I think we leave these 2 as optional in configuration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still wondering if you can in someway detect if SSO1-4, ESM or ESO is present by using the API ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20241115
Changes done regarded to SSO's, they are now detected automatically.
Eso and Esm modules seems not to be so very common so I think we leave these 2 as optional in configuration, and the very same for the battery.

@basse04
Copy link
Contributor Author

basse04 commented Oct 24, 2024

Please, see each Conversion for latest answers.
I have also done a new ferroamp.properties
Br Basse

Changes done in README.md, 20241010

Örjan Backsell <[email protected]>

Signed-off-by: Örjan Backsell <[email protected]>
Done changes in EhubParameters.java, FerroampBindingConstants.java,
FerroampChannelConfiguration.java, ferroamp.xml, README.md

Signed-off-by: Örjan Backsell <[email protected]>
Changes done in:
EsmParameters.java
EsoParameters.java
ferroamp.xml
FerroampBindingConstants.java
FerroampChannelConfiguration.java
README.md
SsoParameters.java

Signed-off-by: Örjan Backsell <[email protected]>
Changes done in README.md

Signed-off-by: Örjan Backsell <[email protected]>
Changes done, Please see Reply...regarded to each conversion

Signed-off-by: Örjan Backsell <[email protected]>
Changes done in FerroampHandler.java

Signed-off-by: Örjan Backsell <[email protected]>
Please, see each Conversion for latest answers

Signed-off-by: Örjan Backsell <[email protected]>
@basse04
Copy link
Contributor Author

basse04 commented Oct 25, 2024

Hi, @lsiepel, finally have I found a solution for the, for me very embarrassing misstake to forgot about the first part of sign-off in one commit.
But now it seems to be solved, puh :-)
I wish you a nice weekend!
Br Basse

Copy link
Contributor

@lsiepel lsiepel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another round with suggested improvements. Hopefully this will lead to more improvements. Please verify the changes you make match the asked changes or comment what you did and why, as that helps to speed up.

Have not yet looked at too much java code. I did notice quit verbose json handling with element indices and all that. Might be perfectly sane, but usually when you have json, it is best to use proper DTO's. But first let's fix the already made comments.

Oh yes, another question, did you consider to use channel groups ? They seem a perfect fit for the sso, as you could define 1 set of channels and duplicate it for each group.

}

public static List<String> getChannelParametersEhub() {
final List<String> channelParametersEhub = Arrays.asList("grid-frequency", "ace-current-l1", "ace-current-l2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This method does not seem to be used anywhere.
  2. Use the defined FerroampBindingConstants where possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20241107
Deleted the class. Has been used earlier, but I have missed to delete it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you forget to push these changes as it is still there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20241111, Deleted

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20241115
I had a look at channel-groups, but I think it look like it's the very same lines just split into several xml files instead of one thing-types.xml

}

public static List<String> getChannelParametersEsm() {
final List<String> channelParametersEsm = Arrays.asList("esm-unique-identifier", "esm-soh", "esm-soc",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the channel string constants defined in FerroampBindingConstants.java

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20241107
Deleted the class. Has been used earlier, but I have missed to delete it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20241111, Deleted

}

public static List<String> getChannelParametersEso() {
final List<String> channelParametersEso = Arrays.asList("eso-unique-identifier", "eso-measured-voltage-battery",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the channel string constants defined in FerroampBindingConstants.java

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20241107
Deleted the class. Has been used earlier, but I have missed to delete it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20241111, Deleted

public class SsoParameters {

public static List<String> getChannelParametersSso() {
final List<String> channelParametersSs0 = Arrays.asList("id", "measured-voltage-pv-string",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the channel string constants defined in FerroampBindingConstants.java

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20241107
Deleted the class. Has been used earlier, but I have missed to delete it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20241111, Deleted

bundles/org.openhab.binding.ferroamp/README.md Outdated Show resolved Hide resolved

private void startMqttConnection() throws InterruptedException {
try {
TimeUnit.SECONDS.sleep(10);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this sleep ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20241107
It seems like the broker in the Ferroamp EnergyHub need some time to start sending.
There will be an complaining about that MqttBrokerConnection localSubscribeConnection in method getMQTT in ferroampMqttComminication is null otherwise

Copy link
Contributor

@lsiepel lsiepel Nov 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest that two lines of getMQTT is moved to this startMqttConnection() method, as these lines should only be fired once. and not for each subscription?!

        localSubscribeConnection.start();
        localSubscribeConnection.setCredentials(ferroampConfig.userName, ferroampConfig.password);

getMQTT should also be renamed to subscribeTopic (or something similar)

Besides the above, this sleep still bothers me. First i looked at the MQTT bindings and could not find anything similar, but they are totally different in setup. Adn then i asked myseldf why is this no subbindingof mqtt just like the others? Like mqtt.ferroamp did you consider this and can you share some insights why not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have problems with that it seems like I have to wait for broker to start sending. (I have no system on mine own so I use one at a friend, might be a reason for the delay, but thats just a guess).
Anyhow, the sleep was an emergency solution to handle this delay, but I think I found another solution, Please have a look in FerroampHandler.java.

I have changed the name to getSubscribedTopic.

Sleep and scheduler.execute(() -> {.... is both now taken away due to that both were regarded to my tries to handle the delays.

When I started with this binding did I found some solution( don't remember which ) simiilar to this one. I have then down the road also seen the mqtt.x solution, but I thought that I shall continue to do it the way I have started, so actually no reasons, other then I think that has been a way for me as nopro to get any kind of a working and for me understandable solution.

public class EsoParameters {
public String jsonPostEso;

public EsoParameters(String jsonPostEso) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This method does not seem to be used anywhere.
  2. Use the defined FerroampBindingConstants where possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20241107
Deleted this class, it's not used anymore

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20241111 Deleted

this.jsonPostEsm = jsonPostEsm;
}

public static List<String> getChannelParametersEsm() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This method does not seem to be used anywhere.
  2. Use the defined FerroampBindingConstants where possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20241107
Deleted this class, it's not used anymore

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20241111 Deleted

Changes done in:
EhubJsonElements.java
EsmJsonElements.java
EsoJsonElements.java
ferroamp.properties
FerroampBindingConstants.java
FerroampChannelConfiguration.java
FerroampConfiguration.java
FerroampHandler.java
FerroampMqttCommunication.java
SsoJsonElements.java
thing-types.xml

Signed-off-by: Örjan Backsell <[email protected]>
@basse04
Copy link
Contributor Author

basse04 commented Nov 7, 2024

Please see above, I think I have answered all of your suggestions. Btw, Thanks!
I will have a look at the suggestions left asap
Br Basse

Changes done in:
FerroampHandler.java
FerroampMqttCommunication.java
README.md

Signed-off-by: Örjan Backsell <[email protected]>
@basse04
Copy link
Contributor Author

basse04 commented Nov 11, 2024

2024111
Done some changes, Please see each for info.
Br Basse

Done changes in:
FerroampConfiguration.java
FerroampHandler.java
FerroampMqttCommunication.java
README.md

Signed-off-by: Örjan Backsell <[email protected]>
@basse04
Copy link
Contributor Author

basse04 commented Nov 15, 2024

2024115
Done some changes, Please see each for info.
Br Basse

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new binding If someone has started to work on a binding. For a new binding PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants