scottyphillips/echonetlite_homeassistant

Timeout with device containing many instances

Closed this issue · 4 comments

xen2 commented

I often have issues with a Panasonic light system device (with 50 switch instances) not starting up correctly 50%+ of the time.
image

It used to work in my old fork but not in new version.
By doing some testing with various versions, I tracked it down to 136176c (which relate with timeout handling).

I didn't investigate the code in detail yet, but from a very quick glance, maybe what happens is:

  • before it used to retry a specific step (so if device instance 20 failed, it would restart from instance 20)
  • now, if it fails at any point, it passes exception to HA, mark it as failed, and try again but from instance 0
    So as a result, it fails much more easily because to succeed, all instances 0 to 50 need to not have a single failure/timeout during a single pass?

here's the pseudo code:

// OLD? (robust, if an instance fails, it tries again same isntance, restart from there and usually can recover)
foreach (var instance)
{
     // async_update_data (with internal retry loop)
     for (int tries = 0; i < 4; ++i)
     {
          try
          {
             // echonet query
          }
          catch
          {
          }
     }
}

// NEW? (easy to fail, it just takes one single failure per global try)
// top level home assistant retry loop
for (int tries = 0; i < X; ++i)
{
    try
    {
        foreach (var instance)
        {
             // async_update_data (without retry loop)
             // echonet query
        }
    }
    catch
    {

    }
}

Sorry @xen2 my poor old single HVAC instance makes me not the ideal candidate to test with, maybe @nao-pon can assist.

I also don't own a device with this many instances, so I can't debug it accurately. But I'm very interested in solving this problem.

xen2 commented

Sorry @xen2 my poor old single HVAC instance makes me not the ideal candidate to test with, maybe @nao-pon can assist.

No worries, you guys did most of the work already, it's thanks to you that I can automate most of my house ;)

I guess I can be a good beta-tester with plenty of devices and many categories covered: several AC, 2 electric boards (reporting live consumption for each electric line), enefarm, solar panel, light system and recently electric blinds (just got their new HEMS controller, before I had something serial port based) :)

@xen2 I cherry-picked the commit in your repository to master. Thanks! 👍