custom-components / zaptec

zaptec charger custom component for home assistant
MIT License
67 stars 20 forks source link

Missing sensors #60

Closed Olen closed 11 months ago

Olen commented 1 year ago

This is just a feature request to add a few more sensors from the attributes of the "main" binary sensor. Taken from my current template sensors.

I believe this is the allocated current to a specific charger in a load balanced environment Allocated current: unit_of_measurement: "A" value_template: "{{ state_attr('binary_sensor.xxxx_charger', 'charge_current_set') | round(0, default=0) }}"

Humidity: unit_of_measurement: "%" value_template: "{{ state_attr('binary_sensor.xxxx_charger', 'humidity') | round(0, default=0) }}"

Temperature: unit_of_measurement: '°C' value_template: "{{ state_attr('binary_sensor.xxxx_charger', 'temperature_internal5') | round(0, default=0) }}"

sveinse commented 1 year ago

Thank you. I should be trivial to add these. Some questions:

Temperature internal5        22.148
Temperature e meter phase1    4.515
Temperature e meter phase2    4.906
Temperature e meter phase3    5.782
Temperature tm                4.678
Temperature tm2               5.645
Humidity                     25.357
Olen commented 1 year ago

In a load balanced environment, the available current for the installation is not the same as the current for a single charger.

In my case, installation available current is "unavailable" (I have not investigate this but it should have been 90A Then I have two circouts - each with "Max current" 63A And Then I have my personal charger, which varies depending on the total load of the installation:

image

For temperature, I have the following attributes: temperature_internal5: 27.9779 temperature_internal6: 23.9463

I don't know whether 5 or 6 is the "correct" one. Not sure what the others you can see represent. Are your charged mounted oudoor or indoor?

sveinse commented 1 year ago

In a load balanced environment, the available current for the installation is not the same as the current for a single charger.

According to Zaptec docs, the only way to adjust the charging current is to adjust the available current in the installation object. It is a bit strange, because adjusting this value will affect all chargers connected to the installation, which is probably not what's wanted in multi charger setups.

<charger>.charge_current_set is adjusted dynamically when a central system controls the load balancing. I really haven't tested that use case, but it does make sense and I see why its needed. Out of interest, how do you use that information?

My charger is mounted out-door, so the low 5 degrees figures are probably most correct for the outside temp.

What kind of charger do you have? Pro?

Olen commented 1 year ago

This is a pro-installation with multiple circuits and several chargers on each circuit.

I just use the info to display my current available current in the UI. But I see other use cases for statistics, ensuring that the load balancing works fairly and as intended etc.

When it comes to the temperatures, I believe the "5" one that I use is the internal temperature of the charger, which is probably the one that is interesting for protecting against over heat etc.

sveinse commented 1 year ago

@Olen Would you say its ok if I add the sensors as "Diagnostics" sensors? At least temp and humidity belong there I think, but I'm more uncertain about if "Allocated charge current" should be diagnostic or regular. The difference between the two is what is shown on automatic generated dashboards. I think they behave equally if the entity is used in automations.

(I've gotten requests from some users to reduce the number of entities, which thinks the number of sensors are already too high. Putting it in diagnostics might be a way to reduce the clutter.)

Olen commented 1 year ago

I don't use the default dashboards so for me diagnostics is perfectly fine.

Great job on the new version btw. Thanks a lot.

sveinse commented 1 year ago

@Olen Please try the latest 0.7.1a2 which you can install by selecting "master" as the version in HACS. It contains the sensors you requested. Please test and report back.

Olen commented 1 year ago

Just installed it, and it looks fine. Might be that the Humidity sensor is missing an icon?

Another thing I discovered, which is probably not related directly to this, is that all my "Installation" sensors are unavailable or unknown. The two Circuits are fine, with the correct Max Current, but the Installation shows "NA" for "Avaialable current" under Controls (and changing it does not seem to have any effect). and "Unknown" for the Available current phase 1, 2 and 3 sensors.

This might be the setup of our installation from Zaptech/Charge365, so it might not be something you can control.

But the "Allocated current" for each charger now looks fine:

Charger A: image

Charger B: image

Charger C: image

Etc...

So thanks again.

sveinse commented 1 year ago

Another thing I discovered, which is probably not related directly to this, is that all my "Installation" sensors are unavailable or unknown.

The current zaptec integration (for HA) have a fixed list of sensors which it adds to HA and it will be unavailable until the specifc data point has been received from zaptec portal. However, not all chargers seems to have all sensors, and this might be the case here. Would it be possible for you to download the diagnostics for it and post it here?

Olen commented 1 year ago

The diagnostics is almost 6000 lines long(!) But I did some more testing, and it seems like the number.xxxx_available_current can be adjusted, and directly affects the three phases. However, I do see that I have another MaxCurrent also for the installation. The values for "AvailableCurrent" below was set by me manually when testing now. "MaxCurrent" must be from the API.


  "data": {
    "api": {
      "installation": {
        "Pages": 1,
        "Data": [
          {
            "Id": "<--Redact #1-->",
            "Name": "<--Redact #2-->",
            "Address": "<--Redact #3-->",
            "ZipCode": "<--Redact #4-->",
            "City": "<--Redact #5-->",
            "CountryId": "83bffdb1-0a92-4574-bb7b-bd0d17387c17",
            "InstallationType": 0,
            "MaxCurrent": 125.0,
            "AvailableCurrent": 92.0,
            "AvailableCurrentPhase1": 92.0,
            "AvailableCurrentPhase2": 92.0,
            "AvailableCurrentPhase3": 92.0,
            "AvailableCurrentMode": 0,
            "AvailableCurrentScheduleWeekendActive": false,
            "InstallationCategoryId": "5c624162-e595-4167-a8bb-8b33a1487b62",
            "InstallationCategory": "Community_Installation_Category",
            "UseLoadBalancing": true,
(...)
sveinse commented 1 year ago

I'm not sure what the question is...

If the question is if "Max Current" can be added to the install object then that should be easy to fix.

The AvailableCurrent vs AvailableCurrentPhase* is Zaptecs way of handling phase adjustments. number.xxx_available_current can be used to adjust all three phases to the same value. The zaptec.limit_current must be used if individual 3 phase adjustment is wanted (there is no good way to do it in HA GUI unfortunately).

Olen commented 1 year ago

It was not really a question, I just wondered what the "AvailableCurrent" actually is. I thought it was something you got from the API, resembling MaxCurrent, but I understand they are different things. It was also a bit confusing that it did not update when I tried to set it manually the first time. But that might be just a glitch since I tried to do it right after HA restart.

But maybe "AvailableCurrent" should be automatically set to "MaxCurrent" if it is unset? Or an option to override any manual adjustments of AvailableCurrent and always set it to MaxCurrent? Would that make sense?

sveinse commented 1 year ago

It was not really a question, I just wondered what the "AvailableCurrent" actually is. I thought it was something you got from the API, resembling MaxCurrent, but I understand they are different things. It was also a bit confusing that it did not update when I tried to set it manually the first time. But that might be just a glitch since I tried to do it right after HA restart.

All sensors comes from zaptec cloud, including "AvailableCurrent". Changing a value often take some time to propagate in the zaptec cloud, so some patience is needed when changing a value. The values should be ok after the next refresh, which is either 30 or 60 seconds later.

But maybe "AvailableCurrent" should be automatically set to "MaxCurrent" if it is unset? Or an option to override any manual adjustments of AvailableCurrent and always set it to MaxCurrent? Would that make sense?

This value is retrieved from the Zaptec Portal, so its value is what it has been set with.

Olen commented 1 year ago

This value is retrieved from the Zaptec Portal, so its value is what it has been set with.

Ah. That makes sense. For some reason, it was unset here until I started fiddling with it. I just set it to the Max value now. Not sure if it affects anything in reality. I hope not...

Olen commented 11 months ago

Seems like Allocated Current has been lost in some update.

The same with temperature and humidity.

From the Zaptec portal

image

image

And from HA (2023.12.3)

image

image

sveinse commented 11 months ago

@Olen For the missing "Allocated Current", what is the name of the attribute and under which device? Unfortunately I don't have any attributes named like that in my installation.

There are two ways of finding it: Either by downloading the diagnostics and finding in the large file, or by locating the "Charger" diagnostics entity (which is "Connected") and find it in the list of attributes. It might be located in the "Installation" diagnostics entity too.

What kind of temperature attributes does your charger have? Evidently the attribute "Humidity" and "Temperature internal5" does not exist in your charger.

Olen commented 11 months ago

Allocated current can be found as

state_attr('binary_sensor.plass_24_ola_thoresen_charger', 'charge_current_set)

I have both

temperature_internal5: 25.3091
temperature_internal6: 23.2012 

As attributes to the same binary senor for all the chargers. But the temperature-sensor is unavailable.

I also have

humidity: 24.9817

As an attribute for the binary-sensor of all the chargers.

From the diagnostics


  "integration_manifest": {
    "domain": "zaptec",
    "name": "Zaptec EV charger",
    "documentation": "https://github.com/custom-components/zaptec",
    "dependencies": [],
    "config_flow": true,
    "codeowners": [
      "hellowlol",
      "sveinse"
    ],
    "iot_class": "cloud_polling",
    "requirements": [
      "azure-servicebus",
      "pydantic"
    ],
    "version": "0.7.0",
    "is_built_in": false
  },

...

        {
          "ChargerId": "<--Redact #10-->",
          "StateId": "201 (TemperatureInternal5)",
          "Timestamp": "2023-12-27T19:30:49.37",
          "ValueAsString": "25.2789"
        },
        {
          "ChargerId": "<--Redact #10-->",
          "StateId": "202 (TemperatureInternal6)",
          "Timestamp": "2023-12-27T20:03:59.927",
          "ValueAsString": "21.0498"
        },
...

        {
          "ChargerId": "<--Redact #10-->",
          "StateId": "270 (Humidity)",
          "Timestamp": "2023-12-18T16:54:32.667",
          "ValueAsString": "23.2849"
        },
sveinse commented 11 months ago

Thank you. I see you're running 0.7.0. However the temperature and humidity isn't released yet. I'm working on a 0.7.1 version. If you install the master version, you'll get support for the sensors.

Olen commented 11 months ago

Ah, I had enabled beta-relases but will test master now.

Olen commented 11 months ago

Works as expected in "master".

Thanks

sveinse commented 11 months ago

@Olen With the latest master, is everything related to this issue fixed? I'd like to close this issue, so I can move forwards with a 0.7.1 release.

Olen commented 11 months ago

As far as I can tell, "master" works fine, and has the sensors I asked for. There are a few more attributes from the binary-sensor that could be sensors as well, but nothing I need for my monitoring for now.