Problème Blockly

Free domotica! Forums Report a bug Problème Blockly

This topic contains 3 replies, has 2 voices, and was last updated by Mika Mika 1 year, 11 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1334

    Maxland
    Participant

    Bonjour,
    J’ai un problème de fonctionnement avec un bloclky. lorsque les conditions sont réunis (if) ma lampe s’allume mais s’éteint 45 secondes plus tard. je n’arrive pas à trouver la solution, je pense que mes variables sont bonnes. Si quelqu’un a une idée…

    Voici le bout de code:

    $Semaine;
    $Samedi;
    $On;
    $Off;

    $event = “empty”;
    if(isset($argv[1])){
    $event = $argv[1];
    }

    function getValue($service,$deviceid, $valueid){
    $abspath = dirname(__FILE__);
    $datapath = $abspath.DIRECTORY_SEPARATOR.”..”.DIRECTORY_SEPARATOR.$service.”.json”;
    $content = file_get_contents($datapath);
    $json = json_decode($content);
    foreach($json as $object){
    if($object->id == $deviceid){
    $values = array();
    if(isset($object->values)){
    $values = $object->values;
    }
    foreach($values as $value){
    if($value->id == $valueid){
    $v = “”;
    if(isset($value->value)){
    $v = $value->value;
    }
    return $v;
    }
    }
    }
    }
    return “”;
    }

    function setValue($service,$deviceid, $valueid,$value){
    $url = “http://localhost:4020/message=”;
    $message = “1|scene|”.$service.”|UPDATEPROPERTY|”.$deviceid.”|”.$valueid.”|”.$value;
    $messageURL = $url . rawurlencode($message);
    file_get_contents($messageURL);
    sleep(1);
    }

    function dateBetween($timeFrom, $timeTo){
    $current = date(“Y-m-d H:i”);
    if($timeTo == “00:00″){
    $timeTo=”23:59”;
    }
    $from = date(“Y-m-d H:i”, strtotime($timeFrom));
    $to = date(“Y-m-d H:i”, strtotime($timeTo));
    if(strtotime($from) > strtotime($to)){
    if(strtotime($from) > strtotime($to) && strtotime($current) < strtotime($from)){
    $from = date(“Y-m-d H:i”,strtotime($from. ‘ – 1 days’));
    }else if(strtotime($current) > strtotime($from) && strtotime($current) > strtotime($to)){
    $to = date(“Y-m-d H:i”,strtotime($to. ‘ + 1 days’));
    }
    }
    if((strtotime($current) >= strtotime($from)) && (strtotime($current) <= strtotime($to))){
    return true;
    }else{
    return false;
    }
    }

    $Semaine = ((strtoupper(date(“D”)) == ‘MON’ || strtoupper(date(“D”)) == ‘TUE’ || strtoupper(date(“D”)) == ‘WED’ || strtoupper(date(“D”)) == ‘THU’ || strtoupper(date(“D”)) == ‘FRI’) || strtoupper(date(“D”)) ==’SUN’) && dateBetween(’12:00′,’22:30′);
    $Samedi = strtoupper(date(“D”)) ==’SAT’ && dateBetween(’12:00′,’23:30′);
    $On = “99”;
    $Off = “0”;
    if ((getValue(“zwave”,”zwave-5″,”49-user-decimal-1-3″)) <= “30”) {
    if ($Semaine) {
    setValue(“zwave”,”zwave-4″,”38-user-byte-1-0″,$On);
    } else {
    setValue(“zwave”,”zwave-4″,”38-user-byte-1-0″,$Off);
    }
    if ($Samedi) {
    setValue(“zwave”,”zwave-4″,”38-user-byte-1-0″,$On);
    } else {
    setValue(“zwave”,”zwave-4″,”38-user-byte-1-0″,$Off);
    }
    } else {
    setValue(“zwave”,”zwave-4″,”38-user-byte-1-0″,$Off);
    }

    #1359
    Mika
    Mika
    Keymaster

    Bonjour,

    Pouvez vous me contacter par mail et m’envoyer un printscreen de votre scene avec les blocks?

    Merci
    Mika

    #1367

    Maxland
    Participant

    Bonjour, je n’ai que noreply@pulse-station.com

    #1372
    Mika
    Mika
    Keymaster

    info [at] pulse-station.com

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.