Skip to content

Exception has occurred: KeyError #22

@keanuplayz

Description

@keanuplayz

First off, let's start off with displaying my code:

import sonoff

username = "usrname"
password = "pass"
api_region = "region"

s = sonoff.Sonoff(username, password, api_region)

devices = s.get_devices()
print(devices)

if devices:
    # We found a device, lets turn something on
    device_id = devices[0]['device id']
    s.switch('on', device_id, None)

This code was copied straight from the example, and modified to drop config, since it was making trouble on my end.

After running this, I get quite the abnormal error from the code.

Exception has occurred: KeyError
'at'

After delving into the source of this library, I found the exact line from where the exception originates.
Line 123: self._bearer_token = resp['at']
at_error


I have absolutely no idea how to fix this, as I am not willing to make modifications to a library I don't understand, unless guided by someone who does.

If anyone can lend a hand with this, you'd have my sincere gratitude.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions