nayaverdier / halohome

A python library to control Eaton HALO Home Smart Lights
MIT License
1 stars 1 forks source link

Empty locations #1

Closed oyvindkinsey closed 7 months ago

oyvindkinsey commented 2 years ago

First off, thank you for making this component available, knowing that I can directly control these lights have been crucial for me feeling comfortable with using these for a large project.

I've added the halohome component from your Home Assistant fork to my custom_components, and while I'm able to setup the component, it shows no entities. When I added some additional logging, it was clear that the response from the halohome component contained an empty list of locations.

I've also hit the avi-on API's with my credentials, and I've been able to enumerate both locations and devices, but looks like something might have changed with regards to how this module parses the response? I have both lights and switches added to my account.

I'm running core-2021.12.10 with python 3.9.7 if that helps.

I'll play around some more with seeing where things go wrong, but getting the python environment up and running without messing up my host has been a challenge. Will see what I can do.

I hope this is something you're aware of and which has a simple fix.

nayaverdier commented 2 years ago

@oyvindkinsey Unfortunately I haven't encountered that issue. Can you include the response data you're seeing both through home assistant and directly from avi-on? If you would like help getting an environment setup to run this library directly I can provide instructions.

oyvindkinsey commented 2 years ago

Here's what I get when I test with halohome

    locations = await halohome.list_devices("***", "****")
    print(locations)

// prints this
[{'location_id': '*****', 'passphrase': '******************', 'devices': []}]

This is what I get when I use a simple nodejs script to query /locations/296538/abstract_devices, where 296538 is the location from /locations, and the same as what halohome sees:

{
  locationId: 296538,
  abstract_devices: [
    {
      id: 1449576,
      name: 'MicroEdge (HLB)',
      product_id: 162,
      location_id: 296538,
      avid: 32896,
      mac_address: 'ef84bd9f1cd6',
      mandatory_ota: null,
      friendly_mac_address: '1cd6bd9fef84',
      pid: '571f4bb9c2de2617c4bfe058',
      thumbnail: '',
      current_version: '0.0.0',
      type: 'device',
      favorite: null,
      versions: [Array],
      tags: null,
      mesh_status: 'available',
      ssid: null,
      remote_status: 'online',
      last_active_at: '2022-01-12T03:09:26.000Z',
      parent_id: null,
      sensor_type: null,
      status_processed_at: '2022-01-12T03:09:31+00:00',
      status_updated_at: '2022-01-12T03:09:26.000Z',
      invalid: false,
      created_at: '2022-01-12T03:09:18+00:00',
      updated_at: '2022-01-12T03:13:14+00:00',
      product: [Object],
      groups: [Array],
      schedules: [],
      parent: null
    },
    {
      id: 1451039,
      name: 'Smart Bulb (A19)',
      product_id: 134,
      location_id: 296538,
      avid: 32897,
      mac_address: '1551bd9b1cd6',
      mandatory_ota: null,
      friendly_mac_address: '1cd6bd9b1551',
      pid: 'd953739e8a72f4b5b2aa151b',
      thumbnail: '',
      current_version: '0.0.0',
      type: 'device',
      favorite: null,
      versions: [Array],
      tags: null,
      mesh_status: 'available',
      ssid: null,
      remote_status: 'online',
      last_active_at: '2022-01-13T21:17:35.000Z',
      parent_id: null,
      sensor_type: null,
      status_processed_at: '2022-01-13T21:17:43+00:00',
      status_updated_at: '2022-01-13T21:17:35.000Z',
      invalid: false,
      created_at: '2022-01-13T21:17:35+00:00',
      updated_at: '2022-01-13T21:17:43+00:00',
      product: [Object],
      groups: [Array],
      schedules: [],
      parent: null
    },
    {
      id: 1451051,
      name: 'Anyplace Dimmer',
      product_id: 81,
      location_id: 296538,
      avid: 32898,
      mac_address: '4e36391488d0',
      mandatory_ota: null,
      friendly_mac_address: '88d039144e36',
      pid: '7bf39b5806e0c067897214ed',
      thumbnail: '',
      current_version: '0.0.0',
      type: 'controller',
      favorite: null,
      versions: [Array],
      tags: null,
      mesh_status: 'available',
      ssid: null,
      remote_status: null,
      last_active_at: null,
      parent_id: null,
      sensor_type: null,
      status_processed_at: '2022-01-13T21:21:28+00:00',
      status_updated_at: null,
      invalid: false,
      created_at: '2022-01-13T21:21:28+00:00',
      updated_at: '2022-01-13T21:25:14+00:00',
      product: [Object],
      groups: [],
      schedules: [],
      parent: null
    },
    {
      id: 1451063,
      name: 'Smart Bulb (A19)',
      product_id: 134,
      location_id: 296538,
      avid: 32899,
      mac_address: '022abd9b1cd6',
      mandatory_ota: null,
      friendly_mac_address: '1cd6bd9b022a',
      pid: '14e052550195a65a6a571c9f',
      thumbnail: '',
      current_version: '0.0.0',
      type: 'device',
      favorite: null,
      versions: [Array],
      tags: null,
      mesh_status: 'available',
      ssid: null,
      remote_status: 'online',
      last_active_at: '2022-01-13T21:24:49.000Z',
      parent_id: null,
      sensor_type: null,
      status_processed_at: '2022-01-13T21:25:01+00:00',
      status_updated_at: '2022-01-13T21:24:49.000Z',
      invalid: false,
      created_at: '2022-01-13T21:23:55+00:00',
      updated_at: '2022-01-13T21:25:01+00:00',
      product: [Object],
      groups: [Array],
      schedules: [],
      parent: null
    },
    {
      id: 1451290,
      name: 'Smart Dimmer',
      product_id: 97,
      location_id: 296538,
      avid: 32900,
      mac_address: 'ce19bd951cd6',
      mandatory_ota: null,
      friendly_mac_address: '1cd6bd95ce19',
      pid: '5893b18ef932f4ca0884c0b6',
      thumbnail: '',
      current_version: '0.0.0',
      type: 'device',
      favorite: null,
      versions: [Array],
      tags: null,
      mesh_status: 'available',
      ssid: null,
      remote_status: null,
      last_active_at: null,
      parent_id: null,
      sensor_type: null,
      status_processed_at: '2022-01-13T23:55:42+00:00',
      status_updated_at: null,
      invalid: false,
      created_at: '2022-01-13T23:55:42+00:00',
      updated_at: '2022-01-13T23:55:49+00:00',
      product: [Object],
      groups: [],
      schedules: [],
      parent: null
    },
    {
      id: 1451294,
      name: 'Accessory Dimmer',
      product_id: 91,
      location_id: 296538,
      avid: 32901,
      mac_address: '8ce0bd951cd6',
      mandatory_ota: null,
      friendly_mac_address: '1cd6bd958ce0',
      pid: '1c07f978cb4d69b27f3877ab',
      thumbnail: '',
      current_version: '0.0.0',
      type: 'controller',
      favorite: null,
      versions: [Array],
      tags: null,
      mesh_status: 'available',
      ssid: null,
      remote_status: null,
      last_active_at: null,
      parent_id: null,
      sensor_type: null,
      status_processed_at: '2022-01-14T00:02:27+00:00',
      status_updated_at: null,
      invalid: false,
      created_at: '2022-01-14T00:02:27+00:00',
      updated_at: '2022-01-14T04:36:57+00:00',
      product: [Object],
      groups: [],
      schedules: [],
      parent: null
    },
    {
      id: 1451718,
      name: 'MicroEdge (HLB)',
      product_id: 162,
      location_id: 296538,
      avid: 32903,
      mac_address: 'f231bd9f1cd6',
      mandatory_ota: null,
      friendly_mac_address: '1cd6bd9ff231',
      pid: 'ee2e76f67d7f73eb1de13ab9',
      thumbnail: '',
      current_version: '0.0.0',
      type: 'device',
      favorite: null,
      versions: [Array],
      tags: null,
      mesh_status: 'available',
      ssid: null,
      remote_status: 'online',
      last_active_at: '2022-01-14T05:06:09.000Z',
      parent_id: null,
      sensor_type: null,
      status_processed_at: '2022-01-14T05:06:15+00:00',
      status_updated_at: '2022-01-14T05:06:09.000Z',
      invalid: false,
      created_at: '2022-01-14T05:04:54+00:00',
      updated_at: '2022-01-14T05:06:15+00:00',
      product: [Object],
      groups: [Array],
      schedules: [],
      parent: null
    },
    {
      id: 1451719,
      name: 'MicroEdge (HLB)',
      product_id: 162,
      location_id: 296538,
      avid: 32904,
      mac_address: 'f092bd9f1cd6',
      mandatory_ota: null,
      friendly_mac_address: '1cd6bd9ff092',
      pid: '4388e37b9ffeb9d6bd80fe58',
      thumbnail: '',
      current_version: '0.0.0',
      type: 'device',
      favorite: null,
      versions: [Array],
      tags: null,
      mesh_status: 'available',
      ssid: null,
      remote_status: 'online',
      last_active_at: '2022-01-14T05:06:09.000Z',
      parent_id: null,
      sensor_type: null,
      status_processed_at: '2022-01-14T05:06:15+00:00',
      status_updated_at: '2022-01-14T05:06:09.000Z',
      invalid: false,
      created_at: '2022-01-14T05:05:20+00:00',
      updated_at: '2022-01-14T05:06:15+00:00',
      product: [Object],
      groups: [Array],
      schedules: [],
      parent: null
    },
    {
      id: 1454712,
      name: 'MicroEdge (HLB)',
      product_id: 162,
      location_id: 296538,
      avid: 32905,
      mac_address: 'e33cbd9f1cd6',
      mandatory_ota: null,
      friendly_mac_address: '1cd6bd9fe33c',
      pid: '973514b0e33224fafc85f725',
      thumbnail: '',
      current_version: '0.0.0',
      type: 'device',
      favorite: null,
      versions: [Array],
      tags: null,
      mesh_status: 'available',
      ssid: null,
      remote_status: 'online',
      last_active_at: '2022-01-17T01:15:32.000Z',
      parent_id: null,
      sensor_type: null,
      status_processed_at: '2022-01-17T01:15:38+00:00',
      status_updated_at: '2022-01-17T01:15:32.000Z',
      invalid: false,
      created_at: '2022-01-17T01:15:32+00:00',
      updated_at: '2022-01-17T01:15:43+00:00',
      product: [Object],
      groups: [],
      schedules: [],
      parent: null
    }
  ],
  count: 9
}
oyvindkinsey commented 2 years ago

You know what? I bet it's the product_id filter - seems the library defaults to filter on 93, while mines have other values. I'll try modifying the call to list_devices to include these values.

nayaverdier commented 2 years ago

Yep looks like that's exactly the issue. I was only able to test with the specific lights that I have, so hopefully the same protocols apply to yours. The dimmers/etc might take some additional work if you want to support those as well.

oyvindkinsey commented 2 years ago

Is there any reason to believe different lights will use different protocols? AFAIK the Avi-on modules are white label and used across many different lights, and from different manufacturers (GE for instance). I would guess that these would all share the same instruction set.

I got my A19 bulbs (the one I have here) working, but I disconnected the light and HA became unable to control/monitor it. Maybe there needs to be some reconnection logic?

What's the best way to monitor this component in HA? It doesn't seem to write much to any logs.

nayaverdier commented 2 years ago

As long as the feature set is the same there shouldn't be any issues (e.g. my lights have brightness + color temperature so that's what this currently supports). This library should automatically reconnect when necessary (it tries to connect to the first device listed, and if that times out it then moves on the subsequent devices)--though it can take several seconds (or substantially longer if the first devices listed are unavailable).

This component also doesn't currently update state when the lights are controlled outside of HA, it just blindly sets the state of each device and then sets the state in HA.

And yeah, there's not much in the way of logs right now but is there anything that would be helpful for you?

oyvindkinsey commented 2 years ago

Ah, that explains it - I have a bunch added to my account, but many of them are disconnected right now (we're in the middle of a remodel). So it might be cycling through devices that aren't actually online. Maybe we could use the last_active_at field to filter down first? I'll try something like that and see if it works.

How did you identify the current logic, and how would you go about maintaining it (I don't know if these things receive firmware updates etc from the app)? I noticed that the API calls you make are not actually listed in the official documentation, so some reverse engineering I presume? We're about to buy quite a few of these, and I would feel much more comfortable knowing that I could if needed control these directly

Message ID: @.***>

nayaverdier commented 2 years ago

Good idea, happy to review a PR if you have success with sorting by last active. Though I'm not sure how the API would know that information if the devices are only controlled via bluetooth (versus through the app where it sends that data back to the API).

For the API, I found avi-on's web portal and used that to find the various endpoints needed. For the bluetooth protocol, I logged the packets when controlling the lights through the app and used those to reverse engineer the protocol.

oyvindkinsey commented 2 years ago

Good point - maybe it should instead intersect the list with a local scan and select the node with the best RSSI?

-sean

On Tue, Jan 25, 2022 at 11:49 AM nayaverdier @.***> wrote:

Good idea, happy to review a PR if you have success with sorting by last active. Though I'm not sure how the API would know that information if the devices are only controlled via bluetooth (versus through the app where it sends that data back to the API).

For the API, I found avi-on's web portal https://myaccount.avi-on.com and used that to find the various endpoints needed. For the bluetooth protocol, I logged the packets when controlling the lights through the app and used those to reverse engineer the protocol.

— Reply to this email directly, view it on GitHub https://github.com/nayaverdier/halohome/issues/1#issuecomment-1021549379, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2MAR75TBCJ6QA7URJ2DDUX35FBANCNFSM5MXEFHPQ . 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.

You are receiving this because you were mentioned.Message ID: @.***>

nayaverdier commented 2 years ago

Just released 0.5.0 to sort by RSSI, let me know if that works on your side (can close this issue if it does).