audiconnect / audi_connect_ha

Adds an audi connect integration to home assistant
MIT License
224 stars 98 forks source link

Sensor `charging_complete_time` unknown on A5 #401

Closed mm98 closed 4 months ago

mm98 commented 4 months ago

Describe the bug

First of all. This isn't really a problem at all. I just wanted to report it, since it doesn't really make any sense to me

I have a sensor.audi_a5_sportback_charging_complete_time sensor, which doesn't really have anything to do with my car (gasoline, A5). I can see in the code and debug logs, that the state is checked / validated by remainingChargingTime here:

TRY APPEND STATE: Searching for 'remainingChargingTime' at location=['charging', 'chargingStatus', 'value', 'remainingChargingTimeToComplete_min'], tsoff=-1
TRY APPEND STATE: 'remainingChargingTime' adjusted to 0 due to None value
TRY APPEND STATE: Timestamp for 'remainingChargingTime' is None or missing; not appending state.

Wouldn't this mean that it is None and returned as is not supported? Meaning the sensor would be disabled / hidden?

Screenshots image

Logfile home-assistant_audiconnect_2024-04-18T13-32-10.734Z.log

Your Vehicle Details Model: A5 Sportback Year: 2021 Type (ICE/PHEV/BEV): ICE

Note: It might be good to describe what ICE/PHEV/BEV is (ex. this) for none native English speaking. I had to look it up ;)

Kolbi commented 4 months ago

Thanks for reporting. Which version are you using currently?

Good note as I even don't know the term ICE (only in combination with trains :))

Kolbi commented 4 months ago

Need to dig deeper but maybe this could be the issue:

# Special handling for remainingChargingTime if name == "remainingChargingTime" and val is None: val = 0 _LOGGER.debug( "TRY APPEND STATE: 'remainingChargingTime' adjusted to 0 due to None value" )

Do you also have the entity remainingChargingTime ?

In this line https://github.com/audiconnect/audi_connect_ha/blob/5055bc34b14e99fda066ce9975da9e8c98ee99da/custom_components/audiconnect/audi_connect_account.py#L1655 if self.last_update_time is None or self.remaining_charging_time is None: return None remaining_charging_time is 0 so not None that might be the reason why we have unknown.... :)

mm98 commented 4 months ago

Thanks for reporting. Which version are you using currently?

I'm using the most recent release v1.6.3

mm98 commented 4 months ago

Do you also have the entity remainingChargingTime ?

No, I don't have an entity named remainingChargingTime.

image

Kolbi commented 4 months ago

Can you check the fix in https://github.com/audiconnect/audi_connect_ha/pull/402 ?

Kolbi commented 4 months ago

Maybe the fix is not working well in all cases need to think about it.

mm98 commented 4 months ago

Maybe the fix is not working well in all cases need to think about it.

I'll try to make the change locally and report back.

mm98 commented 4 months ago

@Kolbi i made the change in audi_connect_account.py locally. Nothing changed though.

image

mm98 commented 4 months ago

Honestly, you don't need to spend much time on it for me. I just reported it in case there was an "easy" fix. It doesn't bother me at all that it is visible. I can just disable it manually if needed.

coreywillwhat commented 4 months ago

I think @kolbi and I have worked this out. I will work on updating #402 when I have some time. As always, thanks for reporting @mm98 !