Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.9.x - Set available #97

Closed
Tony763 opened this issue Feb 4, 2024 · 6 comments
Closed

0.9.x - Set available #97

Tony763 opened this issue Feb 4, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@Tony763
Copy link
Contributor

Tony763 commented Feb 4, 2024

Hi @twrecked, I am unable to set availability of entity trough websocket. This worked in 0.6.x.

2024-02-04 17:42:08.895 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [546918702784] l component not set up
Traceback (most recent call last):
File "/srv/ha/venv/lib/python3.11/site-packages/homeassistant/components/websocket_api/commands.py", line 238, in handle_call_service
response = await hass.services.async_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/ha/venv/lib/python3.11/site-packages/homeassistant/core.py", line 2149, in async_call
response_data = await coro
^^^^^^^^^^
File "/srv/ha/venv/lib/python3.11/site-packages/homeassistant/core.py", line 2186, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/ha/venv/lib/python3.11/site-packages/homeassistant/helpers/service.py", line 1043, in check_permissions
return await service_handler(call)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/homeassistant/.homeassistant/custom_components/virtual/__init__.py", line 142, in async_virtual_service_set_available
await async_virtual_set_availability_service(hass, call)
File "/home/homeassistant/.homeassistant/custom_components/virtual/__init__.py", line 206, in async_virtual_set_availability_service
get_entity_from_domain(hass, domain, entity_id).set_available(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/homeassistant/.homeassistant/custom_components/virtual/__init__.py", line 187, in get_entity_from_domain
raise HomeAssistantError("{} component not set up".format(domain))
homeassistant.exceptions.HomeAssistantError: l component not set up
2024-02-04 17:42:08.918 INFO (MainThread) [custom_components.virtual] set_available service called
2024-02-04 17:42:08.918 INFO (MainThread) [custom_components.virtual] s set_avilable(value=False)
2024-02-04 17:42:08.918 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [546918702784] s component not set up
Traceback (most recent call last):
File "/srv/ha/venv/lib/python3.11/site-packages/homeassistant/components/websocket_api/commands.py", line 238, in handle_call_service
response = await hass.services.async_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/ha/venv/lib/python3.11/site-packages/homeassistant/core.py", line 2149, in async_call
response_data = await coro
^^^^^^^^^^
File "/srv/ha/venv/lib/python3.11/site-packages/homeassistant/core.py", line 2186, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/ha/venv/lib/python3.11/site-packages/homeassistant/helpers/service.py", line 1043, in check_permissions
return await service_handler(call)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/homeassistant/.homeassistant/custom_components/virtual/__init__.py", line 142, in async_virtual_service_set_available
await async_virtual_set_availability_service(hass, call)
File "/home/homeassistant/.homeassistant/custom_components/virtual/__init__.py", line 206, in async_virtual_set_availability_service
get_entity_from_domain(hass, domain, entity_id).set_available(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/homeassistant/.homeassistant/custom_components/virtual/__init__.py", line 187, in get_entity_from_domain
raise HomeAssistantError("{} component not set up".format(domain))
homeassistant.exceptions.HomeAssistantError: s component not set up

image

Example websocket payload:

snd = {
  "id": id_msg,
  "type": "call_service",
  "domain": "virtual",
  "service": "set_available",
  "service_data": {
  "entity_id": id_,
  "value": event["state"]
  }
}
@Tony763
Copy link
Contributor Author

Tony763 commented Feb 4, 2024

Syntax for set_available changed:

This works:

 snd = {
  "id": id_msg,
  "type": "call_service",
  "domain": "virtual",
  "service": "set_available",
  "service_data": {
  "value": event["state"]
  },
  "target": {
      "entity_id": id_
  }
}

@Tony763
Copy link
Contributor Author

Tony763 commented Feb 4, 2024

This error occur not just with websocket, I can simulate it inside Developer tools > Services

Firing empty service shows request to define entity_id, device_id or area_id in target or data.
image

Adding entity _id inside target works as expected:
image

But adding entity _id inside data as suggested by HA fail with error from above:
image
(b is probably first letter from binary_sensor.aqua_bdoor)

@twrecked twrecked self-assigned this Feb 4, 2024
@twrecked
Copy link
Owner

twrecked commented Feb 4, 2024

I had to change some stuff around to make the UI Mode work. I'll take another look.

@twrecked
Copy link
Owner

twrecked commented Feb 4, 2024

I'll fix it. I need to check if entity_id is a list or not.

@twrecked twrecked added the bug Something isn't working label Feb 4, 2024
@twrecked
Copy link
Owner

twrecked commented Feb 4, 2024

Should be fixed by #98 and it's in the latest Alpha.

I had actually forgot to specify a schema for the service.

Let me know if it works for you.

@Tony763
Copy link
Contributor Author

Tony763 commented Feb 4, 2024

Yes, this works. Thank You 🙂

@Tony763 Tony763 closed this as completed Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants