You've already forked STARK
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:
@ -1,3 +1,4 @@
|
||||
from .main_light import *
|
||||
from .window import *
|
||||
from .alarmclock import *
|
||||
from .light import *
|
||||
|
64
SmartHome/light.py
Normal file
64
SmartHome/light.py
Normal 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)
|
||||
|
||||
################################################################################
|
@ -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
|
||||
|
Reference in New Issue
Block a user