Skip to content

Commit a21769b

Browse files
authored
Support more commands, reorder, raise error with screenshot and camshot (#25)
* Support more commands, reorder, raise error with screenshot and camshot * Fix Daydream commands, comments
1 parent 07de3c0 commit a21769b

1 file changed

Lines changed: 96 additions & 42 deletions

File tree

fullykiosk/__init__.py

Lines changed: 96 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,17 @@ async def sendCommand(self, cmd, **kwargs):
2525
data = await self._rh.get(
2626
cmd=cmd, password=self._password, type="json", **kwargs
2727
)
28-
if RESPONSE_STATUS in data and data[RESPONSE_STATUS] == RESPONSE_ERRORSTATUS:
28+
29+
if (
30+
isinstance(data, dict)
31+
and RESPONSE_STATUS in data
32+
and data[RESPONSE_STATUS] == RESPONSE_ERRORSTATUS
33+
):
2934
raise FullyKioskError(RESPONSE_ERRORSTATUS, data[RESPONSE_STATUSTEXT])
3035
return data
3136

37+
# REST API Documentation: https://www.fully-kiosk.com/en/#rest
38+
3239
async def getDeviceInfo(self):
3340
result = await self.sendCommand("deviceInfo")
3441
self._deviceInfo = result
@@ -47,91 +54,138 @@ def deviceInfo(self):
4754
def settings(self):
4855
return self._settings
4956

50-
async def startScreensaver(self):
51-
await self.sendCommand("startScreensaver")
57+
# Configurations
5258

53-
async def stopScreensaver(self):
54-
await self.sendCommand("stopScreensaver")
59+
async def setConfigurationString(self, setting, stringValue):
60+
await self.sendCommand("setStringSetting", key=setting, value=stringValue)
61+
62+
async def setConfigurationBool(self, setting, boolValue):
63+
await self.sendCommand("setBooleanSetting", key=setting, value=boolValue)
64+
65+
# Screen, screensaver
5566

5667
async def screenOn(self):
5768
await self.sendCommand("screenOn")
5869

5970
async def screenOff(self):
6071
await self.sendCommand("screenOff")
6172

62-
async def setScreenBrightness(self, brightness):
63-
await self.sendCommand(
64-
"setStringSetting", key="screenBrightness", value=brightness
65-
)
73+
async def forceSleep(self):
74+
await self.sendCommand("forceSleep")
6675

67-
async def setAudioVolume(self, volume, stream=None):
68-
await self.sendCommand("setAudioVolume", level=volume, stream=stream)
76+
async def startScreensaver(self):
77+
await self.sendCommand("startScreensaver")
6978

70-
async def restartApp(self):
71-
await self.sendCommand("restartApp")
79+
async def stopScreensaver(self):
80+
await self.sendCommand("stopScreensaver")
7281

73-
async def loadStartUrl(self):
74-
await self.sendCommand("loadStartUrl")
82+
# Daydream: max Android 12
7583

76-
async def loadUrl(self, url):
77-
await self.sendCommand("loadUrl", url=url)
84+
async def startDaydream(self):
85+
await self.sendCommand("startDaydream")
86+
87+
async def stopDaydream(self):
88+
await self.sendCommand("stopDaydream")
89+
90+
async def setScreenBrightness(self, brightness):
91+
await self.setConfigurationString("screenBrightness", brightness)
92+
93+
# Audio
94+
95+
async def setAudioVolume(self, volume, stream=None):
96+
await self.sendCommand("setAudioVolume", level=volume, stream=stream)
7897

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

82101
async def stopSound(self):
83102
await self.sendCommand("stopSound")
84103

85-
async def toForeground(self):
86-
await self.sendCommand("toForeground")
87-
88-
async def toBackground(self):
89-
await self.sendCommand("toBackground")
104+
async def textToSpeech(self, text, locale=None, engine=None, queue=None):
105+
if queue is not None:
106+
queue = "1" if queue else "0"
107+
await self.sendCommand("textToSpeech", text=text, locale=locale, engine=engine, queue=queue)
90108

91-
async def startApplication(self, application):
92-
await self.sendCommand("startApplication", package=application)
109+
async def stopTextToSpeech(self):
110+
await self.sendCommand("stopTextToSpeech")
93111

94-
async def setConfigurationString(self, setting, stringValue):
95-
await self.sendCommand("setStringSetting", key=setting, value=stringValue)
112+
# Lock, maintenance
96113

97-
async def setConfigurationBool(self, setting, boolValue):
98-
await self.sendCommand("setBooleanSetting", key=setting, value=boolValue)
114+
async def lockKiosk(self):
115+
await self.sendCommand("lockKiosk")
116+
117+
async def unlockKiosk(self):
118+
await self.sendCommand("unlockKiosk")
99119

100120
async def enableLockedMode(self):
101121
await self.sendCommand("enableLockedMode")
102122

103123
async def disableLockedMode(self):
104124
await self.sendCommand("disableLockedMode")
105125

106-
async def lockKiosk(self):
107-
await self.sendCommand("lockKiosk")
126+
# Root only:
108127

109-
async def unlockKiosk(self):
110-
await self.sendCommand("unlockKiosk")
128+
async def rebootDevice(self):
129+
await self.sendCommand("rebootDevice")
111130

112-
async def enableMotionDetection(self):
113-
await self.setConfigurationBool("motionDetection", True)
131+
# App management
114132

115-
async def disableMotionDetection(self):
116-
await self.setConfigurationBool("motionDetection", False)
133+
async def restartApp(self):
134+
await self.sendCommand("restartApp")
117135

118-
async def rebootDevice(self):
119-
await self.sendCommand("rebootDevice")
136+
async def exitApp(self):
137+
await self.sendCommand("exitApp")
138+
139+
async def killMyProcess(self):
140+
await self.sendCommand("killMyProcess")
141+
142+
async def toForeground(self):
143+
await self.sendCommand("toForeground")
144+
145+
async def toBackground(self):
146+
await self.sendCommand("toBackground")
147+
148+
async def startApplication(self, application):
149+
await self.sendCommand("startApplication", package=application)
150+
151+
# Web browsing
152+
153+
async def loadStartUrl(self):
154+
await self.sendCommand("loadStartUrl")
155+
156+
async def loadUrl(self, url):
157+
await self.sendCommand("loadUrl", url=url)
120158

121159
async def clearCache(self):
122160
await self.sendCommand("clearCache")
123-
161+
124162
async def clearWebstorage(self):
125163
await self.sendCommand("clearWebstorage")
126-
164+
127165
async def clearCookies(self):
128166
await self.sendCommand("clearCookies")
129167

168+
async def resetWebview(self):
169+
await self.sendCommand("resetWebview")
170+
171+
# Motion detection
172+
173+
async def triggerMotion(self):
174+
await self.sendCommand("triggerMotion")
175+
176+
async def enableMotionDetection(self):
177+
await self.setConfigurationBool("motionDetection", True)
178+
179+
async def disableMotionDetection(self):
180+
await self.setConfigurationBool("motionDetection", False)
181+
182+
# Camera, screenshot:
183+
130184
async def getCamshot(self):
131-
return await self._rh.get(cmd="getCamshot", password=self._password)
185+
return await self.sendCommand("getCamshot")
132186

133187
async def getScreenshot(self):
134-
return await self._rh.get(cmd="getScreenshot", password=self._password)
188+
return await self.sendCommand("getScreenshot")
135189

136190

137191
class _RequestsHandler:

0 commit comments

Comments
 (0)