[Custom component] Bird Buddy smart bird feeder

I am constantly getting this error when running the Bird Buddy Postcard Collection Blueprint. Any ideas as to how i can resolve getting this error? The integration seems to be working as it should.

``

Logger: homeassistant.components.automation.bird_buddy_postcard_collection
Source: components/automation/__init__.py:718
integration: Automation (documentation, issues)
First occurred: January 10, 2025 at 5:41:48 PM (6 occurrences)
Last logged: 4:54:36 PM

While executing automation automation.bird_buddy_postcard_collection
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 718, in async_trigger
    return await self.action_script.async_run(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        variables, trigger_context, started_action
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1801, in async_run
    return await asyncio.shield(create_eager_task(run.async_run()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 464, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 528, in _async_step
    self._handle_exception(
    ~~~~~~~~~~~~~~~~~~~~~~^
        ex, continue_on_error, self._log_exceptions or log_exceptions
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 558, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 526, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 764, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<9 lines>...
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 727, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2795, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2838, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/birdbuddy/__init__.py", line 106, in handle_collect_postcard
    await coordinator.handle_collect_postcard(service.data)
  File "/config/custom_components/birdbuddy/coordinator.py", line 144, in handle_collect_postcard
    success = await self.client.finish_postcard(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<5 lines>...
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/birdbuddy/client.py", line 456, in finish_postcard
    for sighting, mod in report.sighting_finishing_strategies(
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        confidence_threshold
        ^^^^^^^^^^^^^^^^^^^^
    ).values():
    ^
  File "/usr/local/lib/python3.13/site-packages/birdbuddy/sightings.py", line 207, in sighting_finishing_strategies
    matches = self.highest_confidence_matches
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/birdbuddy/sightings.py", line 251, in highest_confidence_matches
    i["matchToken"]: max(
                     ~~~^
        (ii for ii in i["items"] if ii["type"] == "BIRD"),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        key=lambda x: x["confidence"],
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
ValueError: max() iterable argument is empty

Hmm, looks like you’re running a quite old version of the integration. That was fixed in Nov 2023 :flushed:

Please try updating to the latest version (v0.0.21)

Thank you for the help. I have installed the most current version and now I am waiting for the birds. Question: have you been able to access the live-stream with HA yet. I was just reading an AI response that says it is working in this HA integration.

No, there is no plan to access the live stream in HA - that was an AI hallucination.

The Bird Buddy is not designed for 24/7 live streaming. The ability to check the live camera from the BB app is only for troubleshooting purposes, so you can confirm connectivity and visual placement. While in this mode, the BB will not function as it usually does; and it will drain the battery if you try to leave it streaming.

Should I be getting the errors below from the Blueprint Automation collect_postcard.yaml:. Are these errors fatal?

I’ve never seen this, as I didn’t edit the blueprint in VS Code since creating it.

If you look at the blueprint selectors documentation, it appears that, e.g. sort: false, IS valid. Though it also looks like sort=false is the default, so you could also just remove that.

To resolve the first error, it looks like it wants a list:

selector:
  device:
    - integration: birdbuddy
  multiple: false

So multiple gets unindented to the same level as device; and integration line adds a - array item notation.

Thank you Joe. Appreciate you looking at it. I will make the changes. Btw, upgrading fixed the problems i was having so thank you for that as well.

Can someone tell me what this error means when adding the same URL?

I got it working with double quotes. i restarted my HA, it stopped working. I went to set up camera agian it keeps telling me

Relative URLs are not allowed

Please helpppp

Generic Camera (especially with the UI config flow) does not work nicely with template URLs. And especially if the template does not currently resolve to a usable URL. Test your template in the developer tools screen, and check if it evaluates to a real URL and that you can view the image using that URL. If it’s reporting None or some other non-URL, then the generic camera config flow will NOT accept it. That’s because the config flow will show the image from that URL and requires that you confirm the image before you can finish setup.

Alternatively you could try to add it directly to configuration.yaml, which used to work, but not sure if it still does.

Finally, the image entity is still sitting in an open PR, because I’m not entirely happy with it yet. When the recent visitor entity_picture is working, the image entity also appears to be working. It’s just a little unpredictable, particularly when there hasn’t been a visitor in several days. If you’re interesting in testing out the PR, you can run the action yaml mentioned here. That will install the PR version, and when you restart HA you should have a new image entity, and you won’t need the Generic Camera workaround anymore.

@madcoder

Generic Camera (especially with the UI config flow) does not work nicely with template URLs.

Do you have an example of a template URL that is not working correctly with generic camera? It is intended to handle these.

When you enter URLs during the config flow, the following checks happen:

  1. Templates are rendered, and a check is done to make sure that there is a valid image or stream at the other end of the resulting URL.
  2. The config flow attempts to load a preview of the image and/or stream. You can ignore these if you like by clicking ‘everything looks good’, even if it doesn’t. This will finish the config flow.

But you are correct that 1. will not succeed if the URLs are not valid. This logic is to catch problems caused by people entering the URL of an HTML page which embedded an image/stream rather than the actual raw image/stream URL. In a lot of cases users did not understand the difference.

configuration.yaml setup of cameras is not supported any more. I don’t know what happens if you try it.

If you have a specific use-case that isn’t working, please describe it or raise as a bug ticket and I will help where I can.

Nope, that’s exactly what I was referring to. Since the template won’t evaluate to a valid URL unless there is an image to show, so if you try to enter the template while the attribute is not set or after the signed URL has expired, then it prevents you from setting it up. Once there’s a valid image URL in the attribute then it will work and will remain valid from then on. That’s what I meant by that.

Would be nice if there were a “yes I know this isn’t a valid URL, but save it anyway” override.

Anyway, the right solution here is the image entity, which is what’s in progress now and will be released eventually