DuoFernGateway/module.php
/**
     * Handles registered messages
     * Will be called when receiving a registered msg
     *
     * @param int $TimeStamp
     * @param int $SenderID
     * @param string $Message
     * @param array $Data
     */
Handles registered messages
Will be called when receiving a registered msg


Handles registered messages Will be called when receiving a registered msg
public function MessageSink($TimeStamp, $SenderID, $Message, $Data)
    {
        switch ($Message) {
            case IPS_KERNELSTARTED :
                $this->ApplyChanges();
                break;
            case FM_CONNECT :
            case FM_DISCONNECT :
                $this->ForceRefresh();
                break;
            case IM_CHANGESTATUS :
                if ($SenderID == @IPS_GetInstance($this->InstanceID) ['ConnectionID']) {
                    $this->ForceRefresh();
                }
                break;
            case IM_CHANGESETTINGS :
                foreach ($Data as $changedPropertyJson) {
                    $changedProperty = json_decode($changedPropertyJson, true);
                    if (is_array($changedProperty) && array_key_exists("duoFernCode", $changedProperty)) {
                        $duoFernCode = $changedProperty["duoFernCode"];
                        if (!preg_match(DuoFernRegex::DUOFERN_REGEX_DUOFERN_CODE, $duoFernCode)) {
                            break;
                        }
                        if (in_array($duoFernCode, (array)$this->DeviceDuoFernCodes)) {
                            break;
                        }
                        $this->ForceRefresh();
                    }
                }
                break;
        }
    }
public function MessageSink ( $ TimeStamp , $ SenderID , $ Message , $ Data ) { switch ( $ Message ) { case IPS_KERNELSTARTED : $ this -> ApplyChanges ( ) ; break ; case FM_CONNECT : case FM_DISCONNECT : $ this -> ForceRefresh ( ) ; break ; case IM_CHANGESTATUS : if ( $ SenderID == @ IPS_GetInstance ( $ this -> InstanceID ) [ 'ConnectionID' ] ) { $ this -> ForceRefresh ( ) ; } break ; case IM_CHANGESETTINGS : foreach ( $ Data as $ changedPropertyJson ) { $ changedProperty = json_decode ( $ changedPropertyJson , true ) ; if ( is_array ( $ changedProperty ) && array_key_exists ( " duoFernCode " , $ changedProperty ) ) { $ duoFernCode = $ changedProperty [ " duoFernCode " ] ; if ( ! preg_match ( DuoFernRegex :: DUOFERN_REGEX_DUOFERN_CODE , $ duoFernCode ) ) { break ; } if ( in_array ( $ duoFernCode , ( array ) $ this -> DeviceDuoFernCodes ) ) { break ; } $ this -> ForceRefresh ( ) ; } } break ; } }
Handles registered messages
 Will be called when receiving a registered msg
Handles registered messages Will be called when receiving a registered msg
// check changed properties // if property duoFernCode is changed // valid duo fern code // no new duo fern code // force refresh