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

S10 fixes #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

S10 fixes #74

wants to merge 1 commit into from

Conversation

torbennehmer
Copy link
Contributor

A number of fixes done for my HA integration to work cleanly.

fixes #73:

  • S10E Serial number detection did not work, a missing elif masked the corresponding check
  • A few exported classes were missing (notably SendError for error detection)
  • Calls to set_power_save and set_weather_regulated_charge were not correctly parsing the results from E3DC. (Did some code streamlining to those functions on the way)

Copy link
Collaborator

@vchrisb vchrisb left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution.
I made a few comments.

e3dc/_e3dc.py Outdated Show resolved Hide resolved
e3dc/_e3dc.py Outdated Show resolved Hide resolved
e3dc/_e3dc.py Outdated Show resolved Hide resolved
e3dc/_e3dc.py Outdated
Comment on lines 2033 to 2051
# Returns the new value of EMS_RES_WEATHER_REGULATED_CHARGE_ENABLED, we need
# to validate this against the desired value, the object looks like this:
# [ "EMS_SET_POWER_SETTINGS",
# "Container",
# [
# ["EMS_RES_WEATHER_REGULATED_CHARGE_ENABLED", "Char8", 0]
# ]
# ]

# validate new value
if (
rscpFindTagIndex(res, "EMS_RES_WEATHER_REGULATED_CHARGE_ENABLED")
== newValue
):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Using rscpFindTagIndex is nice.

EMS_RES_WEATHER_REGULATED_CHARGE_ENABLED is not returning the actual set value but rather 0 if the new value was set successfully.
Therefore checking against 0 was correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe the S10 is behaving differently here? I see things differently here, basically:

A call e3dc.set_weather_regulated_charge(False) to my S10 always yields this result, with weather regulated charging successfully disabled:

[
  "EMS_SET_POWER_SETTINGS",
  "Container",
  [
    [
      "EMS_RES_WEATHER_REGULATED_CHARGE_ENABLED",
      "Char8",
      0
    ]
  ]
]

This is a dump of the res structure directly after teh call to sendRequest. If I call e3dc.set_weather_regulated_charge(True), I always get this:

[
  "EMS_SET_POWER_SETTINGS",
  "Container",
  [
    [
      "EMS_RES_WEATHER_REGULATED_CHARGE_ENABLED",
      "Char8",
      1
    ]
  ]
]

Again, independant of the number of calls, the feature is enabled successfully. This is what I see reverse-engineering my own unit. What I was unable to do though is trying to force an error. So I can't tell how this call behaves if for any reason the S10 could not set the value.

How does your unit behave?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vchrisb should I drop the Weather Regulated Charge changes from this PR until these questions are resolved so that the other changes can be merged?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll have a look in the evening at my E3DC how it behaves.

Copy link
Collaborator

Choose a reason for hiding this comment

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

1 is enabling weather regulated charge any other value is disabling it.
The return value is 1 for True/1 and 0 for all other positive integers.
E3DC API consistency...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you test again?
You shouldn't be able to send 3000 at all, as it is larger than 255.
Further up you did report the same behavior like me. I do not expect E3DC to implement APIs differently.

set_weather_regulated_charge should only need to support boolean. We might add type annotations.

Copy link
Contributor Author

@torbennehmer torbennehmer May 16, 2023

Choose a reason for hiding this comment

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

I have created a test run, the code it uses is attached to this file. It basically calls set_weather_regulated_charge repeatedly and rereads the current state afterwards alongside the return value of the call itself. What I get is this:

WRC state: False
Setting WRC to int 0, got 0, new state: False
Setting WRC to int 1, got -1, new state: True
Setting WRC to int 0, got 0, new state: False
Setting WRC to int 2, got -1, new state: True
Setting WRC to int 0, got 0, new state: False
Setting WRC to int 5, got -1, new state: True
Setting WRC to int 0, got 0, new state: False
Setting WRC to int 3000, got -1, new state: True
Setting WRC to int 0, got 0, new state: False
Setting WRC to int 0, got 0, new state: False
WRC state: False

sample.txt

Explicitly, there seems to be no error when sending 3000 to the API (i understand, that it's an 8 bit type, I'd have expected an exception here, but did not dive further in the code. Maybe python casts this implicitly, but honestly, its probably beside the point. If we define the argument as bool, this will be of no more importance. The Int 3000 correctly runs on an error, the current master code does check this beforehand, so that the 3000 never reaches the E3DC RSCP code. I beg your pardon here, I had another piece of code in my mind.

Essentially, if we break it down to zero/nonzero, we are identical. What I think is, that there are subtle details in the hardware, one returning 0x01 for active, the other 0xFF. I'll rebase this branch onto the current master and build you a new proposal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new version of this branch should now fix this. current test output:

WRC state: False
Setting WRC to int 0, got 0, new state: False
Setting WRC to int 1, got 0, new state: True
Setting WRC to int 0, got 0, new state: False
Setting WRC to int 2, got 0, new state: True
Setting WRC to int 0, got 0, new state: False
Setting WRC to int 5, got 0, new state: True
Setting WRC to int 0, got 0, new state: False
Setting WRC to int 3000, got 0, new state: True
Setting WRC to int 0, got 0, new state: False
Setting WRC to int 0, got 0, new state: False
WRC state: False

This should now correctly give us the result state. Unfortunately, I could not bring the E3DC to actually return an error (no idea how I can get the call to fail), but the happy path does work.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I can't remember that we hand an inconsistency in the past. AFAIK E3DC does ship the same firmware for the different S10 models.
Which model and release version do you have?
It would be great to find other folks to comment on their observations before proceeding.

FWIW the E3DC support was helpful in the past to shed some light on these topics.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Contacting support is a good idea (even though I've got one open ticket for 2-3 weeks now w/o response, but not trying will be even less helpful). Unfortunately, in the RSCP-Tags-Official.xlsm there is no clear documentation on the return value. It sure sounds that it schould return the current value.

I've got an S10E from 2015, Firmware Version S10_2023_02, Serial Number starts with 4515... What do you use?

@torbennehmer
Copy link
Contributor Author

torbennehmer commented May 7, 2023

@vchrisb I have just created another PR without the changes around weather regulated charging. That should allow you to move on, while we get to the bottom of this here :)

#75 open

@torbennehmer torbennehmer force-pushed the s10-fixes branch 4 times, most recently from aadd95c to df22fef Compare May 16, 2023 16:12
- normalize all arguments to a boolean
- fix result code detection, some E3DCs report active weather regulation
  as 1, others as -1
- result code is the new state of weather regulated charging, so we
  deduce the success value bycomparing with the originally requested
  value.
- Update source code comments accordingly.
@torbennehmer
Copy link
Contributor Author

@vchrisb How should we continue here, I still think we have some different behviour here depending on unit type. If this is easier for you, we could also take this discussion offline and do it in German language.

@eikowagenknecht
Copy link
Contributor

If you need to test with yet another device (S10 X Compact 14), feel free to contact me :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Various fixes needed for HA integration
3 participants