#!/usr/bin/env python
# -*- coding:utf-8 -*

# Plugin for FSTA
# the main FSTA.installation object is named "maison"
# To add a new group :
#	maison.add_group(name = "mongroupe", hotword = "mongroupe.pmdl")
# 
# To add a new scenario (here or (better) in another file (ie my_rule.scenario))
#	maison.group("mongroupe").add_scenario(name = "monscenario", _
#											phrases = [u"do this",u"do that"], _ or phrases = u"éteint la lumière",
#											actions = [
#												action_mqtt(
#													topic = "T-HOME/SALON/LUMIERES",
#													payload = "ON",
#													text = "ON"),
#												action(callback_function, text = "Oooh"),
#												action_os(cmd="my_cmd_line", text = "cmd_line")]
from FSTA.action import *
from FSTA.eyes import *

def reboot():
	import os
	import time
	time.sleep(3)
	os.system("shutdown now -r")

def halt():
	import os
	import time
	time.sleep(3)
	os.system("shutdown now -h")

maison.group("maison").add_scenario(name = "Stop",
									phrases = [ u'éteins-toi',
												u'shutdown'],
									actions = [
										action_mqtt_random(
													topic = 'T-HOME/PI-SALON/SPEAK',
													payload = [u"Je m'éteins.",
																u"Ok, mais n'oublie pas de me rallumer.",
																u'Adieu, que les framboises soient avec toi.']),
										action(callback=halt,text="halt")],
									min_cosine = 0.75)
maison.group("maison").add_scenario(name = "Reboot",
									phrases = [ u'redémarre'],
									actions = [
										action_mqtt_random(
													topic = 'T-HOME/PI-SALON/SPEAK',
													payload = [u"Je redémarre.",
																u"Ok, à tout de suite..",
																u'Pourquoi tant de haine?']),
										action(callback=halt,text="halt")],
									min_cosine = 0.75)