Teslamate: Level 1 (120V@12A) : charger_power reports 1 kWh instead of 1.44

Created on 24 May 2020  路  11Comments  路  Source: adriankumpf/teslamate

charges.charger_power is a smallint, I recall seeing a schema change lately. While this works great for Level 2+ the experience with level 1 isn't as good.

On level 1 ~120V@12A , charges.charger_power is set to "1" (kWh) but true value is more like "1.44" calculated with charger_voltage * charger_actual_current (or charger_pilot_current .. not sure the difference yet). The Overview in grafana while charging shows "1 kWh".

I understand the use of smallint for disk usage, would there a concern to switch to integer and make charger_power unit Wh instead of kWh? Would there be a better way to make the experience a little better?

I know level 1 isn't popular to charge but at a small cottage in the wood, it's all I can use. It believe the calculated total kWh at the end of a charge seems right.

idea

All 11 comments

charger_power is sent in the INT format by the API , so it isnt possible to change to a numeric value, at least not directly.

@adriankumpf What do you think about not storing that field and just calculating it instead?

EX: ((charger_voltage * charger_actual_current)::numeric(6,2) / 1000)::numeric(6,2)

Edit: Ignore :) See below.

charger_power is sent in the INT format by the API , so it isnt possible to change to a numeric value, at least not directly.

No wonder why I couldn't find that "1" in the source code, I thought level 1 was a special case but makes sense if it's by the API.

If the value can easily be calculated, not storing at all might sure make sense. If the decision is to remove that field, might make sense to run a query, apply the formula and compare the value from the API to see if they match exactly or within ~1% ? I would try to do it but I don't have a single L2+ entry yet. I could visit a supercharger but a single entry wouldn't help to do a good cross check.

Yeah there would need to be some research if anything was done. Super chargers dont show right, but all my home charges are good /w it.

For superchargers, I guess the total kW for a charge shown in grafana should match the value charged by Tesla.

What exactly doesn't show right w/ the supercharger entries? The numbers make no sense or ?! I'll try to stop by one in the coming days to get an entry.

So fast chargers can;t be calculated because the charger_actual_current is always 0. I tried to see if charger_pilot_current would be a valid replacement, but its not the kWh was crazy low. Once I can get validation how fast_charger_type and fast_charger_brand show for non Tesla chargers and how the data comes across, I can put in a PR for the report side.

And no it will not match within ~1% because the accuracy isn't even close to that. You can't compare #.## to # with a without a up to a 50% variance. However, I will say with all of my L2, the data rounds to the nearest whole INT, but it seems to be semi random if it rounds up or down. Without Tesla's actual API source code well never know. So that raises the variable up to 100% for kWh ranges of 0-1.99. The higher the # obviously the lower the variance.

Long story, I feel good with this formula CURRENTLY, but again I have no L1 data or L3 that isn't Tesla.

case when fast_charger_present is false then ((charger_voltage * charger_actual_current)::numeric(8,2) / 1000)::numeric(8,2) else charger_power end

This formula would have to work for three phase charging as well but you'd have to differentiate between 127/230V three-phase networks and regular ones (see #290).

My first commit to teslamate was much easier than this task :D .... wish I had more free time to learn Exilir & postgres but I have a house under construction :(

The proposed approach by @Dulanic seems to update the query in Grafana, while #290 added to "log.ex" is about taking the values returned by the API and log it in the database after applying the formula. Correct me if I'm wrong.

For this request it seems we'd need to add that functionality as well in log.ex .

What's being discussed in this issue is the phase correction applied by TeslaMate to calculate the "kWh used". The background is that the Model 3 (and possibly other vehicles) always incorrectly report 2 phase charging. Additionally, as it turned out, 127/230V three-phase networks also have to be considered for the calculation to be correct.

The same problems would also have to be solved here. That's why the above formula would only work for selected vehicles. The issues with calculating the charger power on the fly is that you'd have to find out whether/which of those corrections need to be applied, and change the formula accordingly.

I suspect that the code would inevitably be quite error-prone and would often output wrong values. I can already imagine dozens of new issues being opened on the subject 馃槅 Given this, I am not convinced of the usefulness of having slightly higher accuracy. Maybe someday the Tesla API will return the charger power with higher accuracy though?

The whole phase things threw me for a loop. Blame Tesla's API :) They didn't build it for us.

Unless there are more comments coming in, I'll close this in ~1-3 days max. Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

russinating picture russinating  路  4Comments

virtualm2000 picture virtualm2000  路  4Comments

kongomongo picture kongomongo  路  5Comments

petariga picture petariga  路  5Comments

detritu5 picture detritu5  路  4Comments