Conversation
This reverts commit c4a78f8.
|
@fabaff This fixes the linting errors and also resoled the merge conflicts, merging the upstream master. Edit: should this be a minor release, as every device inheriting from the base class now supports the |
fabaff
left a comment
There was a problem hiding this comment.
Thanks for your contribution.
For the bulb example i get a trackback.
$ python examples/example-bulb.py
DEBUG:asyncio:Using selector: EpollSelector
/home/repos/python-mystrom/pymystrom/bulb.py:176: RuntimeWarning: coroutine 'MyStromDevice.__aenter__' was never awaited
super().__aenter__()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Get the details from the bulb...
Traceback (most recent call last):
File "/home/repos/python-mystrom/examples/example-bulb.py", line 65, in <module>
loop.run_until_complete(main())
File "/etc/profiles/per-user/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/repos/python-mystrom/examples/example-bulb.py", line 16, in main
await bulb.get_state()
^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get_state'|
I see. From what I've found I would most likely need to await the So: async def __aenter__(self) -> "MyStromBulb":
super().__aenter__()would become: async def __aenter__(self) -> "MyStromBulb":
await super().__aenter__()
return selfI'll test it as soon as possible. If you have time to test it in the bulb I'll gladly update all the other files based on your feedback. |
|
If I understand the async context manager correctly und looking at your usage it should be good, just returning |
|
I've tested my pir and plug. Pir output: Settings: {'rest': True, 'panel': True, 'hap_disable': False, 'name': '', 'temp_offset': 0}
PIR settings: {'backoff_time': 180, 'led_enable': True}
Sensors: {'motion': False, 'light': 24, 'temperature': 20.62}
Temperatures: {'measured': 31.93, 'compensation': 11.31, 'compensated': 20.62, 'offset': 0}
Temperature measured: 31.93
Brightness: 24
Day?: True
Raw light data: {'visible': 24, 'infrared': 4}
Actions: {'pir': {'generic': 'get://192.168.0.11:8123/api/mystrom', 'night': '', 'twilight': '', 'day': '', 'rise': '', 'fall': ''}}Plug output: Power consumption: 13.1
Energy consumed: 22.3
Relay state: True
Temperature: 21.8
Firmware: 4.0.14
MAC address: C8F09E86BD50
Turn on the switchThey also use the Little side note: Don't run the switch example if your router and wifi is plugged into it. And no I didn't just accidentally shut down my internet 👀 |
|
Did you have time to look into it? |
This moved the
MyStromDeviceclass from the__init__.pyfile into its separate file including the related functions from the__init__.py.The imports of the
_requestfunction have been updated in thebulb.py,pir.pyandswitch.pyfiles to reflect the changes.This also made the device classes inherit from the
MyStromDevicebase class.The
urlhad to be changed to make all devices work from the base classurl.Duplicate functions and variable assignments were removed from the inheriting classes. E.g.:
These changes were tested using the examples with the myStrom Switch and the myStrom PIR. I don't own or have bulbs, so if someone could test those, that would be great.