DurgNomis-drol / ha_toyota

Toyota Connected Services integration for Home Assistant.
MIT License
148 stars 29 forks source link

Entities Unavailable after a few hours #88

Closed benjabievres closed 2 years ago

benjabievres commented 2 years ago

Hi,

I configured my account, and everything works fine when the Integration starts (or is reloaded). But, after a while, all the metrics are gone (unavailable). It works again only if I Reload the integration.

I see in the Logs that I get this error message:

_**Logger: mytoyota Source: /usr/local/lib/python3.9/site-packages/mytoyota/vehicle.py:161 First occurred: 06:21:39 (1 occurrences) Last logged: 06:21:39

Your vehicle does not support Connected services (). You can find out if your vehicle is compatible by checking the manual that comes with your car.**_

It's strange because it always works when it's started, and fails after a while...

Btw, it's a super Intgeration! thanks a lot

DurgNomis-drol commented 2 years ago

Strange, i have personally had this happen sometimes, but never consistently. The API seems to be a bit flacky sometimes, it fails, without any obvious reason. The error you see are only generated if live data is not supported. Can you confirm that you have enabled Connected Services in the Toyota APP?

benjabievres commented 2 years ago

Hi, thanks for your answer. Yes I enabled the connected services. Maybe it’s due to the instability of their API. A workaround would be that the integration reloads automatically, regularly ; but I don’t know if that’s possible…

Best regards

Le mar. 23 nov. 2021 à 18:43, Simon Hansen @.***> a écrit :

Strange, i have personally had this happen sometimes, but never consistently. The API seems to be a bit flacky sometimes, it fails, without any obvious reason. The error you see are only generated if live data is not supported. Can you confirm that you have enabled Connected Services in the Toyota APP?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/DurgNomis-drol/ha_toyota/issues/88#issuecomment-976921392, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIUDCWUC3PZBZNVQQWEATVTUNPHETANCNFSM5ISYYQDA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

DurgNomis-drol commented 2 years ago

Btw, it's a super Intgeration! thanks a lo

And thanks for the nice comment! This is what keeps me coding :smile:

No, it should reconnect after some time, I experience that it fails to connect, typically about midnight GMT, I believe it is a server issue, but mine always comes back after a short while.

It is not possible to reload the integration other then clicking the button on the integration page. This is a limitation in Home Assistant.

Can you enable more logging by adding this to configuration.yaml:

logger:
  default: info
  logs:
    custom_components.my_integration: debug
    mytoyota: debug

And then restart and post the log output AFTER it fails again. This will give me a lot more details of why it is failing. Sensitive data should be censored, but please double check before posting.

benjabievres commented 2 years ago

Hi,

I modified the configuration, I will post my anonymized log as soon as it disconnects 😄

Kind regards

benjabievres commented 2 years ago

Hi @DurgNomis-drol ,

Here are the 2 logs I found so far; hope it's what you expected. (I went to Configure/Logs). One of the errors occured more than 400 times, so I guess this is the most important. For the second one, it's recent, so I guess it's not directly the cause of the issue I have.

Thanks!

Regards.

`Logger: homeassistant Source: custom_components/toyota/binary_sensor.py:346 Integration: Toyota Connected Services (documentation, issues) First occurred: 23 November 2021, 19:46:27 (402 occurrences) Last logged: 06:14:22

Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 134, in _handle_refresh_interval await self._async_refresh(log_failures=True, scheduled=True) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 265, in _async_refresh update_callback() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in _handle_coordinator_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 486, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 519, in _async_write_ha_state state = self._stringify_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 492, in _stringify_state if (state := self.state) is None: File "/usr/src/homeassistant/homeassistant/components/binary_sensor/init.py", line 186, in state return STATE_ON if self.is_on else STATE_OFF File "/config/custom_components/toyota/binary_sensor.py", line 346, in is_on return self.coordinator.data[self.index].hvac.front_defogger AttributeError: 'Hvac' object has no attribute 'front_defogger'`

`Logger: custom_components.toyota Source: helpers/update_coordinator.py:219 Integration: Toyota Connected Services (documentation, issues) First occurred: 00:09:06 (3 occurrences) Last logged: 06:11:16

Error fetching toyota data: Update canceled! Toyota's API was too slow to respond. Will try again later...`

DurgNomis-drol commented 2 years ago

Thanks, i believe i have found the issue. I just pushed an update to master. Can you please check it out to see if it fixes your issue and report back?

Another thing, my car does not support this feature, so I not 100% sure that it reports back on when the defogger is on, can you double check for me that it reflects the actual status in the car? :smiley:

benjabievres commented 2 years ago

Thank you so much @DurgNomis-drol, I just downloaded the latest version, i will let you know. Actually, for the Defogger, the MyT app only allows me to start or schedule them, but there is no status. And in HA, I see these 2 metrics as Unavailable, and I think I'm in the same limitation as you.

Cheers,

ben

DurgNomis-drol commented 2 years ago

Just to make sure, did you download the latest master or the latest version? I have not published a new version with this fix included, but the master branch of this repository contains this fix? They shouldn't show up as unavailable in HA if your car does not report anything for them.

benjabievres commented 2 years ago

Oh no actually, I used HACS/Download again, and yes, there was only the published version. How do I download the master? Do i download a ZIP and install the files directly in my host? (PI with Debian)

DurgNomis-drol commented 2 years ago

In HACS, click on the three dots and then click redownload, a pop-up should appear where you can choose a version, at the bottom of this, you can select master. :smiley:

benjabievres commented 2 years ago

Oh Ahaah, I didn’t scroll down the first time 😂 Thanks! Ben

Le mer. 24 nov. 2021 à 15:03, Simon Hansen @.***> a écrit :

In HACS, click on the three dots and then click redownload, a pop-up should appear where you can choose a version, at the bottom of this, you can select master. 😃

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/DurgNomis-drol/ha_toyota/issues/88#issuecomment-977907864, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIUDCWQUZKFUSGTNTJQC76TUNTWDHANCNFSM5ISYYQDA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

benjabievres commented 2 years ago

They shouldn't show up as unavailable in HA if your car does not report anything for them. Now they display as on or off :-)

Let's see if all metrics stay available forever.

Cheers,

Ben

DurgNomis-drol commented 2 years ago

If not, please feel free to open a new issue if there is a problem with the defogger sensors :smiley:

Cheers,

Simon

benjabievres commented 2 years ago

Hi @DurgNomis-drol, it seems to work perfectly now! Because before, it was disconnecting earlier than this. And I get all metrics. Thanks to you, I can alert myself when the EV Battery is full and I can unplug the charger 😂😂😂 Thanks a lot, you rock!!!

DurgNomis-drol commented 2 years ago

Just published a new version (12.6) that contains the fix for this issue