Exemplo n.º 1
0
<?php

include_once "../modules/SymconSonos/Sonos/sonosAccess.php";
include_once "../modules/SymconSonos/Sonos/radio_stations.php";
$ip = IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "IPAddress");
$timeout = IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "TimeOut");
if (!$timeout || Sys_Ping($ip, $timeout) == true) {
    $sonos = new SonosAccess($ip);
    $status = $sonos->GetTransportInfo();
    SetValueInteger(IPS_GetObjectIDByName("Volume", IPS_GetParent($_IPS["SELF"])), $sonos->GetVolume());
    if (IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "MuteControl")) {
        SetValueInteger(IPS_GetObjectIDByName("Mute", IPS_GetParent($_IPS["SELF"])), $sonos->GetMute());
    }
    if (IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "LoudnessControl")) {
        SetValueInteger(IPS_GetObjectIDByName("Loudness", IPS_GetParent($_IPS["SELF"])), $sonos->GetLoudness());
    }
    if (IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "BassControl")) {
        SetValueInteger(IPS_GetObjectIDByName("Bass", IPS_GetParent($_IPS["SELF"])), $sonos->GetBass());
    }
    if (IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "TrebleControl")) {
        SetValueInteger(IPS_GetObjectIDByName("Treble", IPS_GetParent($_IPS["SELF"])), $sonos->GetTreble());
    }
    if (IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "BalanceControl")) {
        $leftVolume = $sonos->GetVolume("LF");
        $rightVolume = $sonos->GetVolume("RF");
        if ($leftVolume == $rightVolume) {
            SetValueInteger(IPS_GetObjectIDByName("Balance", IPS_GetParent($_IPS["SELF"])), 0);
        } elseif ($leftVolume > $rightVolume) {
            SetValueInteger(IPS_GetObjectIDByName("Balance", IPS_GetParent($_IPS["SELF"])), $rightVolume - 100);
        } else {
            SetValueInteger(IPS_GetObjectIDByName("Balance", IPS_GetParent($_IPS["SELF"])), 100 - $leftVolume);