home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70k stars 29.08k forks source link

Blink Integration. BLINK.BLINK_UPDATE Service Fails #105316

Open Zoriontsu opened 7 months ago

Zoriontsu commented 7 months ago

The problem

All features of the Blink Integration work OK for me, except the BLINK_UPDATE service. I get the following error: Failed to call service blink.blink_update. Unknown error image

What version of Home Assistant Core has the issue?

core-2023.12.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Blink

Link to integration documentation on our website

https://www.home-assistant.io/integrations/blink/

Diagnostics information

File "/usr/src/homeassistant/homeassistant/components/blink/services.py", line 150, in blink_refresh

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 7 months ago

Hey there @fronzbot, @mkmer, mind taking a look at this issue as it has been labeled with an integration (blink) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `blink` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign blink` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


blink documentation blink source (message by IssueLinks)

kwkid commented 7 months ago

Have the exact same issue...everything seems to be working except for blink.blink_update. Running Home Assistant os v 2023.12.0 as well

kwkid commented 7 months ago

my errors is slightly different "Failed to call service script blink_camera_snapshot. 'device_id'" is flashed along the bottom of the UI... the logs have this: websocket_api script: Error executing script. Unexpected error for call_service at pos 1: 'device_id' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 704, in _async_call_service_step response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 666, in _async_run_long_action return long_task.result() ^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2067, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2104, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/blink/services.py", line 150, in blink_refresh for coordinator in collect_coordinators(call.data[ATTR_DEVICE_ID]):


KeyError: 'device_id'
ilwalti commented 7 months ago

Hi, same condition and same errors here. Not an issue on 2023.11...

mkmer commented 7 months ago

Sorry for the mistakes. PR should have the services all fixed up.

ToroNander commented 7 months ago

Hi! In my case the error still remains. Same like in @kwkid message. Switched back again for the 2nd time to 2023.11.

Core 2023.11.3 Supervisor 2023.11.6 Operating System 11.2 Frontend 20231030.2

BR

MikyM0use commented 7 months ago

I think we have to wait for the next release to have the fix...? (same problem here..) meanwhile thank you

MikyM0use commented 7 months ago

Unfortunately even after the update to 2023.12.2 i have the same problem... Required key not provided @ data['device_id']

EDIT: I looked better, it seems now the refresh itself is not system wide but requires a camera id, right?

ilwalti commented 7 months ago

Yes, right. Add a camera ID and everything is fine! Thanks @ all

Pirol62 commented 7 months ago

That doesn't work: image

MikyM0use commented 7 months ago

Yes, right. Add a camera ID and everything is fine! Thanks @ all

not clear to me if the update now works only on the listed camera or on all the system... ?

mkmer commented 7 months ago

Update works on the whole system by picking one device id from the integration. This is a temporary situation, due to a mistake I made converting services. In the next pr, I have fixed this and you will only pick the integration from a pick list. If everything goes well, it should be in 2024.1

Pirol62 commented 7 months ago

Sorry: I tried in every possible way: Always get the message that the device cannot be found in the device registration. It doesn't work for me image

ilwalti commented 7 months ago

device_id: has to be something like 9026fab6546fc1516d90045c4f86d1xx Using the GUI I've no problems to define it.

Pirol62 commented 7 months ago

Ok, found it. Thank you. I use yaml and did not found the device_id even in the core registry. But using the gui and change from there into the yaml view provided the device_id. Strange path but it worked :-)

mkmer commented 7 months ago

We will be depreciating blink.update in the near future. Using Home Assistant Core Integration: Update entity achieves the same result, may as well move to it now :)

Pirol62 commented 7 months ago

Sounds good. Do I have to update one entity for all like blink.update or do I have to list all cameras here?

ilwalti commented 7 months ago

A list is allowed...

Pirol62 commented 7 months ago

done and works perfectly

mkmer commented 7 months ago

one entity gets all entities associated with the integration.

gregorymartin commented 7 months ago

Trying to follow this thread. I found it because my scripts that leverage trigger_camera broke due to change from using entity_id to device_id. This doesn’t seem right, entity_ids should be the preferred method for a call like this right? Does the PR above revert this breaking change?

mkmer commented 7 months ago

Use Assistant Core Integration: Update entity - the core team recommended removing the blink.update service in the near future. There is a PR https://github.com/home-assistant/core/pull/105413 that modifies Blink.Update to use the config_entry rather than a device or entity (which makes more sense to me) but at some point the blink.update service will be removed.

gregorymartin commented 7 months ago

Does that replicate the functionality of blink.trigger_camera? In the past, my understanding was you had to use blink.trigger_camera to have the camera take a picture and then blink.blink_update to refresh. I'm basing my assumptions off the Blink documentation that does not reflect any of these changes.

gregorymartin commented 7 months ago

I realize my questions are for a different service call than this original bug, and while I suspect they are related, I have logged an explicit bug for trigger_camera: https://github.com/home-assistant/core/issues/105991

mkmer commented 7 months ago

Both services call the exact same code internally, hence the choice to remove one. As for updating, as soon as the next blinkpy is released we should no longer need to do a refresh after the trigger_camera, it will be automatic. https://github.com/home-assistant/core/blob/5f2a13fec6ae026ae8b786a7723f8296d9d48fea/homeassistant/components/blink/camera.py#L105-L110 Any "early" testing is appreciated by installing dev branch of blinkpy.

gregorymartin commented 7 months ago

What is the underlying reason these calls were broken and switched to device_id and in turn, also made them less usable given the need to discover device_id vs. known entity_id? This feels like a major breaking change that was not thought through.

mkmer commented 7 months ago

A mistake, no thought was involved :)

gregorymartin commented 7 months ago

It happens, thanks for the clarity!

dougle03 commented 6 months ago

Both services call the exact same code internally, hence the choice to remove one. As for updating, as soon as the next blinkpy is released we should no longer need to do a refresh after the trigger_camera, it will be automatic.

https://github.com/home-assistant/core/blob/5f2a13fec6ae026ae8b786a7723f8296d9d48fea/homeassistant/components/blink/camera.py#L105-L110

Any "early" testing is appreciated by installing dev branch of blinkpy.

Hi, so I'm using NodeRed to trigger an update (Take new still) from all my cameras, I don't automation in HA. How does this change affect me?

Sorry should be on a new issue, but feel this thread is already covering it. Thanks.

Pirol62 commented 6 months ago

Hi, already updated to 2024.1.3. The component works well again. blink.update is obsolete, yes but the service update_entity has to be called otherwise the dashboard camera picture will never be updated. Here, it needs around 7 Minutes until the picture is refreshed after a new snapshot.

PS: Correction: It needs a little less then 2 Minutes

Pirol62 commented 6 months ago

From my point of view we can close this ticket.

UsernetFR commented 6 months ago

Hi,

If I launch this simple automation from HA for my 2 Blink cameras:

alias: Blink update thumbnail
description: 
condition: []
action:
  - service: blink.trigger_camera
    data: {}
    target:
      entity_id:
        - camera.cam1
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - service: blink.trigger_camera
    data: {}
    target:
      entity_id:
        - camera.cam2
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - service: blink.blink_update
    data: {}
mode: single

Thumbnails update almost instantly on the Official Blink mobile application.

But on the HA dashboard (Mobile/Desktop), you have to wait between 2 and 5 minutes to see the new thumbnails.

This is new behavior.

mkmer commented 6 months ago

You should no longer need to update after the snaps, it's now in the Blinkpy code. I too have noticed the pictures not updating but have not found the root problem. I'm looking :)

DoMike76 commented 3 months ago

Hi, solved: Grid Card:

type: grid
square: false
columns: 1
cards:
  - type: entities
    entities:
      - entity: binary_sensor.casa_movimento
        name: Movimento
    title: Casa
  - show_state: false
    show_name: false
    camera_view: auto
    type: picture-entity
    entity: camera.casa
    tap_action:
      action: call-service
      service: script.turn_on
      target:
        entity_id: script.aggiorna_cam_casa

Script in /homeassistant/scripts.yaml:

File: scripts.yaml

aggiorna_cam_casa:
  sequence:
    - service: blink.trigger_camera
      target:
        entity_id: camera.casa
    - service: blink.blink_update
      target:
        device_id: 22c370966f59fc92ed577657fff5003e
issue-triage-workflows[bot] commented 2 weeks ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.