serkri / SmartEVSE-3

Smart Electric Vehicle Charging Station (EVSE)
MIT License
68 stars 28 forks source link

[RFID] Removing cable from vehicle without RFID stop scan does not block next session #148

Closed hmmbob closed 1 year ago

hmmbob commented 1 year ago

I'm using a fixed cable and a RFID reader to lock my charger - at least I thought so. Yesterday I've scanned one of the learned tags to enable the charging point and charged my car. Today I removed the cable from the car (as soon as you unlock the doors, the car also unlocks the cable and you can just pull it out) which the EVSE detected properly ("Not Connected").

Upon return, I plugged in the cable and without scanning a RFID tag the EVSE started charging again. This was unexpected, I assumed removing the cable would lock the EVSE and would have expected to need to swipe the RFID tag again to "unlock" the EVSE before loading could commence.

raw_data:

{
  "version": "SERKRI-1.6.5",
  "mode": "SOLAR",
  "mode_id": 2,
  "car_connected": true,
  "wifi": {
    "status": "WL_CONNECTED",
    "ssid": "--redacted--",
    "rssi": -54,
    "bssid": "34:60:F9:11:22:33",
    "auto_connect": false,
    "auto_reconnect": true
  },
  "evse": {
    "temp": 39,
    "temp_max": 65,
    "connected": true,
    "access": true,
    "mode": 2,
    "pwm": 102,
    "solar_stop_timer": 0,
    "state": "Charging",
    "state_id": 2,
    "error": "None",
    "error_id": 0,
    "rfid": "Ready to read card"
  },
  "settings": {
    "charge_current": 60,
    "override_current": 0,
    "current_min": 6,
    "current_max": 32,
    "current_main": 25,
    "solar_max_import": 0,
    "solar_start_current": 5,
    "solar_stop_time": 5,
    "enable_C2": "Not present",
    "modem": "Not present",
    "mains_meter": "API",
    "starttime": 0,
    "stoptime": 0,
    "repeat": 0
  },
  "home_battery": {
    "current": 0,
    "last_update": 0
  },
  "ev_meter": {
    "description": "Eastron3P",
    "address": 11,
    "import_active_power": 1.1,
    "total_kwh": 14.2,
    "charged_kwh": 0.1,
    "currents": {
      "TOTAL": 55,
      "L1": 55,
      "L2": 0,
      "L3": 0
    },
    "import_active_energy": 14.2,
    "export_active_energy": 0
  },
  "mains_meter": {
    "import_active_energy": 0,
    "export_active_energy": 0
  },
  "phase_currents": {
    "TOTAL": 0,
    "L1": 40,
    "L2": -20,
    "L3": -20,
    "last_data_update": 1684767750,
    "charging_L1": true,
    "charging_L2": false,
    "charging_L3": false,
    "original_data": {
      "TOTAL": 0,
      "L1": 40
    }
  }
}
dingo35 commented 1 year ago

That is indeed unexpected behaviour. Im having trouble to reproduce, do you perhaps know of a previous version that didnt have this problem?

hmmbob commented 1 year ago

No, i only installed the hardware last weekend so I've only ever used the current / latest version.

Edit: could it be a configuration thingie? I don't think I see all possible config items that I've seen on screen are listed in the JSON (I think to remember a 'switch' option?)

hmmbob commented 1 year ago

Could this be the problem?

https://github.com/serkri/SmartEVSE-3/blob/b6b17084573bb090324c98532762e9ed53eb783b/SmartEVSE-3/src/evse.cpp#L1692-L1694

I am using EnableAll instead of EnableOne (so that I can start charging, and my wife can stop charging with a different card). which is RFIDReader == 1

edit: Or, it might be here - also only checking for mode 2:

https://github.com/serkri/SmartEVSE-3/blob/b6b17084573bb090324c98532762e9ed53eb783b/SmartEVSE-3/src/evse.cpp#L2748-L2749

dingo35 commented 1 year ago

Yes I think you found the bug! Interesting because I think this code was untouched, so that would mean the original code has it too. But I think you misunderstand the settings; from the code: EnableAll: All learned cards accepted for locking/unlocking EnableOne: Only the card that unlocks, can relock the EVSE.

So I think everybody uses EnableOne.

But I still think its a bug, its on my list, keep this issue open, bit busy nowadays.

hmmbob commented 1 year ago

Yes I think you found the bug! Interesting because I think this code was untouched, so that would mean the original code has it too.

Ha, nice bug found then 🤣

But I think you misunderstand the settings; from the code: EnableAll: All learned cards accepted for locking/unlocking EnableOne: Only the card that unlocks, can relock the EVSE.

No, that is exactly the use case I wanted to have! Any of the learned cards can unlock the evse, and also any of them can lock it again regardless of the previous card used. That's very comfortable at home when you have 2 different key(chains) (i.e. myself and my wife) with a small token attached to it (in our case: Vattenfall charge tokens, both having a different ID).

But I still think its a bug, its on my list, keep this issue open, bit busy nowadays.

No worries. I'll happily test whenever you're ready for it. I'll be out for Pentecost (Pinksteren) anyways as well, so any testing from my side would be after that anyways 😉

dingo35 commented 1 year ago

rfid-enableall.zip @hmmbob Could you test this version (extensively, since I cannot test this fully myself)?

hmmbob commented 1 year ago

I'll try this weekend!

Thanks!

dingo35 commented 1 year ago

@hmmbob Any progress on testing this?

hmmbob commented 1 year ago

Nope, I forgot. Thanks for reminding me!