Closed gitwob101 closed 3 months ago
Hey, that’s no good. I’ll see if I can take a look tonight (UTC-7 here)
Taking a look at this, can you confirm in output of your OSBee, such as a simple curl -v http://192.168.xx.xx/jc
, that the Content-Type
is really application/json
?
I just confirmed that my OSBee doesn't do that, but if there's been a firmware upgrade, I haven't updated.
If your OSBee has that Content-Type, please do confirm (as it's good news), and then maybe try this:
In custom_components/osbee/osbeeapi.py
, around line 61, you'll see:
jc_body = await jc_request.json(content_type="text/html")
Change that to:
jc_body = await jc_request.json()
Lemme know how that goes.
Hi,
Thanks for looking at this. The result is json:
curl -v http://192.168.xx.xx/jc
* Trying 192.168.xx.xx:80...
* Connected to 192.168.xx.xx (192.168.xx.xx) port 80
> GET /jc HTTP/1.1
> Host: 192.168.xx.xx
> User-Agent: curl/8.5.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: application/json
< Access-Control-Allow-Origin: *
< Content-Length: 212
< Connection: close
<
* Closing connection
{"fwv":102,"sot":0,"utct":1713621577,"pid":-1,"tid":-1,"np":0,"nt":0,"mnp":6,"prem":0,"trem":0,"zbits":0,"name":"MyOSBee","mac":"xxxxxxxxxxx","cid":5451440,"rssi":-53,"cld":0,"zons":["Zone 1","Zone 2","Zone 3"]}#
I don't know exactly what happened but HA seemed to restart with osbee working for a short time and broke again:
2024-04-20 07:34:00.076 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration osbee which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-04-20 07:34:00.077 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-04-20 07:34:00.970 WARNING (MainThread) [custom_components.osbee.osbeeapi] type of timeout/max_runtime is <class 'int'>
2024-04-20 07:34:00.970 WARNING (MainThread) [custom_components.osbee.osbeeapi] created OSBeeAPI at 192.168.xx.xx max_runtime 1800 (<class 'int'>)
2024-04-20 07:34:01.663 WARNING (MainThread) [homeassistant.helpers.frame] Detected that custom integration 'hacs' accesses hass.components.frontend. This is deprecated and will stop working in Home Assistant 2024.9, it should be updated to import functions used from frontend directly at custom_components/hacs/frontend.py, line 68: hass.components.frontend.async_register_built_in_panel(, please create a bug report at https://github.com/hacs/integration/issues
Since I couldn't determine what took place and was not able to reproduce, I uninstall osbee and HACS and re-installed, the following has been consistent:
cat home-assistant.log
2024-04-20 09:57:38.977 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration osbee which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-04-20 09:57:38.978 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-04-20 09:57:39.689 WARNING (MainThread) [custom_components.osbee.osbeeapi] type of timeout/max_runtime is <class 'int'>
2024-04-20 09:57:39.690 WARNING (MainThread) [custom_components.osbee.osbeeapi] created OSBeeAPI at 192.168.xx.xx max_runtime 1800 (<class 'int'>)
2024-04-20 09:57:39.714 ERROR (MainThread) [custom_components.osbee.coordinator] In coordinator.py::OSBeeHubCoordinator::Exception on api::fetch_data Server disconnected
Traceback (most recent call last):
File "/config/custom_components/osbee/coordinator.py", line 46, in _async_update_data
return await self.my_api.fetch_data(listening_idx)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/osbee/osbeeapi.py", line 40, in fetch_data
async with self._session.get(f"http://{self._host}/jc") as jc_request:
File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1194, in __aenter__
self._resp = await self._coro
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 605, in _request
await resp.start(conn)
File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 976, in start
message, payload = await protocol.read() # type: ignore[union-attr]
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/streams.py", line 640, in read
await self._waiter
aiohttp.client_exceptions.ServerDisconnectedError: Server disconnected
2024-04-20 09:57:39.726 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up osbee platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 356, in _async_setup_platform
await asyncio.shield(awaitable)
File "/config/custom_components/osbee/sensor.py", line 112, in async_setup_platform
await coordinator.async_config_entry_first_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 280, in async_config_entry_first_refresh
await self._async_refresh(
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 414, in _async_refresh
self.async_update_listeners()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 168, in async_update_listeners
update_callback()
File "/config/custom_components/osbee/binary_sensor.py", line 168, in _handle_coordinator_update
self._attr_is_on = (self.coordinator.data["zbits"] & mask) > 0
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable
2024-04-20 09:57:40.421 WARNING (MainThread) [homeassistant.helpers.frame] Detected that custom integration 'hacs' accesses hass.components.frontend. This is deprecated and will stop working in Home Assistant 2024.9, it should be updated to import functions used from frontend directly at custom_components/hacs/frontend.py, line 68: hass.components.frontend.async_register_built_in_panel(, please create a bug report at https://github.com/hacs/integration/issues
Hi Again, I wasn't paying close attention to my dashboard, but about an hour after I posted my previous post, it looks like an rssi osbee device appeared (or started working) with a graph for WiFi signal strength via click through. In the same dashboard, I have three binary sensors and switches (1 per zone) and they are functional, albeit they need to be manipulated slowly. I presume to allow one to complete execution before going on to the next. I don't know when they appeared. For good measure, I restarted HA before posting here. The rssi device now reports as unavailable but the switches still work. The graph shows signal between when it began to work and the HA restart, but also some signal from earlier this morning likely pertaining to when I started that things looked like they were working and the stopped, etc. For what it is worth, here the the logs from when the main slider of the switch (as opposed to the sub-switches) is disabled. Perhaps this is expected:
24-04-20 12:59:33.782 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140163639134784] Server disconnected
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 239, in handle_call_service
response = await hass.services.async_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2543, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2580, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/homeassistant/__init__.py", line 144, in async_handle_turn_service
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/core.py", line 2543, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2580, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 996, in entity_service_call
raise result from None
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1580, in async_request_call
return await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1043, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/config/custom_components/osbee/switch.py", line 173, in async_turn_off
await self._hub.async_turn_off(self._zone_id)
File "/config/custom_components/osbee/osbeeapi.py", line 85, in async_turn_off
return await self.async_apply_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/osbee/osbeeapi.py", line 142, in async_apply_state
return await self.fetch_data(0)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/osbee/osbeeapi.py", line 40, in fetch_data
async with self._session.get(f"http://{self._host}/jc") as jc_request:
File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1194, in __aenter__
self._resp = await self._coro
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 605, in _request
await resp.start(conn)
File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 976, in start
message, payload = await protocol.read() # type: ignore[union-attr]
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/streams.py", line 640, in read
await self._waiter
aiohttp.client_exceptions.ServerDisconnectedError: Server disconnected
The OSBee has a funky API that I tried to workaround, I might have made errors in the implementation.
you can’t just turn on or off a single valve; it seems the OSBee needs to have “the values that are turned on of off” updated. There are other oddities.
the system needs to track switch status, then send an update for all three valves. There’s some mutex and stuff there that can be a bit convoluted.
the optimal pattern should be just “turn on number 2” so I’ll need to work on that.
is your OSBee now giving “text/html” as content-type, or “application/json”?
It is returning applications/json.
It is returning applications/json.
Did you try the workaround near the words "Change that to" in https://github.com/chickenandpork/hass-osbee/issues/9#issuecomment-2067609189 ?
Line 61 was modified to: jc_body = await jc_request.json()
Presently, the three switches work but the "osbee xxx rssi" is "Unavailable.
Oh, I missed that last update -- it's a month old too. really sorry.
I just dropped a v0.2.0 of the underlying library; can you run this code and share the output? (maybe XXX-out your IP if you're worried)
You should see "rssi" dumped as well as a dozen or so attributes. You may need to "pip install osbee" for the underlying library to be available.
import aiohttp
import asyncio
from json import dumps
from osbee import OSBeeAPI
async def main():
async with aiohttp.ClientSession() as client:
host = "192.168.0.1"
token = "opendoor" # default password for OSBee
body = await OSBeeAPI(host, 30, token, client).fetch_data(0)
print(dumps(body, indent=4, sort_keys=True))
asyncio.run(main())```
@gitwob101 ^^ forgot to tag you. Really feeling like a bonehead tonight :-/
Oh, I missed that last update -- it's a month old too. really sorry.
I just dropped a v0.2.0 of the underlying library; can you run this code and share the output? (maybe XXX-out your IP if you're worried)
You should see "rssi" dumped as well as a dozen or so attributes. You may need to "pip install osbee" for the underlying library to be available.
import aiohttp import asyncio from json import dumps from osbee import OSBeeAPI async def main(): async with aiohttp.ClientSession() as client: host = "192.168.0.1" token = "opendoor" # default password for OSBee body = await OSBeeAPI(host, 30, token, client).fetch_data(0) print(dumps(body, indent=4, sort_keys=True)) asyncio.run(main())```
I'd like to help debugging. I have the same problem with the RSSI missing. Sorry for asking, but I'm not used to run my own code on HASS. Any hint on how to get a dump would be appreciated. Thanks
I replaced custom_components/osbee with the new code, including applying the line 61 replacement as above. Having restarted HA, HA did not appear to be communicating with the OSBEE until I ran "pip install osbee" from a Python venv.
Here is my output from my local customizations:
(venv) homeassistant # python test
type of timeout/max_runtime is <class 'int'>
created OSBeeAPI at 192.168.2.33 max_runtime 30 (<class 'int'>)
{
"cid": 5451440,
"cld": 0,
"fwv": 102,
"mac": "C45BBE532EB0",
"mnp": 6,
"name": "MyOSBee",
"np": 3,
"nt": 0,
"pid": -1,
"prem": 0,
"rssi": -68,
"sot": 0,
"tid": -1,
"trem": 0,
"utct": 1717244286,
"zbits": 0,
"zons": [
"Back Yard",
"Patio",
"Front Yard"
]
}
(venv) homeassistant # exit
Logs are:
2024-06-01 08:19:35.647 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration osbee which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2024-06-01 08:19:35.647 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2024-06-01 08:19:36.578 WARNING (MainThread) [custom_components.osbee.osbeeapi] type of timeout/max_runtime is <class 'int'> 2024-06-01 08:19:36.578 WARNING (MainThread) [custom_components.osbee.osbeeapi] created OSBeeAPI at 192.168.2.33 max_runtime 2700 (<class 'int'>) 2024-06-01 08:19:36.739 ERROR (MainThread) [custom_components.osbee.coordinator] In coordinator.py::OSBeeHubCoordinator::Exception on api::fetch_data Server disconnected Traceback (most recent call last): File "/config/custom_components/osbee/coordinator.py", line 46, in _async_update_data return await self.my_api.fetch_data(listening_idx) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/osbee/osbeeapi.py", line 40, in fetch_data async with self._session.get(f"http://{self._host}/jc") as jc_request: File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1197, in aenter self._resp = await self._coro ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 608, in _request await resp.start(conn) File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 976, in start message, payload = await protocol.read() # type: ignore[union-attr] ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/streams.py", line 640, in read await self._waiter aiohttp.client_exceptions.ServerDisconnectedError: Server disconnected 2024-06-01 08:19:36.743 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up osbee platform for sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 356, in _async_setup_platform await asyncio.shield(awaitable) File "/config/custom_components/osbee/sensor.py", line 112, in async_setup_platform await coordinator.async_config_entry_first_refresh() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 280, in async_config_entry_first_refresh await self._async_refresh( File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 414, in _async_refresh self.async_update_listeners() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 168, in async_update_listeners update_callback() File "/config/custom_components/osbee/binary_sensor.py", line 168, in _handle_coordinator_update self._attr_is_on = (self.coordinator.data["zbits"] & mask) > 0
TypeError: 'NoneType' object is not subscriptable
2024-06-01 08:19:37.706 WARNING (MainThread) [homeassistant.helpers.frame] Detected that custom integration 'hacs' accesses hass.components.frontend. This is deprecated and will stop working in Home Assistant 2024.9, it should be updated to import functions used from frontend directly at custom_components/hacs/frontend.py, line 68: hass.components.frontend.async_register_built_in_panel(, please create a bug report at https://github.com/hacs/integration/issues
2024-06-01 08:19:48.181 WARNING (MainThread) [homeassistant.helpers.frame] Detected that custom integration 'hacs' accesses hass.helpers.event. This is deprecated and will stop working in Home Assistant 2024.11, it should be updated to import functions used from event directly at custom_components/hacs/base.py, line 642: self.hass.helpers.event.async_track_time_interval(, please create a bug report at https://github.com/hacs/integration/issues
```
@gitwob101 thanks -- I think you're reporting that you needed to manually install the dependent library:
HA did not appear to be communicating with the OSBEE until I ran "pip install osbee"
This is a valid bug; I believe I've solved in #14, and I've got a release 0.1.1 that publishes the fix, but for some reason, I didn't pull-the-trigger on it.
Would you be willing to re-test on v0.1.1?
By release 0.1.1, the line 61 swap (content type) shouldn't be necessary.
By release 0.1.1, the line 61 swap (content type) shouldn't be necessary.
I updated to 0.1.1 using HACS and had to fix line 61 to get the entities working.
I don't know if @gitwob101 will have the same results. Maybe I've done something wrong.
I haven't been using HACS for installation until now. HACS installation forces current (1.3 at time of writing). In HACS, re-download to 1.1.
In /homeassistant/custom_components/osbee/osbeeapi.py line 61, remove content_type variable:
'''jc_body = await jc_request.json(content_type="text/html")'''
jc_body = await jc_request.json()
Restart and I see RSSI data now. Switches are also working. This is where I need to be for today.
In the process of testing this, I also tested 1.2 & 1.3 to no avail, and moved to 1.1 as per this thread. Your notes indicate the you are moving libraries to pypi. I am curious as to what this entails and how it will integrate with HAOS, is based on Alpine Linux.
I will likely create a new feature request to see if we can get more out of the OSBEE device.
I haven't been using HACS for installation until now. HACS installation forces current (1.3 at time of writing). In HACS, re-download to 1.1.
In /homeassistant/custom_components/osbee/osbeeapi.py line 61, remove content_type variable:
'''jc_body = await jc_request.json(content_type="text/html")''' jc_body = await jc_request.json()
Restart and I see RSSI data now. Switches are also working. This is where I need to be for today.
In the process of testing this, I also tested 1.2 & 1.3 to no avail, and moved to 1.1 as per this thread. Your notes indicate the you are moving libraries to pypi. I am curious as to what this entails and how it will integrate with HAOS, is based on Alpine Linux.
I will likely create a new feature request to see if we can get more out of the OSBEE device.
are we essentially OK with this?
FWIW there is now a release 1.4
I tested 1.3 and 1.4 and I had to revert to 1.1 because all osbee entities were missing.
Difficult to debug from here, but I’d like to find out what’s wrong. Are you able to share a log file of the v1.4 ?
Difficult to debug from here, but I’d like to find out what’s wrong. Are you able to share a log file of the v1.4 ?
2024-08-09 13:06:19.431 ERROR (SyncWorker_4) [homeassistant.util.package] Unable to install package osbee>0.2.0: ERROR: Cannot install osbee==0.3.0 because these package versions have conflicting dependencies. ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts 2024-08-09 13:06:26.527 ERROR (SyncWorker_4) [homeassistant.util.package] Unable to install package osbee>0.2.0: ERROR: Cannot install osbee==0.3.0 because these package versions have conflicting dependencies. ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts 2024-08-09 13:06:33.567 ERROR (SyncWorker_4) [homeassistant.util.package] Unable to install package osbee>0.2.0: ERROR: Cannot install osbee==0.3.0 because these package versions have conflicting dependencies. ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts 2024-08-09 13:06:33.570 ERROR (MainThread) [homeassistant.config] Platform error: binary_sensor - Requirements for osbee not found: ['osbee>0.2.0']. 2024-08-09 13:06:33.574 ERROR (MainThread) [homeassistant.config] Platform error: sensor - Requirements for osbee not found: ['osbee>0.2.0']. 2024-08-09 13:06:33.607 ERROR (MainThread) [homeassistant.config] Platform error: switch - Requirements for osbee not found: ['osbee>0.2.0'].
Might be resolved now with osbee integration v0.0.3 which uses the library osbee-0.3.1
@marcolivierroy pleaee try an update? If it fails, another log would be most welcome. Thanks!
It works
It works
Awesome. There's more work to be done for this little integration, but I want to eliminate my past errors first. I'm glad you're OK now -- I hope it's OK that I close this issue.
Hi,
It looks like I have run into a bug:
hass-osbee downloaded via git clone
Install path:
/homeassistant/custom_components/osbee/
Logs:
/homeassistant/configuration.yaml:
/homeassistant/home-assistant.log:
I would appreciate any help as I would like to get this up and running.