Package: aioflo
💧 aioflo: a Python3, asyncio-friendly library for Flo Smart Water Detectorsaioflois a Python 3,asyncio-friendly library for interacting withFlo by Moen Smart Water Detectors.Python Versionsaioflois currently supported on:Python 3.6Python 3.7Python 3.8Python 3.9Python 3.10InstallationpipinstallaiofloUsageimportasynciofromaiohttpimportClientSessionfromaiofloimportasync_get_apiasyncdefmain()->None:"""Run!"""api=awaitasync_get_api("<EMAIL>","<PASSWORD>")# Get user account information:user_info=awaitapi.user.get_info()a_location_id=user_info["locations"][0]["id"]# Get location (i.e., device) information:location_info=awaitapi.location.get_info(a_location_id)# Get device informationfirst_device_id=location_info["devices"][0]["id"]device_info=awaitapi.device.get_info(first_device_id)# Run a health testhealth_test_response=awaitapi.device.run_health_test(first_device_id)# Close the shutoff valveclose_valve_response=awaitapi.device.close_valve(first_device_id)# Open the shutoff valveopen_valve_response=awaitapi.device.open_valve(first_device_id)# Get consumption info between a start and end datetime:consumption_info=awaitapi.water.get_consumption_info(a_location_id,datetime(2020,1,16,0,0),datetime(2020,1,16,23,59,59,999000),)# Get various other metrics related to water usage:metrics=awaitapi.water.get_metrics("<DEVICE_MAC_ADDRESS>",datetime(2020,1,16,0,0),datetime(2020,1,16,23,59,59,999000),)# Set the device in "Away" mode:awaitset_mode_away(a_location_id)# Set the device in "Home" mode:awaitset_mode_home(a_location_id)# Set the device in "Sleep" mode for 120 minutes, then return to "Away" mode:awaitset_mode_sleep(a_location_id,120,"away")asyncio.run(main())By default, the library creates a new connection to Flo with each coroutine. If you are
calling a large number of coroutines (or merely want to squeeze out every second of
runtime savings possible), anaiohttpClientSessioncan be used for connection
pooling:importasynciofromaiohttpimportClientSessionfromaiofloimportasync_get_apiasyncdefmain()->None:"""Create the aiohttp session and run the example."""asyncwithClientSession()aswebsession:api=awaitasync_get_api("<EMAIL>","<PASSWORD>",session=session)# Tell Flo to get updated data from the deviceping_response=awaitapi.presence.ping()# Get user account information:user_info=awaitapi.user.get_info()a_location_id=user_info["locations"][0]["id"]# Get location (i.e., device) information:location_info=awaitapi.location.get_info(a_location_id)# Get device informationfirst_device_id=location_info["devices"][0]["id"]device_info=awaitapi.device.get_info(first_device_id)# Run a health testhealth_test_response=awaitapi.device.run_health_test(first_device_id)# Close the shutoff valveclose_valve_response=awaitapi.device.close_valve(first_device_id)# Open the shutoff valveopen_valve_response=awaitapi.device.open_valve(first_device_id)# Get consumption info between a start and end datetime:consumption_info=awaitapi.water.get_consumption_info(a_location_id,datetime(2020,1,16,0,0),datetime(2020,1,16,23,59,59,999000),)# Get various other metrics related to water usage:metrics=awaitapi.water.get_metrics("<DEVICE_MAC_ADDRESS>",datetime(2020,1,16,0,0),datetime(2020,1,16,23,59,59,999000),)# Set the device in "Away" mode:awaitset_mode_away(a_location_id)# Set the device in "Home" mode:awaitset_mode_home(a_location_id)# Set the device in "Sleep" mode for 120 minutes, then return to "Away" mode:awaitset_mode_sleep(a_location_id,120,"away")asyncio.run(main())ContributingCheck for open features/bugsorinitiate a discussion on one.Fork the repository.(optional, but highly recommended) Create a virtual environment:python3 -m venv .venv(optional, but highly recommended) Enter the virtual environment:source ./.venv/bin/activateInstall the dev environment:script/setupCode your new feature or bug fix.Write tests that cover your new functionality.Run tests and ensure 100% code coverage:script/testUpdateREADME.mdwith any new documentation.Add yourself toAUTHORS.md.Submit a pull request!