sebr / bhyve-home-assistant

Orbit BHyve custom component for Home Assistant
MIT License
259 stars 42 forks source link

B-hyve integration doesn't work correct with unnamed devices or zones #146

Closed ObiWanCanOweMe closed 6 months ago

ObiWanCanOweMe commented 2 years ago

Describe the bug The integration is unable to create any switch entities

Expected behaviour At least one switch entity should be created for my zone

BHyve devices

Orbit 21004 B-hyve Smart Hose Faucet Timer with Wi-Fi Hub](https://www.amazon.com/dp/B0758NR8DJ)
HT25-0000 by Orbit BHyve
Firmware: 0041
Hardware: HT25-0000

Logs

2022-07-16 17:39:46 ERROR (MainThread) [homeassistant.components.switch] Error while setting up bhyve platform for switch
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 250, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/bhyve/switch.py", line 178, in async_setup_entry
    BHyveProgramSwitch(
  File "/config/custom_components/bhyve/switch.py", line 224, in __init__
    device_name = device.get("name")
AttributeError: 'NoneType' object has no attribute 'get'

Step 1: Enable debugging.

I enabled the logger but could not find the following in the logs:

DEBUG (MainThread) [custom_components.bhyve] Devices:
DEBUG (MainThread) [custom_components.bhyve] Programs:
sebr commented 2 years ago

@ObiWanCanOweMe can you upload the device diagnostics file? Go to the device page and click the ... link:

Screen Shot 2022-07-20 at 10 17 16 am
julianwould commented 2 years ago

I believe I have same issue l, no switches crafted, with a new four port B-hyve.

sebr commented 2 years ago

I believe I have same issue l, no switches crafted, with a new four port B-hyve.

@julianwould Can you please upload diagnostics? Instructions are in an earlier comment. Thx

julianwould commented 2 years ago

Yessir, diagnostics attached, appreciate the help!

config_entry-bhyve-a2afcc8dd1b80ef0e85f8d5a7fafd54d.json.txt

julianwould commented 2 years ago

All working now, it was hub/timer connection issue. Resolved by updating firmware. Thanks @sebr

sebr commented 2 years ago

@ObiWanCanOweMe how did you go with this?

ObiWanCanOweMe commented 2 years ago

Sorry for the delay in my response, here's the diagnostic:

config_entry-bhyve-a7d026a896becfaa4ca243c42b773011.json.txt

I checked for firmware updates but all my devices are on latest.

sebr commented 2 years ago

@ObiWanCanOweMe sorry for the delay on this, but I had a look and it appears that your "Spare" sprinkler has a zone which doesn't have a name. To resolve the issue you probably just need to give it a name, but it would also be helpful to understand how you got into this state so I can try reproduce and improve the integration to handle this edge case.

        "zones": [
          {
            "station": 1,
            "name": "",
            "num_sprinklers": 0,
            "catch_cup_volumes": [],
            "catch_cup_run_time": 0,
            "smart_watering_enabled": false
          }
        ]
ObiWanCanOweMe commented 2 years ago

Amazing, I removed the "Spare" sprinkler, restarted HA, and that fixed it! Long story short, thought I lost the sprinkler unit over the winter and bought a replacement. Once I got the replacement I found the original one (of course). I renamed the original to "Spare" and removed it from the zone.

sebr commented 1 year ago

Fixed in #195