I’m looking to a way to control an iMow robot directly from OH, but so far, no binding seems to exist.
I found out that an API was created for Home-Assistant, but unfortunately, I’m not skilled enough to try to convert it somehow for OH (not even to check if it would be possible).
Anyone able to look into it or guide me on how to start ?
I’m pretty sure i can also control it that way, but didn’t implement it by now. The actual data is collected by a python script:
#!/usr/bin/env python3
from imow.api import IMowApi
from imow.common.actions import IMowActions
import asyncio
import aiohttp
async def main():
async with aiohttp.ClientSession() as session:
api = IMowApi(aiohttp_session=session, lang="de")
# 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("my@cool.email", "MyCoolPassword", return_expire_time=True)
await api.get_token()
mowers = await api.receive_mowers()
mower = mowers[0]
print(f"rasi_name={mower.name}")
print(f"rasi_position={mower.coordinateLatitude},{mower.coordinateLongitude}")
print(f"rasi_status={mower.stateMessage['short']}")
await mower.update_setting("gpsProtectionEnabled", True)
#print(mower.stateMessage)
print(f"rasi_status_info= {mower.machineState}")
match (mower.machineState):
case "DOCKED":
print(f"rasi_color=#0000ff")
case _ :
print(f"rasi_color=#ffffff")
if __name__ == "__main__":
asyncio.run(main())
Fetching the stuff is done by a rule:
rule "Rasi"
when
Time cron "0/60 * * * * ? *"
then
val filedata = executeCommandLine(Duration.ofSeconds(50), "/usr/bin/python3", "/home/ubuntu/rasi.sh")
logger.info("DATA " + filedata);
val lines = filedata.split("\n")
logger.info("LINES " + lines);
lines.forEach [ line |
logger.info("LINE " + line);
val field1 = line.toString.split('=').get(0)
val field2 = line.toString.split('=').get(1)
logger.info("FIELDS " + field1);
logger.info("FIELDS " + field2);
postUpdate(field1, field2)
]
end