1
0
mirror of https://github.com/MarkParker5/STARK.git synced 2025-01-03 10:44:02 +02:00

add tv control

This commit is contained in:
MarkParker5 2020-11-28 07:14:25 +02:00
parent cb79d0765e
commit e04563dce2
3 changed files with 62 additions and 0 deletions

View File

@ -3,3 +3,6 @@ from Command import Command # import parent class
class RPi(Command):
def start(this, string): # main method
pass
def hdmi_cec(this, command):
os.system(f'echo \'{command}\' | cec-client -s -d 1')

View File

@ -1 +1,2 @@
from .gitpull import *
from .tv import *

58
Raspi/tv.py Normal file
View File

@ -0,0 +1,58 @@
from .Raspi import *
################################################################################
def method(params):
Raspi.hdmi_cec('on 0')
Raspi.hdmi_cec('as')
voice = text = ''
return {
'type': 'simple',
'text': text,
'voice': voice,
}
keywords = {}
patterns = ['* включи* (телевизор|экран) *']
tv_on = Raspi('tv on', keywords, patterns)
tv_on.setStart(method)
################################################################################
def method(params):
Raspi.hdmi_cec('standby 0')
voice = text = ''
return {
'type': 'simple',
'text': text,
'voice': voice,
}
keywords = {}
patterns = ['* (выключи|отключи)* (телевизор|экран) *']
tv_off = Raspi('tv off', keywords, patterns)
tv_off.setStart(method)
################################################################################
def method(params):
Raspi.hdmi_cec('tx 4F:82:30:00')
voice = text = ''
return {
'type': 'simple',
'text': text,
'voice': voice,
}
keywords = {}
patterns = ['* (выведи|вывести) * с (ноута|ноутбука|провода|hdmi) *']
tv_hdmi = Raspi('tv hdmi source', keywords, patterns)
tv_hdmi.setStart(method)
################################################################################
def method(params):
Raspi.hdmi_cec('as')
voice = text = ''
return {
'type': 'simple',
'text': text,
'voice': voice,
}
keywords = {}
patterns = ['* (верни|вернуть|включи*|покажи|показать) [нормальн|стандартн|привычн]* (телевизор|экран|картинк|изображение) *']
tv_rpi = Raspi('tv rpi source', keywords, patterns)
tv_rpi.setStart(method)