Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
fr:liste_script [2015/12/23 18:39] eric64 |
fr:liste_script [2016/07/28 14:14] mifrey Script 6 + coloration syntaxique |
||
---|---|---|---|
Line 6: | Line 6: | ||
**But :** Script permettant de modifier la couleur d’une led RGB en fonction de la température de la pièce | **But :** Script permettant de modifier la couleur d’une led RGB en fonction de la température de la pièce | ||
- | < | + | < |
-- Title: Set RGB light output depending on Temperature | -- Title: Set RGB light output depending on Temperature | ||
-- | -- | ||
Line 60: | Line 60: | ||
- | < | + | < |
function urlencode(str) | function urlencode(str) | ||
if (str) then | if (str) then | ||
Line 88: | Line 88: | ||
**But :** Script permettant de gérer le chauffage en fonction de la température des panneaux solaires du ballon EC et du plancher. | **But :** Script permettant de gérer le chauffage en fonction de la température des panneaux solaires du ballon EC et du plancher. | ||
- | < | + | < |
print(" | print(" | ||
local temp_panneaux = calaos: | local temp_panneaux = calaos: | ||
Line 172: | Line 172: | ||
__Script :__ | __Script :__ | ||
- | < | + | < |
local RGBplafond = calaos: | local RGBplafond = calaos: | ||
local Wplafond = calaos: | local Wplafond = calaos: | ||
Line 197: | Line 197: | ||
//By eric64// | //By eric64// | ||
- | **But :** Script permettant de donner une valeur True ou False à une variable lors de l' | + | **But :** Script permettant de donner une valeur True ou False à une variable lors de l' |
- | < | + | < |
- | -- Title: Set RGB light output depending on Temperature | + | |
- | -- | + | |
- | -- Description : | + | |
- | -- Set white color if temp is < 10°C | + | |
- | -- Set light blue color if temps is between 10 and 15 | + | |
- | -- Set dark blue color if temp is between 15 and 19 | + | |
- | -- Set green color if temp is between 19 and 22 | + | |
- | -- Set Yellow color ir temp is between 22 and 25 | + | |
- | -- Set Orange color if temp is between 25 and 28 | + | |
- | -- Set Red color if temp is greater than 28 | + | |
- | -- | + | |
- | -- Inputs | + | |
- | -- * input_4 : N° entrée Temperature | + | |
- | -- Output | + | |
- | -- * output_6 : N° Sortie RGB light | + | |
- | -- Events | + | |
- | -- This script may be launched on input_4 changes | + | |
- | + | ||
- | local temp = calaos: | + | |
- | if temp < 10.0 then | + | |
- | --blanc | + | |
- | str = "set 0x60FFFF" | + | |
- | elseif temp >= 10.0 and temp < 15.0 then | + | |
- | --bleu clair | + | |
- | str = "set 0x28FFFF" | + | |
- | elseif temp >= 15.0 and temp < 19.0 then | + | |
- | --bleu foncé | + | |
- | str = "set 0x0060FF" | + | |
- | elseif temp >= 19.0 and temp < 22.0 then | + | |
- | -- vert | + | |
- | str = "set 0x28FF28" | + | |
- | elseif temp >= 22.0 and temp < 25.0 then | + | |
- | -- Jaune | + | |
- | str = "set 0x7AFF00" | + | |
- | elseif temp >= 25.0 and temp < 28.0 then | + | |
- | -- Orange | + | |
- | str = "set 0xFFFF00" | + | |
- | elseif temp > 28.0 then | + | |
- | -- Rouge | + | |
- | str = "set 0xFF3D00" | + | |
- | end | + | |
- | calaos: | + | |
- | return true | + | |
- | + | ||
- | ****** | + | |
local Variable_Activation_Inter = calaos: | local Variable_Activation_Inter = calaos: | ||
Line 261: | Line 216: | ||
return true | return true | ||
</ | </ | ||
+ | |||
+ | \\ === 6- Détection d'une situation " | ||
+ | //By mifrey// | ||
+ | |||
+ | **But :** Script permettant de détecter une situation " | ||
+ | |||
+ | |||
+ | **Précisions :** Le script doit être mis dans les conditions d'une règle et être déclenché par tous les poussoirs voulus (je les ai mis tous chez moi). Il retourne true en cas de situation panique. Dans l' | ||
+ | |||
+ | |||
+ | __A créer dans CALAOS INSTALLER :__ | ||
+ | < | ||
+ | - Un timer (type InputTimer) : Pour mesurer le temps depuis la première pression sur le poussoir. Le timer est à régler sur quelques secondes. | ||
+ | - Un compteur (type InternalInt) : Pour compter le nombre de fois qu'un poussoir est actionné. | ||
+ | </ | ||
+ | |||
+ | __Script :__ | ||
+ | <code lua> | ||
+ | -- Detect a panic situation in which switches are pressed several times within a short time. | ||
+ | -- The script assumes to be called each time the state of a switch changes. | ||
+ | |||
+ | --if true then return false end -- Uncomment to disable the script | ||
+ | |||
+ | -- Script start | ||
+ | local script_name = " | ||
+ | print(script_name .. ": start" | ||
+ | |||
+ | -- IO id | ||
+ | local timer_id = " | ||
+ | local counter_id = " | ||
+ | |||
+ | -- Other variables to define | ||
+ | local panic_count = 12 -- Number of times the state of a switch must change within a specific time (typically 2 seconds) to trigger a panic situation | ||
+ | |||
+ | -- Print timer and counter value at script start | ||
+ | print(script_name .. ": timer = " .. tostring(calaos: | ||
+ | print(script_name .. ": counter = " .. tostring(calaos: | ||
+ | |||
+ | -- Get timer status: Timer is false when timer starts or stops, true when timer is done. | ||
+ | local timer = calaos: | ||
+ | |||
+ | -- Timer is done, reset timer and counter. | ||
+ | if timer == " | ||
+ | print(script_name .. ": Timer is done, reset timer and counter." | ||
+ | calaos: | ||
+ | calaos: | ||
+ | print(script_name .. ": timer = " .. tostring(calaos: | ||
+ | print(script_name .. ": counter = " .. tostring(calaos: | ||
+ | print(script_name .. ": end") | ||
+ | return false | ||
+ | end | ||
+ | |||
+ | -- Increment the counter | ||
+ | local counter = calaos: | ||
+ | calaos: | ||
+ | |||
+ | -- Timer is not done and counts not reached, continues to count. | ||
+ | if counter < panic_count then | ||
+ | print(script_name .. ": Timer is not done and counts not reached, continue." | ||
+ | print(script_name .. ": timer = " .. tostring(calaos: | ||
+ | print(script_name .. ": counter = " .. tostring(calaos: | ||
+ | print(script_name .. ": end") | ||
+ | return false | ||
+ | -- Timer is not done and counts reached, panic mode. | ||
+ | else | ||
+ | print(script_name .. ": Timer is not done and counts reached, panic mode." | ||
+ | print(script_name .. ": timer = " .. tostring(calaos: | ||
+ | print(script_name .. ": counter = " .. tostring(calaos: | ||
+ | calaos: | ||
+ | calaos: | ||
+ | print(script_name .. ": end") | ||
+ | return true | ||
+ | end | ||
+ | |||
+ | print(script_name .. ": Oups, should never be there..." | ||
+ | return false | ||
+ | </ | ||
+ | |||
+ | |||
+ |