diyhue / diyHue

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

Expected an int but was 191.000100000000003 at path $.lights.31.state.bri #961

Closed u20p17 closed 5 months ago

u20p17 commented 7 months ago

Issue does not already exist?

I have searched and found no existing issue

Select Environment

Docker

Home Assistant related?

No

Description

I have added some light via MQTT and HomeAssistant. I can add the DIYHue Bridge in the Hue App, but with the Hue Essential App I get the following error:

"Expected an int but was 191.000100000000003 at path $.lights.31.state.bri"

image

Errorlog:

"Expected an int but was 191.000100000000003 at path $.lights.31.state.bri"

Steps to reproduce

Install DIYHue via docker and add lights via MQTT and HomeAssistant. After that try to add the Bridge to Hue Essential App.

Please enter your operating system details here

Unraid --> Docker

What DiyHue version(branch) are you using?

master (latest)

u20p17 commented 7 months ago

light number 31 is a ambilight strip of a philips tv:

'31': id_v2: 77b5d3c3-39a5-4cd2-8bee-6c1e54507563 name: 55OLED936/12 Ambilight modelid: LCT015 uniqueid: 00:17:88:01:00:21:4a:f5-0b state: 'on': true bri: 191.00010000000003 hue: 0 sat: 0 xy:

igorcv88 commented 7 months ago

I have this same problem, I can only get Essentials to sync if I delete the Ambilight from my Lights, it always breaks the install

mariusmotea commented 7 months ago

i made a commit, hope now it is fixed.

u20p17 commented 7 months ago

TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType' [2023-12-04 16:29:02,362] ERROR in app: Exception on /api/hueessae92c211ee811348210b26395a [GET] Traceback (most recent call last): File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 1516, in full_dispatch_request rv = self.dispatch_request() ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-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.11/dist-packages/flask_restful/init.py", line 467, in wrapper resp = resource(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/flask/views.py", line 84, in view return current_app.ensure_sync(self.dispatch_request)(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/flask_restful/init.py", line 582, in dispatch_request resp = meth(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/opt/hue-emulator/flaskUI/restful.py", line 116, in get result[resource][resource_id] = bridgeConfig[resource][resource_id].getV1Api( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/hue-emulator/HueObjects/init.py", line 360, in getV1Api result["state"]["bri"] = int(self.state["bri"])

mariusmotea commented 7 months ago

this is a bug with the integration. bri value must always be integer between 1 and 254. maybe when a light is offline it return None.

u20p17 commented 7 months ago

maybe it is related to this error: https://github.com/diyhue/hassio-addon/issues/22 ? The ambilight is connected to DIYHue via the homeassistant_ws protocol...

mariusmotea commented 7 months ago

i think here must ensure the value is int, else ignore it

https://github.com/diyhue/diyHue/blob/master/BridgeEmulator/lights/protocols/homeassistant_ws.py#L64C1-L65C44

u20p17 commented 5 months ago

i still get the same error with the homeassistant_ws connection:

                             ^^^^^^^^^^^^^^^^^^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
2024-01-18 16:48:17,904 - werkzeug - INFO - 192.168.0.178 - - [18/Jan/2024 16:48:17] "GET /api/6fee18b47d8f11eea09048210b26395a HTTP/1.1" 500 -
2024-01-18 16:48:18,920 - werkzeug - INFO - 192.168.0.178 - - [18/Jan/2024 16:48:18] "GET /api/6fee18b47d8f11eea09048210b26395a/groups/0 HTTP/1.1" 200 -
[2024-01-18 16:48:18,924] ERROR in app: Exception on /api/6fee18b47d8f11eea09048210b26395a [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-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.11/dist-packages/flask_restful/__init__.py", line 467, in wrapper
    resp = resource(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask/views.py", line 84, in view
    return current_app.ensure_sync(self.dispatch_request)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask_restful/__init__.py", line 582, in dispatch_request
    resp = meth(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hue-emulator/flaskUI/restful.py", line 116, in get
    result[resource][resource_id] = bridgeConfig[resource][resource_id].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 real number, not 'NoneType'
2024-01-18 16:48:18,925 - werkzeug - INFO - 192.168.0.178 - - [18/Jan/2024 16:48:18] "GET /api/6fee18b47d8f11eea09048210b26395a HTTP/1.1" 500 -
[2024-01-18 16:48:19,889] ERROR in app: Exception on /api/6fee18b47d8f11eea09048210b26395a [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-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.11/dist-packages/flask_restful/__init__.py", line 467, in wrapper
    resp = resource(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask/views.py", line 84, in view
    return current_app.ensure_sync(self.dispatch_request)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask_restful/__init__.py", line 582, in dispatch_request
    resp = meth(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hue-emulator/flaskUI/restful.py", line 116, in get
    result[resource][resource_id] = bridgeConfig[resource][resource_id].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 real number, not 'NoneType'
2024-01-18 16:48:19,889 - werkzeug - INFO - 192.168.0.178 - - [18/Jan/2024 16:48:19] "GET /api/6fee18b47d8f11eea09048210b26395a HTTP/1.1" 500 -
[2024-01-18 16:48:20,889] ERROR in app: Exception on /api/6fee18b47d8f11eea09048210b26395a [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-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.11/dist-packages/flask_restful/__init__.py", line 467, in wrapper
    resp = resource(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask/views.py", line 84, in view
    return current_app.ensure_sync(self.dispatch_request)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask_restful/__init__.py", line 582, in dispatch_request
    resp = meth(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hue-emulator/flaskUI/restful.py", line 116, in get
    result[resource][resource_id] = bridgeConfig[resource][resource_id].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 real number, not 'NoneType'
2024-01-18 16:48:20,889 - werkzeug - INFO - 192.168.0.178 - - [18/Jan/2024 16:48:20] "GET /api/6fee18b47d8f11eea09048210b26395a HTTP/1.1" 500 -
2024-01-18 16:48:21,892 - werkzeug - INFO - 192.168.0.178 - - [18/Jan/2024 16:48:21] "GET /api/6fee18b47d8f11eea09048210b26395a/groups/0 HTTP/1.1" 200 -
[2024-01-18 16:48:21,892] ERROR in app: Exception on /api/6fee18b47d8f11eea09048210b26395a [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-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.11/dist-packages/flask_restful/__init__.py", line 467, in wrapper
    resp = resource(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask/views.py", line 84, in view
    return current_app.ensure_sync(self.dispatch_request)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask_restful/__init__.py", line 582, in dispatch_request
    resp = meth(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hue-emulator/flaskUI/restful.py", line 116, in get
    result[resource][resource_id] = bridgeConfig[resource][resource_id].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 real number, not 'NoneType'
2024-01-18 16:48:21,893 - werkzeug - INFO - 192.168.0.178 - - [18/Jan/2024 16:48:21] "GET /api/6fee18b47d8f11eea09048210b26395a HTTP/1.1" 500 -
2024-01-18 16:48:22,069 - services.stateFetch - INFO - start lights sync
2024-01-18 16:48:22,069 - services.stateFetch - DEBUG - fetch Licht Abstellraum
2024-01-18 16:48:22,069 - services.stateFetch - DEBUG - {'on': False, 'alert': 'select', 'mode': 'homeautomation', 'reachable': True}
2024-01-18 16:48:22,069 - services.stateFetch - DEBUG - fetch Plug_Weihnachtsbeleuchtung
2024-01-18 16:48:22,069 - services.stateFetch - DEBUG - {'on': True, 'alert': 'select', 'mode': 'homeautomation', 'reachable': True}
2024-01-18 16:48:22,069 - services.stateFetch - DEBUG - fetch Spiegelschranklicht
2024-01-18 16:48:22,069 - services.stateFetch - DEBUG - {'on': False, 'bri': None, 'alert': 'none', 'mode': 'homeautomation', 'reachable': True}
2024-01-18 16:48:22,069 - services.stateFetch - DEBUG - fetch Schlafzimmer Deckenlicht
2024-01-18 16:48:22,069 - services.stateFetch - DEBUG - {'on': True, 'bri': 255, 'alert': 'none', 'mode': 'homeautomation', 'reachable': True, 'xy': [0.495, 0.348], 'colormode': 'xy'}
[2024-01-18 16:48:22,898] ERROR in app: Exception on /api/6fee18b47d8f11eea09048210b26395a [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-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.11/dist-packages/flask_restful/__init__.py", line 467, in wrapper
    resp = resource(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask/views.py", line 84, in view
    return current_app.ensure_sync(self.dispatch_request)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask_restful/__init__.py", line 582, in dispatch_request
    resp = meth(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hue-emulator/flaskUI/restful.py", line 116, in get
    result[resource][resource_id] = bridgeConfig[resource][resource_id].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 real number, not 'NoneType'
2024-01-18 16:48:22,899 - werkzeug - INFO - 192.168.0.178 - - [18/Jan/2024 16:48:22] "GET /api/6fee18b47d8f11eea09048210b26395a HTTP/1.1" 500 -
2024-01-18 16:48:23,900 - werkzeug - INFO - 192.168.0.178 - - [18/Jan/2024 16:48:23] "GET /api/6fee18b47d8f11eea09048210b26395a/groups/0 HTTP/1.1" 200 -
[2024-01-18 16:48:23,900] ERROR in app: Exception on /api/6fee18b47d8f11eea09048210b26395a [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-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.11/dist-packages/flask_restful/__init__.py", line 467, in wrapper
    resp = resource(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask/views.py", line 84, in view
    return current_app.ensure_sync(self.dispatch_request)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/flask_restful/__init__.py", line 582, in dispatch_request
    resp = meth(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hue-emulator/flaskUI/restful.py", line 116, in get
    result[resource][resource_id] = bridgeConfig[resource][resource_id].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 real number, not 'NoneType'
mariusmotea commented 5 months ago

I made a new commit wich will set the bri value to 1 in case it is type None.