Skip to content

[Library Bug] Bug from #99: methods with join call broken #101

@kizill

Description

@kizill

Describe the bug
Methods like get_state, set_state, trigger_service & fire_event are broken since #99

To Reproduce
This simple code snippet fails:

api_url = "https://somemy.domain.com/api"
token = 'MYTOKEN'
with Client(
    api_url,
    token,
) as ha_client:
    temperature = ha_client.get_state(entity_id='sensor.temperature')

Stack trace:

Traceback (most recent call last):
  File "/Users/kizill/repo/bolotov_info_bot/playground.py", line 29, in <module>
    ha_client.get_state(entity_id='sensor.temperature')
  File "/opt/homebrew/Caskroom/miniconda/base/envs/tg_bot/lib/python3.10/site-packages/homeassistant_api/rawclient.py", line 233, in get_state
    data = self.request(join("states", entity_id))
  File "/opt/homebrew/Caskroom/miniconda/base/envs/tg_bot/lib/python3.10/site-packages/homeassistant_api/rawclient.py", line 76, in request
    return self.response_logic(resp)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/tg_bot/lib/python3.10/site-packages/homeassistant_api/rawclient.py", line 81, in response_logic
    return Processing(response=response).process()
  File "/opt/homebrew/Caskroom/miniconda/base/envs/tg_bot/lib/python3.10/site-packages/homeassistant_api/processing.py", line 82, in process
    raise EndpointNotFoundError(self.response.url)
homeassistant_api.errors.EndpointNotFoundError: Cannot make request to the endpoint 'https://somemy.domain.com/api/sensor.temperature'

Reason
urljoin works not like path join:
urljoin('xyz', 'abc') - > 'abc'
urljoin('xyz/', 'abc') - > 'xyz/abc'

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions