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

Attempt to decode JSON with unexpected mimetype #187

Open
tj335 opened this issue Oct 28, 2022 · 5 comments
Open

Attempt to decode JSON with unexpected mimetype #187

tj335 opened this issue Oct 28, 2022 · 5 comments

Comments

@tj335
Copy link

tj335 commented Oct 28, 2022

I’m getting this error while trying to use an RGBW LED controller (note: I replaced the full access token with xxxx)

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/hubitat/hub.py:426
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 9:01:52 PM (2 occurrences)
Last logged: 9:01:56 PM

[140615776348448] 0, message='Attempt to decode JSON with unexpected mimetype: text/html;charset=utf-8', url=URL('http://192.168.1.175/apps/api/1371/devices/1024/setLevel/30?access_token=xxxx')
[140615776348448] 0, message='Attempt to decode JSON with unexpected mimetype: text/html;charset=utf-8', url=URL('http://192.168.1.175/apps/api/1371/devices/1024/setLevel/40?access_token=xxxx')
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 202, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1738, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1775, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 207, in handle_service
await service.entity_service_call(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 678, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 931, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 715, in _handle_entity_call
await result
File "/usr/src/homeassistant/homeassistant/components/light/init.py", line 546, in async_handle_light_on_service
await light.async_turn_on(**filter_turn_on_params(light, params))
File "/config/custom_components/hubitat/light.py", line 236, in async_turn_on
await self.send_command(CMD_SET_LEVEL, props["level"])
File "/config/custom_components/hubitat/device.py", line 165, in send_command
await self._hub.send_command(self.device_id, command, arg)
File "/config/custom_components/hubitat/hub.py", line 426, in send_command
await self._hub.send_command(device_id, command, arg)
File "/usr/local/lib/python3.10/site-packages/hubitatmaker/hub.py", line 228, in send_command
return await self._api_request(path)
File "/usr/local/lib/python3.10/site-packages/hubitatmaker/hub.py", line 421, in _api_request
json = await resp.json()
File "/usr/local/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 1103, in json
raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html;charset=utf-8', url=URL('http://192.168.1.175/apps/api/1371/devices/1024/setLevel/30?access_token=xxxx')

Running HAOS 2022.10.5, OS 9.2
Using the latest version of the Hubitat integration
My Hubitat C-7 hub is running 2.3.3.138.

I brought up the URL from the error and this is the output:

{"id":"1024","name":"Zooz Zen31 LED Controller","label":"Kids Room LED Strip","type":"Zooz Zen31 LED Controller","room":"Kids Room","attributes":[{"name":"colorMode","currentValue":"RGB","dataType":"STRING"},{"name":"level","currentValue":20,"dataType":"NUMBER"},{"name":"effectName","currentValue":"None","dataType":"STRING"},{"name":"lightEffects","currentValue":"{"0":"None","6":"Fireplace","7":"Storm","8":"Rainbow","9":"Polar Lights","10":"Police"}","dataType":"JSON_OBJECT"},{"name":"lightEffects","currentValue":"{"0":"None","6":"Fireplace","7":"Storm","8":"Rainbow","9":"Polar Lights","10":"Police"}","dataType":"JSON_OBJECT"},{"name":"saturation","currentValue":100,"dataType":"NUMBER"},{"name":"color","currentValue":null,"dataType":"STRING"},{"name":"colorName","currentValue":"Magenta","dataType":"STRING"},{"name":"colorMode","currentValue":"RGB","dataType":"ENUM","values":["CT","RGB"]},{"name":"colorTemperature","currentValue":null,"dataType":"NUMBER"},{"name":"colorName","currentValue":"Magenta","dataType":"STRING"},{"name":"hue","currentValue":83,"dataType":"NUMBER"},{"name":"RGB","currentValue":null,"dataType":"STRING"},{"name":"switch","currentValue":"on","dataType":"ENUM","values":["on","off"]}],"capabilities":["Configuration","Actuator","Refresh","ColorTemperature",{"attributes":[{"name":"colorTemperature","dataType":null},{"name":"colorName","dataType":null}]},"ColorMode",{"attributes":[{"name":"colorMode","dataType":null}]},"ColorControl",{"attributes":[{"name":"hue","dataType":null},{"name":"saturation","dataType":null},{"name":"color","dataType":null},{"name":"colorName","dataType":null},{"name":"RGB","dataType":null}]},"ChangeLevel","LightEffects",{"attributes":[{"name":"lightEffects","dataType":null},{"name":"effectName","dataType":null}]},"SwitchLevel",{"attributes":[{"name":"level","dataType":null}]},"Switch",{"attributes":[{"name":"switch","dataType":null}]},"Sensor"],"commands":["configure","off","on","refresh","setColor","setColorTemperature","setEffect","setHue","setLevel","setNextEffect","setPreviousEffect","setSaturation","startLevelChange","stopLevelChange"]}

@jcharr1
Copy link

jcharr1 commented Oct 28, 2022

I've suddenly started getting this error too when changing the levels of bulbs. Actual control of the bulbs still works fine. The error just pops up at the bottom of my dashboard when I change the level on any of them. I wonder if a Hubitat firmware update might be the culprit.

@jason0x43
Copy link
Owner

I've seen that error sporadically for quite some time. I'd guess in those cases that Hubitat is sending back an HTML error page rather than the expected JSON data. It's such a sporadic error that I've never really looked much into it. I really need to add some debugging code to see what Hubitat is actually returning on those cases...

@tj335
Copy link
Author

tj335 commented Oct 30, 2022

I've suddenly started getting this error too when changing the levels of bulbs. Actual control of the bulbs still works fine. The error just pops up at the bottom of my dashboard when I change the level on any of them. I wonder if a Hubitat firmware update might be the culprit.

I’ve been experiencing it for a while, going back at least several versions of the Hubitat firmware. I just finally got around to trying to see if I can get it resolved. But definitely looking like it’s a Hubitat issue.

@tj335
Copy link
Author

tj335 commented Oct 30, 2022

I've seen that error sporadically for quite some time. I'd guess in those cases that Hubitat is sending back an HTML error page rather than the expected JSON data. It's such a sporadic error that I've never really looked much into it. I really need to add some debugging code to see what Hubitat is actually returning on those cases...

Good to know it’s not just me. Maybe I’ll see if I add some debug code and reproduce it. At least then a bug can be raised with Hubitat.

jason0x43 added a commit that referenced this issue Apr 10, 2023
@hbh7
Copy link

hbh7 commented Dec 30, 2023

For me at least, this was fixed in v0.9.11 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants