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

Problem parsing Hue Motion Sensor state #15

Open
rzarajczyk opened this issue Aug 29, 2022 · 2 comments
Open

Problem parsing Hue Motion Sensor state #15

rzarajczyk opened this issue Aug 29, 2022 · 2 comments

Comments

@rzarajczyk
Copy link

The Hue Bridge reports the following status for Motion Sensor:

{'state': {'presence': None, 'lastupdated': 'none'}, 'swupdate': {'state': 'noupdates', 'lastinstall': '2020-02-23T10:39:57'}, 'config': {'on': False, 'battery': 50, 'reachable': True, 'alert': 'none', 'sensitivity': 2, 'sensitivitymax': 2, 'ledindication': False, 'usertest': False, 'pending': []}, 'name': 'Czujnik ruchu - korytarz', 'type': 'ZLLPresence', 'modelid': 'SML001', 'manufacturername': 'Signify Netherlands B.V.', 'productname': 'Hue motion sensor', 'swversion': '6.1.1.27575', 'uniqueid': '00:17:88:01:06:f7:d2:86-02-0406', 'capabilities': {'certified': True, 'primary': True}}

I have no idea why this sensor reports state.lastupdated, which equals to 'none' (string of four letters instead of typical None). The sensor is operational and detects presence many times during the day.

But generally these kind of status produces the following validation error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/rzarajczyk/Library/Caches/pypoetry/virtualenvs/hue2mqtt-FuKMssS5-py3.8/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/rzarajczyk/Library/Caches/pypoetry/virtualenvs/hue2mqtt-FuKMssS5-py3.8/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/rzarajczyk/Library/Caches/pypoetry/virtualenvs/hue2mqtt-FuKMssS5-py3.8/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/rzarajczyk/Library/Caches/pypoetry/virtualenvs/hue2mqtt-FuKMssS5-py3.8/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/rzarajczyk/Private/hue2mqtt-python/hue2mqtt/app.py", line 24, in app
    loop.run_until_complete(hue2mqtt.run())
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/Users/rzarajczyk/Private/hue2mqtt-python/hue2mqtt/hue2mqtt.py", line 109, in run
    await self.main(websession)
  File "/Users/rzarajczyk/Private/hue2mqtt-python/hue2mqtt/hue2mqtt.py", line 219, in main
    sensor = SensorInfo(id=id, **sensor_raw.raw)
  File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 16 validation errors for SensorInfo
state -> lastupdated
  invalid datetime format (type=value_error.datetime)
state -> lastupdated
  invalid datetime format (type=value_error.datetime)
state -> rotaryevent
  field required (type=value_error.missing)
state -> expectedrotation
  field required (type=value_error.missing)
state -> expectedeventduration
  field required (type=value_error.missing)
state -> lastupdated
  invalid datetime format (type=value_error.datetime)
state -> lastupdated
  invalid datetime format (type=value_error.datetime)
state -> dark
  field required (type=value_error.missing)
state -> daylight
  field required (type=value_error.missing)
state -> lightlevel
  field required (type=value_error.missing)
state -> lastupdated
  invalid datetime format (type=value_error.datetime)
state -> temperature
  field required (type=value_error.missing)
state -> lastupdated
  invalid datetime format (type=value_error.datetime)
state -> humidity
  field required (type=value_error.missing)
state -> lastupdated
  invalid datetime format (type=value_error.datetime)
state -> open
  field required (type=value_error.missing)
@rzarajczyk
Copy link
Author

rzarajczyk commented Aug 29, 2022

Note: I have also the second Motion Sensor, and it's state is more "normal":

{'state': {'presence': False, 'lastupdated': '2022-08-29T19:01:51'}, 'swupdate': {'state': 'noupdates', 'lastinstall': '2020-04-07T16:47:11'}, 'config': {'on': True, 'battery': 71, 'reachable': True, 'alert': 'none', 'sensitivity': 2, 'sensitivitymax': 2, 'ledindication': False, 'usertest': False, 'pending': []}, 'name': 'Czujnik ruchu - wejście', 'type': 'ZLLPresence', 'modelid': 'SML001', 'manufacturername': 'Signify Netherlands B.V.', 'productname': 'Hue motion sensor', 'swversion': '6.1.1.27575', 'uniqueid': '00:17:88:01:06:f5:53:0f-02-0406', 'capabilities': {'certified': True, 'primary': True}}

@timboettiger
Copy link
Contributor

I had the same or at least very similar errors and was able to solve them with an adapted scheme. Try the newest release that includes (pull request #19), maybe it fixes the errors for you...

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

2 participants