-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
camera status, support number control, add enabled option, replace py…
…nput with xdotool key, discovery fix
- Loading branch information
Showing
10 changed files
with
68 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import subprocess | ||
|
||
|
||
class Addon(): | ||
name = 'Camera used' | ||
icon = 'mdi:webcam' | ||
sensor_type = 'binary_sensor' | ||
|
||
def getInfo(self): | ||
stdout = subprocess.run( | ||
"lsmod | grep '^uvcvideo ' | awk '{print $3}'", | ||
shell=True, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE).stdout.decode("UTF-8") | ||
|
||
cam_used = bool(int(stdout.strip())) | ||
if cam_used: | ||
return "ON" | ||
return "OFF" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,16 @@ | ||
# from pynput.keyboard import Key, Controller | ||
from pynput import keyboard | ||
import subprocess | ||
|
||
|
||
class Addon(): | ||
name = 'Send Keys' | ||
icon = None | ||
unit = None | ||
|
||
def startControl(self, topic, data): | ||
if type(data) == str: | ||
self.__presskeys(data) | ||
else: | ||
for keys in data: | ||
self.__presskeys(keys) | ||
|
||
def __presskeys(self, keys): | ||
contr = keyboard.Controller() | ||
hotkeys = keyboard.HotKey.parse(keys) | ||
for hotkey in hotkeys: | ||
contr.press(hotkey) | ||
hotkeys.reverse() | ||
for hotkey in hotkeys: | ||
contr.release(hotkey) | ||
def exposedControls(self): | ||
return { | ||
"Send_Keys": { | ||
"type": "text", | ||
"icon": "mdi:keyboard-outline", | ||
} | ||
} | ||
|
||
|
||
if __name__ == '__main__': | ||
myaddon = Addon() | ||
# myaddon.startControl('send-keys', ['<alt>+<F4>', '<alt>+<ctrl>+<delete>', '<ctrl>+C']) | ||
# myaddon.startControl('send-keys', ['<shift>+C', 'c']) | ||
def startControl(self, topic, data): | ||
subprocess.call(f"xdotool key {data}", shell=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters