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

moods 'not found' (error parsing json) #220

Closed
brean opened this issue Jan 6, 2019 · 4 comments
Closed

moods 'not found' (error parsing json) #220

brean opened this issue Jan 6, 2019 · 4 comments

Comments

@brean
Copy link
Contributor

brean commented Jan 6, 2019

Where are you using pytradfri (eg stand-alone, Home Assistant etc)

stand-alone

Version of pytradfri

master (aiocoap)

Expected behaviour

I should get a list of moods when I call 'gateway.get_moods'

Actual behaviour

aiocoap receives a "Not Found"-string and fails to parse that as json.

Wild speculation

Maybe the mood-id in const.ROOT_MOODS needs to get changed?

@ggravlingen
Copy link
Member

Can you please post all the raw data from your Gateway? It's available when you run the pytradfri CLI.

@brean
Copy link
Contributor Author

brean commented Jan 13, 2019

What do you mean by "all the raw data from your Gateway"? Do you mean dump_all ?
This outputs some mood-information:

DEBUG:pytradfri.api.libcoap_api:Executing 192.168.1.9 get ['15005', '131080', '196629']
DEBUG:pytradfri.api.libcoap_api:Received: {"9068":1,"9001":"EVERYDAY","9002":1534959275,"9003":196629,"9057":0,"15013":[{"5850":1,"5709":30015,"5851":203,"5707":5427,"5708":42596,"5710":26870,"5711":0,"5706":"f1e0b5","9003":65555}]}
None


DEBUG:pytradfri.api.libcoap_api:Executing 192.168.1.9 get ['15005', '131080', '196630']
DEBUG:pytradfri.api.libcoap_api:Received: {"9068":1,"9001":"RELAX","9002":1534959275,"9003":196630,"9057":1,"15013":[{"5850":1,"5709":32886,"5851":25,"5707":5309,"5708":52400,"5710":27217,"5711":0,"5706":"efd275","9003":65555}]}
None


DEBUG:pytradfri.api.libcoap_api:Executing 192.168.1.9 get ['15005', '131080', '196631']
DEBUG:pytradfri.api.libcoap_api:Received: {"9068":1,"9001":"FOCUS","9002":1534959275,"9003":196631,"9057":2,"15013":[{"5850":1,"5709":25022,"5851":254,"5707":5800,"5708":24394,"5710":24884,"5711":0,"5706":"f5faf6","9003":65555}]}
None


DEBUG:pytradfri.api.libcoap_api:Executing 192.168.1.9 get ['15004', '131080']
DEBUG:pytradfri.api.libcoap_api:Received: {"9001":"Arbeitszimmer","5850":1,"9002":1534959274,"9003":131080,"5851":0,"9039":196630,"9108":0,"9018":{"15002":{"9003":[65554,65555]}}}
None


DEBUG:pytradfri.api.libcoap_api:Executing 192.168.1.9 get ['15005', '131080']
DEBUG:pytradfri.api.libcoap_api:Received: [196629,196630,196631]
None


DEBUG:pytradfri.api.libcoap_api:Executing 192.168.1.9 get ['15005', '131081', '196632']
DEBUG:pytradfri.api.libcoap_api:Received: {"9068":1,"9001":"EVERYDAY","9002":1535045040,"9003":196632,"9057":0,"15013":[{"5850":1,"5709":30015,"5851":203,"5707":5427,"5708":42596,"5710":26870,"5711":0,"5706":"f1e0b5","9003":65557}]}
None


DEBUG:pytradfri.api.libcoap_api:Executing 192.168.1.9 get ['15005', '131081', '196633']
DEBUG:pytradfri.api.libcoap_api:Received: {"9068":1,"9001":"RELAX","9002":1535045040,"9003":196633,"9057":1,"15013":[{"5850":1,"5709":32886,"5851":25,"5707":5309,"5708":52400,"5710":27217,"5711":0,"5706":"efd275","9003":65557}]}
None


DEBUG:pytradfri.api.libcoap_api:Executing 192.168.1.9 get ['15005', '131081', '196634']
DEBUG:pytradfri.api.libcoap_api:Received: {"9068":1,"9001":"FOCUS","9002":1535045040,"9003":196634,"9057":2,"15013":[{"5850":1,"5709":25022,"5851":254,"5707":5800,"5708":24394,"5710":24884,"5711":0,"5706":"f5faf6","9003":65557}]}
None


DEBUG:pytradfri.api.libcoap_api:Executing 192.168.1.9 get ['15005', '131082', '196635']
DEBUG:pytradfri.api.libcoap_api:Received: {"9068":1,"9001":"EVERYDAY","9002":1544122177,"9003":196635,"9057":0,"15013":[{"5850":1,"5851":203,"9003":65559},{"5850":1,"5851":203,"9003":65560}]}
None


DEBUG:pytradfri.api.libcoap_api:Executing 192.168.1.9 get ['15005', '131082', '196636']
DEBUG:pytradfri.api.libcoap_api:Received: {"9068":1,"9001":"RELAX","9002":1544122177,"9003":196636,"9057":1,"15013":[{"5850":1,"5851":25,"9003":65559},{"5850":1,"5851":25,"9003":65560}]}
None


DEBUG:pytradfri.api.libcoap_api:Executing 192.168.1.9 get ['15005', '131082', '196637']
DEBUG:pytradfri.api.libcoap_api:Received: {"9068":1,"9001":"FOCUS","9002":1544122177,"9003":196637,"9057":2,"15013":[{"5850":1,"5851":254,"9003":65559},{"5850":1,"5851":254,"9003":65560}]}
None

I have also some moods from the cli but I can not access them:

>>> moods
[<pytradfri.command.Command object at 0x7fb7909d2908>, <pytradfri.command.Command object at 0x7fb7909d2a20>, <pytradfri.command.Command object at 0x7fb7909d29e8>, <pytradfri.command.Command object at 0x7fb7909d29b0>, <pytradfri.command.Command object at 0x7fb7909d28d0>]
>>> api(moods[0]).raw
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/.local/share/virtualenvs/home_service-cPNi1D6n/lib/python3.5/site-packages/pytradfri/api/libcoap_api.py", line 96, in request
    return self._execute(api_commands, timeout=timeout)
  File "/home/user/.local/share/virtualenvs/home_service-cPNi1D6n/lib/python3.5/site-packages/pytradfri/api/libcoap_api.py", line 72, in _execute
    kwargs['input'] = json.dumps(data)
  File "/usr/lib64/python3.5/json/__init__.py", line 230, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib64/python3.5/json/encoder.py", line 198, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib64/python3.5/json/encoder.py", line 256, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib64/python3.5/json/encoder.py", line 179, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <pytradfri.command.Command object at 0x7fb7906bd668> is not JSON serializable

@Rob4t
Copy link
Contributor

Rob4t commented Dec 26, 2019

Had a similar problem with moods. My use case was to change color temperature through the day (from cold to warm) without changing the bulb state (on or off)

As moods seem to be always linked to a group I patched the lib to represent that. Since i did not bother to write tests and about proper error handling i will not submit a pull request for now.

Find my patch here: Rob4t@7013a72

Drop me a line if this is even remotely useful for you.

If you are interested in my cron script you can find it here;
https://github.com/Rob4t/pytradfri-scripts

This was referenced Dec 26, 2019
@ggravlingen
Copy link
Member

Stale issue, closing.

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

No branches or pull requests

3 participants