core icon indicating copy to clipboard operation
core copied to clipboard

Failed to call service switch/turn_on

Open Micrologiciel opened this issue 9 months ago • 13 comments

The problem

Hello, I have 4 Hue bridges that are working perfectly. On 2 of these bridges, I have 5 motion sensors. Since the update to 2023.11.2, I encounter an error when I try to activate or deactivate the light sensor in configuration section. The error is: 'Failed to call service switch/turn_on. Request failed due to a connection error: 404, message='Not Found', url=URL('https://192.168.1.110/clip/v2/resource/motion/5cac64a6-67c4-48e3-b209-1c9f37ba6d66')'. The motion sensor itself is working fine. Attached is the screenshot of the problem

Capture d'écran 2023-11-21 213628

What version of Home Assistant Core has the issue?

Core 2023.11.2

What was the last working version of Home Assistant Core?

Core 2023.7.1

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Philips Hue, automation

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

Micrologiciel avatar Nov 21 '23 20:11 Micrologiciel

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

Code owner commands

Code owners of hue 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 hue 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)


hue documentation hue source (message by IssueLinks)

home-assistant[bot] avatar Nov 21 '23 22:11 home-assistant[bot]

Are you able to toggle the light sensor on other Hue bridges ?

Is this Hue bridge on the same firmware version as the other ones ?

marcelveldt avatar Nov 24 '23 14:11 marcelveldt

Hello,

On another sensor, which is on a different bridge, there is the same problem. All the bridges are on the same firmware version: 1.61.1961076030.

I'm not sure if it's related, but everything was working perfectly with HA version 2023.7.1. It could also be that there was a bridge update at the same time. That would be unfortunate.

If you need any more information, please don't hesitate to ask. Thanks in advance.

Micrologiciel avatar Nov 24 '23 15:11 Micrologiciel

Hello,

I have the same issue. It failed after updating to the latest version:

Core 2023.11.3 Supervisor 2023.11.3 Operating System 11.1

I restored the backup of my previous version, and it worked without any issues.

Regards, Soheil

oilesa avatar Nov 28 '23 13:11 oilesa

Experiencing the same behavior.

config_entry-hue-4918557eca4c7e55322787bb74db7c45.json

2023-11-29 00:59:00.998 ERROR (MainThread) [homeassistant.components.script.goodnight_scene] Goodnight Script: Error executing script. Error for call_service at pos 2: Request failed due connection error: 404, message='Not Found', url=URL('https://10.0.0.29/clip/v2/resource/motion/18e9bde7-b1f9-4c6c-a1a5-520681af0457') 2023-11-29 00:59:00.999 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139667205189696] Request failed due connection error: 404, message='Not Found', url=URL('https://10.0.0.29/clip/v2/resource/motion/18e9bde7-b1f9-4c6c-a1a5-520681af0457') Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/hue/bridge.py", line 123, in async_request_call return await task(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiohue/v2/controllers/sensors.py", line 179, in set_enabled await self.update(id, MotionPut(enabled=enabled)) File "/usr/local/lib/python3.11/site-packages/aiohue/v2/controllers/base.py", line 153, in update await self._bridge.request("put", endpoint, json=data) File "/usr/local/lib/python3.11/site-packages/aiohue/v2/init.py", line 177, in request resp.raise_for_status() File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1005, in raise_for_status raise ClientResponseError( aiohttp.client_exceptions.ClientResponseError: 404, message='Not Found', url=URL('https://10.0.0.29/clip/v2/resource/motion/18e9bde7-b1f9-4c6c-a1a5-520681af0457')

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 230, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 2035, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2072, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/script/init.py", line 605, in _service_handler response = await self._async_start_run( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/script/init.py", line 563, in _async_start_run script_result = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/script/init.py", line 594, in _async_run return await self.script.async_run(script_vars, context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1578, in async_run return await asyncio.shield(run.async_run()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 420, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 470, in _async_step self._handle_exception( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 493, in _handle_exception raise exception 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 2035, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2072, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/homeassistant/init.py", line 138, in async_handle_turn_service await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/core.py", line 2035, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2072, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service return await service.entity_service_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 904, in entity_service_call task.result() # pop exception if have ^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1219, in async_request_call return await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/hue/switch.py", line 105, in async_turn_off await self.bridge.async_request_call( File "/usr/src/homeassistant/homeassistant/components/hue/bridge.py", line 134, in async_request_call raise HomeAssistantError( homeassistant.exceptions.HomeAssistantError: Request failed due connection error: 404, message='Not Found', url=URL('https://10.0.0.29/clip/v2/resource/motion/18e9bde7-b1f9-4c6c-a1a5-520681af0457')

BTerell82 avatar Nov 29 '23 06:11 BTerell82

Hello @marcelveldt, I've just had this same error, Googled, and found this page.

My scenario is different from OP @Micrologiciel, but possibly the same bug.

I was attempting to set up an automation that enables/disables wake up routines on the Hue Bridge.

When the automation is fired, I get: Error: Request failed due connection error: 404, message='Not Found', url=URL('https://192.168.x.x/clip/v2/resource/motion/7c357868-9f04-4d66-84f4-56aa285e5c0d')

I verified using Postman that the URL it should have used is: /clip/v2/resource/behavior_instance/7c357868-9f04-4d66-84f4-56aa285e5c0d

The resource type should be "behavior_instance", not "motion".

For OP's issue, I suspect the resource type should have been "light_level" instead of "motion".

Is the integration possibly using "motion" in its URLs, where it should be using different resource types?

maximisltd avatar Dec 20 '23 06:12 maximisltd

Same problem here when trying to enable the illuminance sensor of my Hue Motion sensor

Core - 2023.12.4 Supervisor - 2023.12.0 Operating System - 11.2 Frontend - 20231208.2

JanNJNS avatar Dec 28 '23 15:12 JanNJNS

I'm running into the same issue. Trying to disable a phillips hue automation from a homeassistant automation. Selected device > bridge and chose the turn off automation.

Request failed due connection error: 404, message='Not Found', url=URL('https://10.6.154.166/clip/v2/resource/motion/2fbdf2bc-44e0-4bc9-a4ae-013b55a2ce58')

SteezyCougar avatar Dec 28 '23 21:12 SteezyCougar

Same issue for me with trying to change an Automation Switch, 404 error. Core - 2024.1.2 Supervisor - 2023.12.0 Operating System - 11.4 Frontend - 20240104.0

benroscoe avatar Jan 11 '24 21:01 benroscoe

I have the same issue for the automation switch. Lights and scenes work as expected

Core - 2024.1.5 Supervisor - 2023.12.1 Operating System - 11.4 Frontend - 20240104.0

MariekeVDA avatar Jan 24 '24 10:01 MariekeVDA

just had the same problem.
Wanted to set an automation to change the automation in Hue to on or off depending on a calendar entry.
Even when I try to manually change the state of the automation, I get this same error.
All the lights are connected, working and even the scenes are working perfectly when triggered in HA.
Only the on/off trigger of an automation trough HA is giving this 404 error.

HA Core 2024.2.1 Frontend 20240207.1

Unknown if this works in previous versions, just started to test this.

mcasteels avatar Feb 12 '24 11:02 mcasteels

+1

I have the same issue. When is it expected to be solved?

Workaround: Create a zone covering the bulbs in the home that should be toggled. Use that zone as entity to toggle lights, and if needed use HA to handle geofencing.

nc-jeni avatar Feb 18 '24 08:02 nc-jeni

I also was having this issue when trying to enable/disable a Hue automation switch. I was able to work around it by creating a restful api command manually that I can call.

In the configuration.yaml first you need to enable restful command module by adding rest_command:

In the configuration.yaml it looks something like this below. To turn off the automation, just make another one except in the payload make it {"enabled": false} instead of true.

rest_command:
  hue_office_schedule_on:
    url: "https://[Your Bridge IP]/clip/v2/resource/behavior_instance/whatever-automation-hue-id-xxxxx"
    method: PUT
    headers:
      hue-application-key: !secret hue_app_key
    payload: '{"enabled": true}'
    verify_ssl: false

Notes about the rest command entry above:

  • Make sure the URL has quotes around it, that seems to be required
  • The payload has to be a string so that also needs to have the quotes
  • I couldn't get it to work without doing verify_ssl: false
  • For the part that says !secret hue_app_key, it is that way because I have my hue bridge api key (previously called "username" in the V1 API I believe, same thing) set in the secrets.yaml file like: hue_app_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Some other notes:

  • You can get the automation's ID by sending a GET api request to: https://[Your Bridge IP]/clip/v2/resource/behavior_instance with a header called hue-application-key and value of that key/username mentioned before. You can do this with a program called Postman for example.
  • You'll have to look up how to create a app API key for your bridge but it's not hard to find instructions, I believe this shows you how but you need to make a hue developer account to log in and see it.

ThioJoe avatar Feb 25 '24 22:02 ThioJoe

This is fixed in the next HA patch release.

marcelveldt avatar Mar 11 '24 14:03 marcelveldt