A library to authenticate and interact with STIHL iMow mowers using their WebAPI
Project description
STIHL iMow unofficial Python API wrapper
This unofficial Python API was created to provide an interface to interact with the STIHL iMow mower WebAPI. This wrapper is able to receive the current status
status from the mowers and to send actions.
I wrote this library to implement an integration for the Home Assistant Smart Home System
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
API Documentation is available on: https://chrishapunkt.github.io/stihl-imow-webapi/imow
Prerequisites
Python 3.7+ is required to run this application, other than that there are no prerequisites for the project, as the dependencies are included in the repository.
Installing
To install the library is as simple as cloning the repository and running
pip install -e .
It is recommended to create an virtual environment prior to installing this library. Alternatively, you can also install this library via Pip:
pip install imow-webapi
And have fun!
Usage
Import the module and instantiate the IMowApi()
constructor with credentials.
from imow.api import IMowApi
from imow.common.actions import IMowActions
import asyncio
async def main():
api = IMowApi()
# save token for later use if you want to recreate IMowApi(token=my_token) because the created token is valid for
# 30 days
token, expire_time = await api.get_token("email@account.stihl", "supersecret", return_expire_time=True)
my_token, expire_time = await api.get_token()
print(await api.get_token())
mowers = await api.receive_mowers()
mower = mowers[0]
print(f'{mower.name} @ {mower.coordinateLatitude},{mower.coordinateLongitude}')
print(await mower.get_current_task())
await mower.intent(IMowActions.TO_DOCKING)
print(await mower.update_from_upstream())
print(await mower.get_startpoints())
if __name__ == '__main__':
asyncio.run(main())
Testing
For unit testing run pytest -s tests/test_unit*
. For upstream integration testing, provide a /secrets.py
with the following contents:
EMAIL = "email@account.stihl"
PASSWORD = "supersecret"
MOWER_NAME = "MyRobot"
and run pytest -s tests/test_integration*
or pytest -s
.
Built With
- aiohttp
- BeautifulSoup
- asyncio
Versioning
Navigate to tags on this repository to see all available versions.
Authors
Mail Address | GitHub Profile |
---|---|
chris@homeset.de | ChrisHaPunkt |
License
This project is licensed under the MIT License - see the LICENSE.md license file for more details.
Acknowledges
Thanks to
for repo structure inspiration
Changelog
Version 0.4.4 (2021-05-28)
Features
- Add
validate_token()
method toIMowAPI
Class. Test if a token is valid and can call the webapi.
Version 0.4.3 (2021-05-27)
Features
- Allow
IMowAPI
Class to use predefinedaiohttp
session when instantiating
Version 0.4.1 (2021-05-24)
Changes
- Even more asynchronously with switch from
requests
toaiohttp
Version 0.4.0 (2021-05-17)
Breaking Changes
- Reworked everything to use asyncio where possible. See Readme.md for new usage example.
- Renamed MowerState method
update
toupdate_from_upstream
- Renamed MowerState method
get_status
toget_current_status
Version 0.3.0 (2021-05-17)
Breaking Changes
- Renamed Class/Enum
MowerState
toMowerTask
because it describes the current task not the state - Renamed Class
Mower
toMowerState
because it's just a snapshot of the last upstream state
Features
- Add methods to work on
MowerState
objects, like action intents or statistic receive - Add PDoc documents, available on https://chrishapunkt.github.io/stihl-imow-webapi/imow
Bugfixes
- Return a valid error message and raise if provided login credentials are wrong
Version 0.2.2 (2021-05-00)
- Initial release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for imow_webapi-0.4.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 213f208cc856921d79f75e5a4ad03ad5fd14dc308d327e60491d5f7eccf002ad |
|
MD5 | 88902ed56604048a3fd2d53cb3007b7d |
|
BLAKE2b-256 | e5fdd9b8b620cf88a1aeaa8907fcde487bad4bd71ad8fabe6058027b5d7b256c |