jhansche / ha-birdbuddy

Home Assistant integration for Bird Buddy smart bird feeders
MIT License
40 stars 2 forks source link

No recent visitors after 2024.5 update #83

Closed AuroreVgn closed 1 week ago

AuroreVgn commented 2 weeks ago

Hi!

After an upgrade to 2024.5, "Recent Visitor" doesn't work. To be more specific: "sensor.recent_visitor" sensor was "Unavailable" despite is "Enable" in the settings as you can show bellow. Please note that I am running the last version of BB integration: 0.0.19 (with the tricks mentioned in this issue)

image image

AuroreVgn commented 2 weeks ago

The issue occures also in 2024.5.1 update.

jhansche commented 2 weeks ago

I just updated to 5.1, and I'm not seeing either issue, this one or #82. I didn't have to patch my langcodes version, and my recent visitor entity is working correctly.

Do you have any birdbuddy related warnings or errors in the logs?

In the BB app, do you see any recent visitors there - especially in the Saved view? Sometimes after a restart of HA you might have to wait until the next postcard arrives, since it will populate from new postcards. It does also try to populate from the last saved postcard in the feed as well, but that's only a best-effort attempt.

AuroreVgn commented 2 weeks ago

I have a look at the logs and I only have the following ones:

image

In BB app, I can seen recent visitors today.

jhansche commented 2 weeks ago

That error looks promising. What's the actual log (i.e. click on it)? If it's not there anymore you should be able to reload the integration to get it to log the error again.

AuroreVgn commented 1 week ago

I click on the errror log mentionned bellow and I have the following details:

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:580
integration: Sensor (documentation, issues)
First occurred: May 3, 2024 at 20:05:38 (3 occurrences)
Last logged: 17:26:40

Error adding entity sensor.etourmi_recent_visitor for domain sensor with platform birdbuddy
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 580, in _async_add_entities
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 892, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1358, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/config/custom_components/birdbuddy/sensor.py", line 148, in async_added_to_hass
    await self._update_latest_visitor()
  File "/config/custom_components/birdbuddy/sensor.py", line 216, in _update_latest_visitor
    medias := [
              ^
TypeError: 'NoneType' object is not iterable

It seems to be no sensors updates with Home Assistant Core 2024.5.1 and Bird Buddy 0.0.19 Unless you manually reload the integration, sensors will not changed over the time. I have this issue with "battery" (see below with two manual reloads) and "charging" sensors.

image
jhansche commented 1 week ago

Yeah if the sensor platform didn't load, then it likely wouldn't have finished the rest of the sensors either. I'll take a look at that your, thanks for reporting.

jhansche commented 1 week ago

You can try installing the version in the PR branch, with this service call:

service: update.install
target:
  entity_id: update.bird_buddy_update
data:
  version: pr/fix-83

Afterwards it will ask you to restart HA to finish the install. Note it will start saying that there's a newer version (v0.0.19), but that's just because this PR branch isn't released yet.

Let me know if a) your recent visitors entity starts working again, and/or b) the rest of the sensors start working again.

AuroreVgn commented 1 week ago

I tried to "update" to pr/fix-38 by using your service call under the "Developer tools" menu tab "services" and I still am in 0.0.19. I also tried to pu the code you provide in configuration.yaml or in a script ("Automation" menu then "Scripts" tab) without success. I am not very sure this is the good way to use a service call. Could ou please tell me what is the right way to do this?

jhansche commented 1 week ago

Doing it from the developer tools screen is the correct place:

Screenshot 2024-05-05 at 1 50 28 PM

After running the service, you'll go back to the Settings menu, and there will be 2 Bird Buddy notifications at the top: one telling you to restart HA, and the other telling you that there is an update available:

Screenshot 2024-05-05 at 1 48 19 PM

You need to ignore the update line, because that will undo the PR version. You'll note that in the dialog - it's trying to replace the pr/fix-83 version with v0.0.19, which is NOT what you want: Screenshot 2024-05-05 at 1 46 46 PM

But you do have to click the Restart required repair, and actually restart HA. After it restarts, it will continue showing the available update to v0.0.19, but you must continue to ignore it. If you install that, it will remove the PR fix.

AuroreVgn commented 1 week ago

Thank you! I think I still have an issue to run the service install :-( I can see this warning in logs :

image
jhansche commented 1 week ago

OK, that means the HACS update entity isn't right.

When you go to Settings > Devices & Services > Entities tab, and search for "bird buddy", you should see an Update entity owned by integration HACS. That entity is the one you need to use in the service call. Screenshot 2024-05-05 at 2 36 19 PM

Or in the Dev Tools Service screen, click the Go to UI Mode button in the bottom left, and choose the correct entity from the "Choose Entity" list. Pick the one that DOES NOT have the name of your BB and "Firmware" in the name, that is different, because that's the one to install a BB firmware update. You want the one that is just named "Bird Buddy Update": Screenshot 2024-05-05 at 2 38 09 PM

AuroreVgn commented 1 week ago

I don't have any entities related to bird buddy and own by HACS :-(

image
jhansche commented 1 week ago

Did you install the BB integration via HACS, or installed manually? Do you have any update.* entities owned by HACS?

I wonder if this might be an Experimental feature of HACS 🤔 If you go to the HACS integration page and then click the "Configure" button, do you have Enable experimental features checked?

AuroreVgn commented 1 week ago

I have installed BB integration (and all other one) with HACS and I have no 'update' entities at all.

Yeeahhhh! By activating experimental featured, I have a lot of 'update' entities!!

I can follow your tutorial above!

AuroreVgn commented 1 week ago

I did it.

Good news! I now have the recent visitor working (and it seems I have some history):

image

I can't tell you right now if the sensors are updating without manual reload but it seems not. I will let you now tomorrow after the night (Paris time).

jhansche commented 1 week ago

If it's nighttime, and the BB is in sleep mode, then none of the sensors will update until it's online again.

If it's not in sleep mode and you're also not seeing other entities update still, then there might be another warning or error in your logs?

AuroreVgn commented 1 week ago

After the night, it seems that all sensors are updating alone :-)

Battery:

image

State:

image

Your fix is working!

jhansche commented 1 week ago

Great, thank you for testing. This will be addressed in the next release.