diff --git a/Raspi/RPi.py b/Raspi/RPi.py index 1de2754..435d954 100644 --- a/Raspi/RPi.py +++ b/Raspi/RPi.py @@ -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') diff --git a/Raspi/__init__.py b/Raspi/__init__.py index 9f35808..dc66b56 100644 --- a/Raspi/__init__.py +++ b/Raspi/__init__.py @@ -1 +1,2 @@ from .gitpull import * +from .tv import * diff --git a/Raspi/tv.py b/Raspi/tv.py new file mode 100644 index 0000000..a3f1653 --- /dev/null +++ b/Raspi/tv.py @@ -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)