Réveille programmable avec HC2

Réveille programmable avec HC2

Bonjour,

Aujourd’hui je partage avec vous une scène simple qui permet nous réveiller le matin.
Pour cela nous allons utiliser notre serveur PAW et sa synthèse vocale.

Etape 1 :

–          Installer serveur PAW sur votre Android (suivez ce tuto)

–          Installer et configurer le script de synthèse vocal (suivez ce tuto)

Etape 2 :

–          Créez une nouvelle scène puis insérez le code suivant en modifions a votre convenance.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
--[[
%% autostart
%% properties
%% globals
--]]    
 
-- SETTINGS
local HReveil = "06:30"; -- heure du réveille
local IdSv = XX  -- remplacez XX par ID_de_votre_VD_synthèse_vocale;
 
local sourceTrigger = fibaro:getSourceTrigger();
if (sourceTrigger["type"] == "autostart") then
while true do
 
local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();
 
-- currentDate.wday == 1 correspond a Dimanche
-- currentDate.wday == 2 correspond a Lundi
-- etc...
-- currentDate.wday == 7 correspond a Samedi
-- ici j ai programmé le réveil de lundi au vendredi
-- modifier a votre convenance
if (
 ( ((currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == HReveil ) )
)
then
    -- volume sonore du smartphone
    fibaro:setGlobal("vol", "10")
        -- message vocal à envoyer au smartphone
    fibaro:setGlobal("speech", "Bonjour, il est " .. string.format("%02d", currentDate.hour) .. " heure " .. string.format("%02d", currentDate.min) .. " il faut se réveiller")
    -- activation du périphérique virtuel et bouton ad hoc
    fibaro:call(IdSv, "pressButton", "1");
end
 
fibaro:sleep(60*1000);
end
else
 
local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();
if (
startSource["type"] == "other"
)
then
    -- volume sonore du smartphone
    fibaro:setGlobal("vol", "10")
        -- message vocal à envoyer au smartphone
    fibaro:setGlobal("speech", "Bonjour, il est " .. string.format("%02d", currentDate.hour) .. " heure " .. string.format("%02d", currentDate.min) .. " il faut se réveiller")
    -- activation du périphérique virtuel et bouton ad hoc
    fibaro:call(IdSv, "pressButton", "1");
end
 
end
--[[
%% autostart
%% properties
%% globals
--]]	

-- SETTINGS
local HReveil = "06:30"; -- heure du réveille
local IdSv = XX  -- remplacez XX par ID_de_votre_VD_synthèse_vocale;

local sourceTrigger = fibaro:getSourceTrigger();
if (sourceTrigger["type"] == "autostart") then
while true do

local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();

-- currentDate.wday == 1 correspond a Dimanche
-- currentDate.wday == 2 correspond a Lundi
-- etc...
-- currentDate.wday == 7 correspond a Samedi
-- ici j ai programmé le réveil de lundi au vendredi
-- modifier a votre convenance
if (
 ( ((currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == HReveil ) )
)
then
	-- volume sonore du smartphone
	fibaro:setGlobal("vol", "10")
        -- message vocal à envoyer au smartphone
	fibaro:setGlobal("speech", "Bonjour, il est " .. string.format("%02d", currentDate.hour) .. " heure " .. string.format("%02d", currentDate.min) .. " il faut se réveiller")
	-- activation du périphérique virtuel et bouton ad hoc
	fibaro:call(IdSv, "pressButton", "1");
end

fibaro:sleep(60*1000);
end
else

local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();
if (
startSource["type"] == "other"
)
then
	-- volume sonore du smartphone
	fibaro:setGlobal("vol", "10")
        -- message vocal à envoyer au smartphone
	fibaro:setGlobal("speech", "Bonjour, il est " .. string.format("%02d", currentDate.hour) .. " heure " .. string.format("%02d", currentDate.min) .. " il faut se réveiller")
	-- activation du périphérique virtuel et bouton ad hoc
	fibaro:call(IdSv, "pressButton", "1");
end

end

[recent_deals per_page=”12″ columns=”3″ orderby=”date” order=”desc”]

Articles Similaires

Leave a Comment


The reCAPTCHA verification period has expired. Please reload the page.

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur comment les données de vos commentaires sont utilisées.