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

Strange behavior from the “cableLocked” sensor (or actually switch) #32

Closed
TheAzzi opened this issue Sep 11, 2020 · 37 comments
Closed

Comments

@TheAzzi
Copy link

TheAzzi commented Sep 11, 2020

From forum: https://community.home-assistant.io/t/easee-ev-charging-station/186474/70

Hi,

I started testing this integration today, and so far it looks very promising. Thank you @fondberg and the rest of the developers! :-)

I did notice some (in my opinion) strange behavior from the “cableLocked” sensor (or actually switch), switch.easee_charger_ehXXXXXX_cablelocked, and I was just wondering if this is by design or a bug:

  • If a car is connected to the charger, and the “permanent lock” is enabled, the “cablelocked” switch is “on”.

  • I go ahead and turn the “cablelocked” switch to “off” in Home Assistant.

  • This disables the “permanent lock” option as I can verify this in the Easee app and web page.

  • However the “cablelocked” switch will jump back to “on” in Home assistant. (Probably because the cable is still in fact locked as there is a car connected).

  • I can not re-enable the “permanent lock” from Home Assistant, as the switch is already “on”.

  • This means there is an inconsistency between what the switch displays (state.cableLocked?), and what the switch actually does when switched (state.lockCablePermanently?).

(Sidenote: If a car is not connected to the charger, the switch will function more as expected, as the state.lockCablePermanently and state.cableLocked will be the same state (both true or both false), however there is a delay where the switch goes back to the previous state for a while before it updates).

In my opinion this is not logical behavior from a switch, and my suggestion is to divide this in 2 parts:

  • A switch which relates only to the “permanent lock” so this function can be easily switched on/off (both manually and in automations).

  • A sensor for showing if the cable is locked or not (this is basically what the switch shows as it is now, however this should not be a switch as you cannot control this anyway. You can only control if the cable is permanently locked or not)

@fondberg
Copy link
Contributor

I think there are 2 values that determine the state of the switch but we need to check this further.

We are right now in the middle of getting this as an official integration in HA and there will take some time before all functionality is ported (starting with sensors only)

@tmjo
Copy link
Collaborator

tmjo commented Sep 12, 2020

As fondberg says, there state of the switch is determined by either locked or permanently locked. Perhaps it would be better to split it as you say, it was more a quick fix since we noticed that the locked state was not changed by permanently locking (which may or may not be a bug on Easee side?). Also there are some improvements needed to make sure the switch is updated after changing it, not waiting a minute or so. I'll look into it.

@TheAzzi
Copy link
Author

TheAzzi commented Sep 14, 2020

Great, thank you for looking into this.
I do believe being able to easily control the “permanent lock” will be one of the most useful features of this integration for users like me who have 2 different EVs and need to switch between 2 different charging cables quite often.

@tmjo
Copy link
Collaborator

tmjo commented Sep 18, 2020

See proposal in #36

PS! There is still a delay between activating the switch in HA and getting the actual update/status. It seems to update quite immediately in the Easee app, so switch is working fine, however need to check how to force an update after calling the function (avoid waiting for SCAN_INTERVAL_SECONDS to see the actual value).

@TheAzzi
Copy link
Author

TheAzzi commented Sep 20, 2020

Looks good! As far as I can understand, this is the same as I was thinking.
(Am I supposed to to any review stuff on the proposal? - I'm new to GitHub)

@tmjo
Copy link
Collaborator

tmjo commented Sep 24, 2020

Released in 0.9.15, please test and see if ok.

@TheAzzi
Copy link
Author

TheAzzi commented Sep 24, 2020

Awesome! I'm currently at work, so I have only been able to do limited testing so far.
The "cable_permanently_locked_charger" switch works great (Except the delay which you are already aware of)

I will do some more extensive testing of the "cable_locked_car" sensor when I get home, so I can test if it behaves correctly with car connected and disconnected.

However I noticed one small strange thing in the history of the sensor (not sure if it is related to the integration or HA itself):
When the sensor is "False" you can see "Changed to False" in the history, but when the sensor is "True" the "Changed to False" disappears from the history and I only see the "Changed to True" entries like this:

13:49:48
Changed to True
13:40:48
Changed to True
13:28:48
Changed to True

@TheAzzi
Copy link
Author

TheAzzi commented Sep 25, 2020

I was able to do some more testing this morning, and I'm happy to report the "cable_locked_car" sensor also works great.

Everything works as it should:

  • If the cable is permanently locked, the sensor is "True" no matter if a car is connected or not
  • If the cable is not permanently locked, the sensor is "True" if car is connected, and "False" if car is disconnected.

Great work, thanks a lot!

Small sidenote regarding the naming of the sensor: I do think the "car" part of the name is slightly misleading.

It may lead someone to think it is related to locking the car end of the cable, or that it's state is only determined by the car, while in fact it's an indicator if the cable is currently locked to the charger or not, which is determined by a combination of the car (connected / not connected) and the charger (the permanent lock).

To avoid confusion they could be named something like this:
sensor: "cable_locked_car" -> "cable_locked_currently" or even just "cable_locked"
switch: "cable_permanently_locked_charger" -> "cable_locked_permanently"

@tmjo
Copy link
Collaborator

tmjo commented Sep 25, 2020

Ok, good. I actually thought it was the car end locking it. But if that's not correct, we should rename it for sure. What I don't understand then: shouldn't it be locked always when permanently locked is enabled? independent of car connected or not?

This may very well be the reason for this confusion, because I noticed there was some inconsistency (in my head at least) on this quite early. For instance my charger currently shows cableLocked=false and cablePermanentlyLocked=true while car is disconnected. Then I'm talking about the Easee API directly, not the sensors although they should be the same now.

@TheAzzi
Copy link
Author

TheAzzi commented Sep 25, 2020

(NOTE: Everything I write below is based on the opinion that the sensor should tell me: "Will I be able to pull the cable from the charger or not")

Yeah, it is actually always locked if the permanent lock is enabled, as I wrote after my testing this morning:

  • If the cable is permanently locked, the sensor is "True" no matter if a car is connected or not
  • If the cable is not permanently locked, the sensor is "True" if car is connected, and "False" if car is disconnected.

To clarify, if the cable is permanently locked and the car is disconnected, you will see state.lockCablePermanently=True and state.cableLocked=False, but the actual sensor is True (i.e. Locked). The sensor will switch to False when both of them are False. Which in my opinion is correct, since you are not able to pull the cable from the charger if either of them is True.

So in my opinion both the sensor and the switch now works perfectly as they should, it's just the naming that is somewhat confusing.

@tmjo
Copy link
Collaborator

tmjo commented Sep 25, 2020

Sorry, I think my head is slow today, but stay with me.

I agree with your statement:

"....if the cable is permanently locked and the car is disconnected, you will see state.lockCablePermanently=True and state.cableLocked=False, but the actual sensor is True (i.e. Locked). The sensor will switch to False when both of them are False.

But this isn't the case now is it? The switch controls the permanently_locked, while the sensor just displays the state.CableLocked. So what I see on my end is permently locked True but sensor cable_loced False. Your argument above was exactly why there was an or between the two states originally, but it was kindof messed up when it became a switch (since we actually just control the permanently_locked).


    "cable_locked_car": {
        "key": "state.cableLocked",
        "attrs": [
            "state.lockCablePermanently",
            "state.cableLocked",
        ],
        "units": None,
        "convert_units_func": None,
        "icon": "mdi:lock",
    },
    "cable_permanently_locked_charger  ": {
        "type": "switch",
        "key": "state.lockCablePermanently",
        "attrs": [
            "state.lockCablePermanently",
            "state.cableLocked",
        ],
        "units": None,
        "convert_units_func": None,
        "icon": "mdi:lock",
        "switch_func": "lockCablePermanently",

My states are currently permanently_locked = True and cable_locked = false identical to the Easee values from API.
image

If I understood you correctly, you would expect the cable_locked = cableLocked OR cablePermanentlyLocked?

@TheAzzi
Copy link
Author

TheAzzi commented Sep 25, 2020

Strange, I have different behavior. Currently with no car connected:
sensor: cable_locked_car = True
switch: cable_permanently_locked_charger = on

However I just noticed that "state.cableLocked" is in fact "true" on my charger even with no car connected, as long as the permanent lock is also on. Which kind of makes sense, because the cable is in fact locked as long as the permanent lock is on. If i disable the permanent lock, with to car connected, the "state.cableLocked" changes to "false".

So I was mistaken when I said "To clarify, if the cable is permanently locked and the car is disconnected, you will see state.lockCablePermanently=True and state.cableLocked=False, but the actual sensor is True (i.e. Locked)".

It seems like the only time these two states are different for me, is if there is a car connected, but the permanent lock is off. In that scenario I will have state.cableLocked=true (because there is a car connected which forces the charger to lock the cable) while state.lockCablePermanently=false (because it is not permanently locked). - I will verify this when I get home.

It is strange you have different behavior, what firmware is your Easee on? I'm currently on 235, but will now upgrade to the latest (240) and see if it changes anything.

@tmjo
Copy link
Collaborator

tmjo commented Sep 25, 2020

I upgraded to 240 yesterday, but quite sure it was like this before as well. Because I added the cable_locked = cableLocked OR cablePermanentlyLocked initially because I thought it was annoying :) either it is locked or its not was my thinking.

But I guess we can keep the switch as is, but rename cable_locked_car to cable_locked = cableLocked OR cablePermanentlyLocked if we agree that's what we want? I believe that's what the Easee app is showing (blue icon), but the API is different. That is why I thought it had to be the car, and proposed the _car name which is wrong then.

@TheAzzi
Copy link
Author

TheAzzi commented Sep 25, 2020

In the app the blue icon indicates the permanent lock. (Click the "i" top right corner, and "cable lock" to see the explanation)
If the cable is locked due to charging (but not permanently), the icon is still white, but with a small padlock in it.

I have now updated to 240 and restarted Home Assistant, and still have the same behavior.

I came to think of another possible difference: Did you have the cable connected to the charger or not when you took that screenshot?

@tmjo
Copy link
Collaborator

tmjo commented Sep 25, 2020

Right, I see. Blue is permanent but it will also indicate that it is locked. My cable is connected to the charger, I always leave it there (can it be permanently locked if it isn't connected to charger??).

@TheAzzi
Copy link
Author

TheAzzi commented Sep 25, 2020

I was really curious about this, so I called my wife and had her remove the cable from the charger. When I enabled the permanent lock with the cable removed, I could also end up with the same result as in your screenshot:
cable_locked_car = False
cable_permanently_locked_charger = on
(and also state.lockCablePermanently=true and state.cableLocked=false)

When she plugged the cable back in (permanent lock still on) it did not seem to lock, and nothing updated. But after disabling and enabling the permanent lock, it locked as it should, and the previous behavior was back, where cable_locked_car = True when cable_permanently_locked_charger = on.

I wasn't able to do any more testing as my wife wanted to go back inside :p so I will test some more when I get home (but it will be really late). Maybe this is due to different cables or something like that.

Honestly I'm not sure what the best solution is, since for me it is working perfectly as it is right now (just with a slightly confusing name for the sensor).

@tmjo
Copy link
Collaborator

tmjo commented Sep 25, 2020

Hehe, good work! I guess there's no hurry, let's leave it for some days to be 100% sure before we conclude and change it the way it should be :)

@TheAzzi
Copy link
Author

TheAzzi commented Sep 25, 2020

Yeah I agree, this is not urgent at all. For me the switch is most important (since we have to switch between two cables - Leaf with type 1 and Tesla with type 2) and that work perfectly, so I'm really happy I found this component. Have a nice evening and thanks again. :-)

@fondberg
Copy link
Contributor

@TheAzzi
Copy link
Author

TheAzzi commented Oct 15, 2020

The switch "cable_permanently_locked_charger" was broken in 0.9.17, but works great again in 0.9.19.

The different behavior of the "cable_locked_car" sensor for me and tmjo seems to be related to how the charger reports the state.cableLocked. In my opinion it is correct for the sensor to report the same as state.cableLocked, like I believe it does currently.

So as far as I'm concerned no further change is needed related to this, except perhaps removing the "car" part of the "cable_locked_car" sensor name, as it might be misleading as mentioned previously.

@tmjo
Copy link
Collaborator

tmjo commented Oct 15, 2020

Hi! Did u do any more testing of the values?

Here's my last logs, as one can observe, charging is performed, and cable is always permanently locked. However, the cable_locked_car sensors does not change. Does it appear locked in your case?

image

I can ask Easee about this topic, but would be great if you could provide something similar to the above. Any ideas why it could be different?

@TheAzzi
Copy link
Author

TheAzzi commented Oct 15, 2020

Yeah, I did a quick test session now to make a screenshot from the History, so you can see how it works:

easee-ha2

What happens here is:

  • Status when I go outside: cable is connected, permanent lock is on, no car is connected
  • 19:37: First I turn off the permanent lock to change to another cable (notice "cable_locked_car" changes to "Unlocked")
  • 19:39: I connect the cable to the car to start charging (notice "cable_locked_car" changes to "Locked" while charging)
  • 19:41: I stop the charging and remove the cable from the car (notice "cable_locked_car" changes to "Unlocked" when charging stops)
  • 19:42: I turn on the permanent lock to demonstrate how it looks with permanent lock on (notice "cable_locked_car" changes to "Locked")
  • 19:43: I connect cable to car again and start charging
  • 19:46: I stop the charging (notice "cable_locked_car" stays "Locked" because permanent lock is on)
  • 19:47: I turn off permanent lock to change back to the first cable (notice "cable_locked_car" changes to "Unlocked")
  • 19:49: I turn on permanent lock (notice "cable_locked_car" changes to "Locked")

So in summary:

  • If permanent lock is on, "cable_locked_car" is always "Locked"
  • If permanent lock is off, and car is connected/charging, "cable_locked_car" is "Locked"
  • If permanent lock is off, and no car is connected, "cable_locked_car" is "Unlocked"

In my opinion this works exactly as it should (Meaning: "cable_locked_car" tells me "will I be able to pull the cable from the charger or not?")

Sidenote:
In the very first event in the history screenshot, the permanent lock and "cable_locked_car" updates at the exact same time.
However later on (19:42, 19:47 and 19:49) there is a delay between the permanent lock and "cable_locked_car".
I believe this is because in the very first event, i turned off the permanent lock from the Easee app, so it was polled in HA at the same time. However the other changes was done with the permanent lock switch in HA, so the "cable_locked_car" is updated at the next polling interval. This is not an issue, just pointing it out in case it confused anyone.

@tmjo
Copy link
Collaborator

tmjo commented Oct 15, 2020

Hmm, interesting. Wonder why mine is not updating similarly...... You're description is how I would expect it to work.

@TheAzzi
Copy link
Author

TheAzzi commented Oct 15, 2020

As for why it's different, I can only guess either your Easee is broken, or they added the functionality/sensor at a later hardware model (mine is fairly new; I got it this summer). Ideally someone else should test as well.

@TheAzzi TheAzzi closed this as completed Oct 15, 2020
@TheAzzi TheAzzi reopened this Oct 15, 2020
@TheAzzi
Copy link
Author

TheAzzi commented Oct 15, 2020

(I clicked the "Close" button by mistake)

@tmjo
Copy link
Collaborator

tmjo commented Oct 15, 2020

Got my charger in June or July, so don't think it is different. Firmware is latest. But I'll try to figure out why.

@olalid
Copy link
Collaborator

olalid commented Jan 9, 2021

Is not the issue only the name of the switch/sensors?
I too have been very confused by why the sensor for the car changes states to locked even when there is no car connected if the permanently locked switch is engaged. But turns out it is not about the car at all...

In the API easee calls these 2 values lockCablePermanently and cableLocked.
So it seems the "car" part of the sensor is probably a misinterpretation.

So I suggest we change the switch name to "Permanent cable lock" and the sensor name to "Cable lock".

@olalid
Copy link
Collaborator

olalid commented Jan 30, 2021

@TheAzzi, @tmjo, @fondberg what do you think of my suggestion above?

@TheAzzi
Copy link
Author

TheAzzi commented Feb 1, 2021

@olalid I like the suggestion, works for me.
I think we were slightly confused because mine and tmjos charger behaved somewhat differently.

@olalid
Copy link
Collaborator

olalid commented Feb 1, 2021

Yes, I think there has been bugs in certain versions och HA component and Easee SW/firmware, so not so sure the differences seen are really valid anymore. But the behavior I see on my charger is equal to what you stated above.
I.e. the switch enables the permanent lock, such that the cable is always locked in the charger.
The sensor tells you if the cable is locked, independent of the reason why it is locked. It can be either because charging is ongoing or if the permanent lock is enabled.
But would be good to hear an update from @tmjo.

@TheAzzi
Copy link
Author

TheAzzi commented Feb 1, 2021

Yeah, that sums it up pretty good, and it also feels like this is the "correct" behavior as well.
So for improving the quality of the component I think renaming as you suggested would be the way to go.
Thanks. :-)

@tmjo
Copy link
Collaborator

tmjo commented Feb 2, 2021

Hum, I am not sure anymore. My sensors last 24h: cable_locked_car is unlocked and permanently_locked_charger is on. The latter is ok, because it is permanently locked (in charger) as shown in app too. The "car" one is a mystery to me. It was named just "locked" initially, then changed to "car_locked" because we believed it to be when the car is charging and thus locks it to the car. But apparantly not, because I charged this night. But what does the "car" one do then? Nothing?

@olalid
Copy link
Collaborator

olalid commented Feb 2, 2021

The charger has no idea what is going on with the lock at the car end of the cable, so I think first of all that is very confusing to name it something with "car" in the name.
But it very strange that it seems to operate differently for you, because you are saying it does not turn on at all, even if the permanent lock is on, or if the car is charging?

@olalid
Copy link
Collaborator

olalid commented Feb 2, 2021

if you add this to your configuration.yaml

logger:
  default: info
  logs:                                                                                                                                                                                                                                               
    pyeasee.easee: debug
    custom_components.easee: debug

Then toggle the switch for permanent lock back and forth when the car is not connected.
And then check the log by
grep -i easee home-assistant.log | grep -i callback | grep -i lock
or similar.
What do you see?
Does only the state_lockCablePermanently change occur or do you see the state_cableLocked also happening?

@tmjo
Copy link
Collaborator

tmjo commented Feb 2, 2021

I can check that later, right now I don't have time. But for me we can rename it or remove it. I am not sure what it does, but results are the same as I found in the initial discussions here. Was different than for theAzzi, maybe something is wrong. At the time there wasn't any debugging messages as I would have noticed it.

Are you sure the charger cannot know the car has locked the cable in his end? I would assume this is a safety feature to avoid user pulling out cable during charging, so I guess there is some kind of info going there. But perhaps just that it is charging and that's that.

I'll try to debug later, but if it's working for you guys, just rename it and we're done. It's not a very important function to me, but will try to figure out what is going on.

@olalid
Copy link
Collaborator

olalid commented Feb 2, 2021

Yes, as I interpret it, the only signalling that goes on from car to the charger is about detecting the car and if the car is ready to charge or not. You could interpret that as if it has locked the cable of course, but not really what is intended for.
https://en.wikipedia.org/wiki/SAE_J1772#Signaling
The wikipedia article is kind of US centric since it describes the switch that the type 1 connectors have, type 2 connectors does not have that. My car has a button close to the charge inlet to stop charging instead, I assume other cars have a similar function somehow.
DC chargers uses HomePlug PNA (IP over power line communication) to exchange a lot more data, but that is not included in a home AC charger.
I think anyway, if your charger behaves differently we should discuss this with Easee since there is just something we do not understand or something is broken somehow.

@olalid
Copy link
Collaborator

olalid commented Jun 2, 2022

I am closing this because as far as I can tell it works as intended. If someone still has issues, we need to have more details.

@olalid olalid closed this as completed Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants