sebr / bhyve-home-assistant

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

Integration breaks when disabling a subset of devices #201

Closed stormshaker closed 1 year ago

stormshaker commented 1 year ago

Describe the bug No Zone Switch devices created after installation and Configuration in Home Assistant. Installation and Config via HACS.

Expected behaviour One Zone Switch created per watering zone, as described in readme

BHyve devices One B-Hyve device, a 12-zone controller

Device Diagnostics config_entry-bhyve-bbfb288f5c42fa9b2e346fa9c5edcf8c.json.txt

sebr commented 1 year ago

Your diagnostics look fine so I can't see any immediate reason why this would be happening.

Can you please enable debugging the bhyve component in Home Assistant? Please follow these steps:

  1. Run the service call below to enable debug logging
  2. Attach the log to this issue. It is preferable to only keep lines which contain custom_components.bhyve to avoid unnecessarily sharing information.
logger:
  logs:
    custom_components.bhyve: debug
    pybhyve: debug

Once this is done, you can set the level back to warning

stormshaker commented 1 year ago

Thankyou! I think the relevant lines from the log are below, but let me know if you need something else from it.

Also FYI, I have Smart Watering enabled for each zone - in fact I have no timed programs at all and only Smart Watering.

2023-06-05 10:05:40.909 INFO (MainThread) [custom_components.bhyve.switch] Creating switch: Monash rain delay
2023-06-05 10:05:40.909 INFO (MainThread) [custom_components.bhyve.switch] Creating switch: Front Lawn 1 zone
2023-06-05 10:05:40.909 INFO (MainThread) [custom_components.bhyve.switch] Front Lawn 1 zone watering_status: {'clear_on_idle': True}
2023-06-05 10:05:40.909 INFO (MainThread) [custom_components.bhyve.switch] Front Lawn 1 Zone: Watering program Smart Watering (e) is not enabled, skipping
2023-06-05 10:05:40.909 INFO (MainThread) [custom_components.bhyve.switch] Creating switch: Front Lawn 2 zone
2023-06-05 10:05:40.910 INFO (MainThread) [custom_components.bhyve.switch] Front Lawn 2 zone watering_status: {'clear_on_idle': True}
2023-06-05 10:05:40.910 INFO (MainThread) [custom_components.bhyve.switch] Front Lawn 2 Zone: Watering program Smart Watering (e) is not enabled, skipping
2023-06-05 10:05:40.910 INFO (MainThread) [custom_components.bhyve.switch] Creating switch: Back Garden zone
2023-06-05 10:05:40.910 INFO (MainThread) [custom_components.bhyve.switch] Back Garden zone watering_status: {'clear_on_idle': True}
2023-06-05 10:05:40.911 INFO (MainThread) [custom_components.bhyve.switch] Back Garden Zone: Watering program Smart Watering (e) is not enabled, skipping
2023-06-05 10:05:40.911 INFO (MainThread) [custom_components.bhyve.switch] Creating switch: Front Bottom Beds zone
2023-06-05 10:05:40.911 INFO (MainThread) [custom_components.bhyve.switch] Front Bottom Beds zone watering_status: {'clear_on_idle': True}
2023-06-05 10:05:40.911 INFO (MainThread) [custom_components.bhyve.switch] Front Bottom Beds Zone: Watering program Smart Watering (e) is not enabled, skipping
2023-06-05 10:05:40.911 INFO (MainThread) [custom_components.bhyve.switch] Creating switch: Front Top Beds zone
2023-06-05 10:05:40.911 INFO (MainThread) [custom_components.bhyve.switch] Front Top Beds zone watering_status: {'clear_on_idle': True}
2023-06-05 10:05:40.911 INFO (MainThread) [custom_components.bhyve.switch] Front Top Beds Zone: Watering program Smart Watering (e) is not enabled, skipping
2023-06-05 10:05:40.912 INFO (MainThread) [custom_components.bhyve.switch] Creating switch: Pool Lawn zone
2023-06-05 10:05:40.912 INFO (MainThread) [custom_components.bhyve.switch] Pool Lawn zone watering_status: {'clear_on_idle': True}
2023-06-05 10:05:40.912 INFO (MainThread) [custom_components.bhyve.switch] Pool Lawn Zone: Watering program Smart Watering (e) is not enabled, skipping
2023-06-05 10:05:40.912 INFO (MainThread) [custom_components.bhyve.switch] Creating switch: Clothes Line Lawn zone
2023-06-05 10:05:40.912 INFO (MainThread) [custom_components.bhyve.switch] Clothes Line Lawn zone watering_status: {'clear_on_idle': True}
2023-06-05 10:05:40.912 INFO (MainThread) [custom_components.bhyve.switch] Clothes Line Lawn Zone: Watering program Smart Watering (e) is not enabled, skipping
2023-06-05 10:05:40.913 INFO (MainThread) [custom_components.bhyve.switch] Creating switch: Studio Beds zone
2023-06-05 10:05:40.913 INFO (MainThread) [custom_components.bhyve.switch] Studio Beds zone watering_status: {'clear_on_idle': True}
2023-06-05 10:05:40.914 INFO (MainThread) [custom_components.bhyve.switch] Studio Beds Zone: Watering program Smart Watering (e) is not enabled, skipping
2023-06-05 10:05:40.915 INFO (MainThread) [custom_components.bhyve.switch] Creating switch: Program Program A
2023-06-05 10:05:40.962 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 304, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/bhyve/switch.py", line 182, in async_setup_entry
    BHyveProgramSwitch(
  File "/config/custom_components/bhyve/switch.py", line 228, in __init__
    device_name = device.get("name", "Unknown switch")
AttributeError: 'NoneType' object has no attribute 'get'
sebr commented 1 year ago

@stormshaker Did you happen to disable the Dover Gardens device when configuring the integration?

stormshaker commented 1 year ago

Yes I did - this HA instance is only for the Monash site - Dover Gardens is also on the account.

stormshaker commented 1 year ago

Confirmed - that's the problem. If I enable the other Device in Configuration, the switches are created for both devices.

kmurphy505 commented 1 year ago

I experienced the same issue, thought I would share in case it helps. I am on version 3.2.0 of the integration. I had a working system with HA automations, I added a new sprinkler controller to my Bhyve account that was at another property, so I wasn't planning on this HA instance interacting with it. As soon as I did that, the integration's switches became disabled and the services, like bhyve.start_watering, disappeared. Once I read this thread, I went into the config on the integration in HA and put a checkbox next to the new controller and that resolved the issue. It seems like if a device is excluded, it breaks. I was able to still see history and status of the devices, I just had no control of them.

@sebr Thanks for this integration, it generally works great for me!