{"id":24464,"library":"python-xsense","title":"XSense Python Module","description":"Python module to control XSense air purifiers and sensors. Current version 0.0.16, released irregularly with small feature updates.","status":"active","version":"0.0.16","language":"python","source_language":"en","source_url":"https://github.com/theosnel/python-xsense","tags":["xsense","air purifier","async","home automation"],"install":[{"cmd":"pip install python-xsense","lang":"bash","label":"Install"}],"dependencies":[{"reason":"Async HTTP client for API calls","package":"aiohttp","optional":false}],"imports":[{"note":"Older examples used nested path; top-level import works in 0.0.16.","wrong":"from xsense.xsense import XSenseDevice","symbol":"XSenseDevice","correct":"from xsense import XSenseDevice"},{"note":"Station object for geography / login.","symbol":"XSenseStation","correct":"from xsense import XSenseStation"}],"quickstart":{"code":"import asyncio\nfrom xsense import XSenseDevice, XSenseStation\n\nasync def main():\n    station = XSenseStation()\n    await station.login('username', 'password')\n    await station.update_devices()\n    for device in station.devices:\n        print(device.name, device.type)\n\nasyncio.run(main())","lang":"python","description":"Login, fetch devices, and print their names."},"warnings":[{"fix":"Always use async/await or asyncio.run().","message":"Library uses asyncio; all methods are async and must be awaited. Calling them without await will return coroutine objects, not raise errors.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure station.update_devices() completes before accessing device attributes.","message":"The 'XSenseDevice' class changed in 0.0.14; attributes like 'name' now return property objects instead of strings if not properly awaited. Version 0.0.16 still has this risk.","severity":"breaking","affected_versions":">=0.0.14"},{"fix":"Use station.update_devices() and then station.devices list.","message":"The 'get_devices()' method on station is deprecated in favor of 'update_devices()'.","severity":"deprecated","affected_versions":">=0.0.12"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Ensure XSenseStation is created inside the same event loop as asyncio.run() or use nest_asyncio in Jupyter.","cause":"Creating the XSenseStation outside an async context or mixing event loops (e.g., Jupyter, multi-threading).","error":"RuntimeError: Task <Task pending ...> got Future <Future pending ...> attached to a different loop"},{"fix":"Always await station.update_devices() before accessing station.devices.","cause":"Calling station.devices before station.update_devices() has been awaited.","error":"AttributeError: 'XSenseStation' object has no attribute 'devices'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}