1
0
mirror of https://github.com/MarkParker5/STARK.git synced 2025-07-12 22:50:22 +02:00

add SmartHome.light (led control) v.1

This commit is contained in:
MarkParker5
2021-03-23 00:55:30 +02:00
parent 9b986b7721
commit c9cfcfaddf
3 changed files with 65 additions and 1 deletions

View File

@ -1,3 +1,4 @@
from .main_light import *
from .window import *
from .alarmclock import *
from .light import *

64
SmartHome/light.py Normal file
View File

@ -0,0 +1,64 @@
from .SmartHome import *
from Command import Response
################################################################################
def method(params):
SmartHome.send({
'target': 'main_light',
'cmd': 'light_on',
})
voice = text = ''
return Response(text = text, voice = voice)
keywords = {}
patterns = ['* (включ|выключ)* свет *']
main_light = SmartHome('main_light', keywords, patterns)
main_light.setStart(method)
################################################################################
# led
def method(params):
SmartHome.send({
'target': 'led',
'cmd': 'led_on',
})
voice = text = ''
return Response(text = text, voice = voice)
keywords = {}
patterns = ['* включи* подсветку *']
light_on = SmartHome('led_on', keywords, patterns)
light_on.setStart(method)
################################################################################
def method(params):
SmartHome.send({
'target': 'led',
'cmd': 'led_off',
})
voice = text = ''
return Response(text = text, voice = voice)
keywords = {}
patterns = ['* выключи* подсветку *']
led_off = SmartHome('led_off', keywords, patterns)
led_off.setStart(method)
################################################################################
def method(params):
SmartHome.send({
'target': 'led',
'cmd': 'led_hello',
})
voice = text = ''
return Response(text = text, voice = voice)
keywords = {}
patterns = []
led_hello = SmartHome('led_hello', keywords, patterns)
led_hello.setStart(method)
################################################################################

View File

@ -118,7 +118,6 @@ while True:
print('\nYou: ', end='')
speech = listener.listen()
print(speech.get('text') or '', end='')
voids = 0
while True:
if speech['status'] == 'error':
break