diyhue / diyHue

Main diyHue software repo
https://diyhue.org/
Other
1.52k stars 274 forks source link

Application stops working because brightness for Ikea Tradfri bulbs can be None or null #985

Closed ziegi1982 closed 5 months ago

ziegi1982 commented 5 months ago

Issue does not already exist?

I have searched and found no existing issue

Select Environment

Docker

Home Assistant related?

No

Description

App stops working because of None or null value in brightness for Ikea Tradfri bulbs.

Cast to int with NoneType throws exception.

if #961 change would be enhanced to check for None or null like #951 does, everything would work.

Errorlog:

2024-01-13 07:25:41,481 - werkzeug - INFO - 192.168.0.200 - - [13/Jan/2024 07:25:41] "GET /api/94dff570b16f11ee9e80d83addbbc5f7/lights HTTP/1.1" 500 -
[2024-01-13 07:25:42,426] ERROR in app: Exception on /api/94dff570b16f11ee9e80d83addbbc5f7/lights [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/usr/local/lib/python3.8/site-packages/flask_restful/__init__.py", line 467, in wrapper
    resp = resource(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/flask/views.py", line 84, in view
    return current_app.ensure_sync(self.dispatch_request)(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/flask_restful/__init__.py", line 582, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/opt/hue-emulator/flaskUI/restful.py", line 131, in get
    response[object] = bridgeConfig[resource][object].getV1Api(
  File "/opt/hue-emulator/HueObjects/__init__.py", line 362, in getV1Api
    result["state"]["bri"] = int(self.state["bri"])
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

Steps to reproduce

Install dyiHue Use ZHA and SkyConnect to set up Ikea Tradfri Bulbs. Start dyiHue and wait some seconds.

Please enter your operating system details here

Linux 6.1.63-haos-raspi aarch64

Home Assistant Core 2024.1.2

What DiyHue version(branch) are you using?

master (latest)