Skip to content

Commit

Permalink
Support more commands, reorder, raise error with screenshot and camsh…
Browse files Browse the repository at this point in the history
…ot (#25)

* Support more commands, reorder, raise error with screenshot and camshot

* Fix Daydream commands, comments
  • Loading branch information
infeeeee authored Aug 30, 2024
1 parent 07de3c0 commit a21769b
Showing 1 changed file with 96 additions and 42 deletions.
138 changes: 96 additions & 42 deletions fullykiosk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,17 @@ async def sendCommand(self, cmd, **kwargs):
data = await self._rh.get(
cmd=cmd, password=self._password, type="json", **kwargs
)
if RESPONSE_STATUS in data and data[RESPONSE_STATUS] == RESPONSE_ERRORSTATUS:

if (
isinstance(data, dict)
and RESPONSE_STATUS in data
and data[RESPONSE_STATUS] == RESPONSE_ERRORSTATUS
):
raise FullyKioskError(RESPONSE_ERRORSTATUS, data[RESPONSE_STATUSTEXT])
return data

# REST API Documentation: https://www.fully-kiosk.com/en/#rest

async def getDeviceInfo(self):
result = await self.sendCommand("deviceInfo")
self._deviceInfo = result
Expand All @@ -47,91 +54,138 @@ def deviceInfo(self):
def settings(self):
return self._settings

async def startScreensaver(self):
await self.sendCommand("startScreensaver")
# Configurations

async def stopScreensaver(self):
await self.sendCommand("stopScreensaver")
async def setConfigurationString(self, setting, stringValue):
await self.sendCommand("setStringSetting", key=setting, value=stringValue)

async def setConfigurationBool(self, setting, boolValue):
await self.sendCommand("setBooleanSetting", key=setting, value=boolValue)

# Screen, screensaver

async def screenOn(self):
await self.sendCommand("screenOn")

async def screenOff(self):
await self.sendCommand("screenOff")

async def setScreenBrightness(self, brightness):
await self.sendCommand(
"setStringSetting", key="screenBrightness", value=brightness
)
async def forceSleep(self):
await self.sendCommand("forceSleep")

async def setAudioVolume(self, volume, stream=None):
await self.sendCommand("setAudioVolume", level=volume, stream=stream)
async def startScreensaver(self):
await self.sendCommand("startScreensaver")

async def restartApp(self):
await self.sendCommand("restartApp")
async def stopScreensaver(self):
await self.sendCommand("stopScreensaver")

async def loadStartUrl(self):
await self.sendCommand("loadStartUrl")
# Daydream: max Android 12

async def loadUrl(self, url):
await self.sendCommand("loadUrl", url=url)
async def startDaydream(self):
await self.sendCommand("startDaydream")

async def stopDaydream(self):
await self.sendCommand("stopDaydream")

async def setScreenBrightness(self, brightness):
await self.setConfigurationString("screenBrightness", brightness)

# Audio

async def setAudioVolume(self, volume, stream=None):
await self.sendCommand("setAudioVolume", level=volume, stream=stream)

async def playSound(self, url, stream=None):
await self.sendCommand("playSound", url=url, stream=stream)

async def stopSound(self):
await self.sendCommand("stopSound")

async def toForeground(self):
await self.sendCommand("toForeground")

async def toBackground(self):
await self.sendCommand("toBackground")
async def textToSpeech(self, text, locale=None, engine=None, queue=None):
if queue is not None:
queue = "1" if queue else "0"
await self.sendCommand("textToSpeech", text=text, locale=locale, engine=engine, queue=queue)

async def startApplication(self, application):
await self.sendCommand("startApplication", package=application)
async def stopTextToSpeech(self):
await self.sendCommand("stopTextToSpeech")

async def setConfigurationString(self, setting, stringValue):
await self.sendCommand("setStringSetting", key=setting, value=stringValue)
# Lock, maintenance

async def setConfigurationBool(self, setting, boolValue):
await self.sendCommand("setBooleanSetting", key=setting, value=boolValue)
async def lockKiosk(self):
await self.sendCommand("lockKiosk")

async def unlockKiosk(self):
await self.sendCommand("unlockKiosk")

async def enableLockedMode(self):
await self.sendCommand("enableLockedMode")

async def disableLockedMode(self):
await self.sendCommand("disableLockedMode")

async def lockKiosk(self):
await self.sendCommand("lockKiosk")
# Root only:

async def unlockKiosk(self):
await self.sendCommand("unlockKiosk")
async def rebootDevice(self):
await self.sendCommand("rebootDevice")

async def enableMotionDetection(self):
await self.setConfigurationBool("motionDetection", True)
# App management

async def disableMotionDetection(self):
await self.setConfigurationBool("motionDetection", False)
async def restartApp(self):
await self.sendCommand("restartApp")

async def rebootDevice(self):
await self.sendCommand("rebootDevice")
async def exitApp(self):
await self.sendCommand("exitApp")

async def killMyProcess(self):
await self.sendCommand("killMyProcess")

async def toForeground(self):
await self.sendCommand("toForeground")

async def toBackground(self):
await self.sendCommand("toBackground")

async def startApplication(self, application):
await self.sendCommand("startApplication", package=application)

# Web browsing

async def loadStartUrl(self):
await self.sendCommand("loadStartUrl")

async def loadUrl(self, url):
await self.sendCommand("loadUrl", url=url)

async def clearCache(self):
await self.sendCommand("clearCache")

async def clearWebstorage(self):
await self.sendCommand("clearWebstorage")

async def clearCookies(self):
await self.sendCommand("clearCookies")

async def resetWebview(self):
await self.sendCommand("resetWebview")

# Motion detection

async def triggerMotion(self):
await self.sendCommand("triggerMotion")

async def enableMotionDetection(self):
await self.setConfigurationBool("motionDetection", True)

async def disableMotionDetection(self):
await self.setConfigurationBool("motionDetection", False)

# Camera, screenshot:

async def getCamshot(self):
return await self._rh.get(cmd="getCamshot", password=self._password)
return await self.sendCommand("getCamshot")

async def getScreenshot(self):
return await self._rh.get(cmd="getScreenshot", password=self._password)
return await self.sendCommand("getScreenshot")


class _RequestsHandler:
Expand Down

0 comments on commit a21769b

Please sign in to comment.