[Modul] Xiaomi Yeelight Color Bulb

Ich hoffe ich bin hier auch richtig um Fragen aus Richtung Entwicklung zu stellen.

Nach der Umstellung auf IPS5 kann ich in der WebGui leider nicht den Instanzen Editor öffnen.

Wo kann ich da schauen?
Hat sich der Aufbau der Module für PHP grundlegend geändert?

Nein, hat sich nicht.

Aber das JSON der form.json ist bei dir defekt.
Michael

:eek: das hätte ich ja nie entdeckt das zu viel gesetzte „,“! Vielen Dank!! :slight_smile:

Der Color_mode ist jetzt mit drin. Nach wie vor noch alles im experimentellen Zustand. Unter IPS 5.0 kann man jetzt zwar das Gerät hinzufügen, jedoch klappt der Dialog mit dem Socket noch nicht. Der Port 55443 muss immer manuell gesetzt werden.
Auch das Verarbeiten der Rückantworten führt noch zu einem Flow Handler Fehler in IP Symcon.
Bin weiterhin noch dran.

Gibt’s schon was neues? Habe jetzt noch eine Yeelight Deckenleuchte. Installieren konnte ich eine neue Instanz mit der Legacy console. Allerdings wie beschrieben der Flow Handler und leider geht auch der Color Mode nicht wirklich.

Moin zusammen,

wollte mal fragen wie der aktuelle Stand des Moduls ist :0)
Meine Lightstripes kann ich damit schon steuern … nur die Farbwahl funktioniert leider noch nicht :0(
Und ich muss mir mal die Befehle anschauen, dass ich auch Variablen per Script auslösen kann.

VG

Andreas

Nabend,

ich hab die module.php jetzt ein bisschen abgeaendert so dass man die Farbe und Saettigung auswaehlen kann.
Leider kriege ich die Farbe bei der Saettigungsuebergabe nicht hin. Hat da einer ne Idee. (Da wo die 0 steht unter function Saturation)

<?
// Klassendefinition
class YeelightColorBulb extends IPSModule {

    // Der Konstruktor des Moduls
    public function __construct($InstanceID) {
        // Diese Zeile nicht löschen
        parent::__construct($InstanceID);

        // Selbsterstellter Code
    }

    public function Create() {
        parent::Create();

        $this->RegisterPropertyString("ipadress", "");

        $this->RequireParent("{3CFF0FD9-E306-41DB-9B5A-9D06D38576C3}"); // CLIENT SOCKET
    }


    public function ApplyChanges() {
        // Diese Zeile nicht löschen
        parent::ApplyChanges();

        $this->RegisterVariableBoolean("power", "Power", "~Switch", 0);
        $this->RegisterVariableInteger("bright", "Brightness", "~Intensity.100", 1);
        $this->RegisterVariableInteger("ct", "Color Temperature", "~Intensity.65535", 2);
        $this->RegisterVariableInteger("rgb", "Color", "~HexColor", 3);
        $this->RegisterVariableString("hue", "Hue", "~String", 4);
        $this->RegisterVariableInteger("sat", "Saturation", "~Intensity.100", 5);
        $this->RegisterVariableInteger("color_mode", "Color Mode", "", 6);

        $this->GetConfigurationForParent();

        $this->EnableAction("power");
        $this->EnableAction("bright");
	$this->EnableAction("rgb");
	$this->EnableAction("sat");
    }

    public function GetConfigurationForParent()
    {
        $host = $this->ReadPropertyString("ipadress");
        $port = 55443;
        return "{\"Host\": \"$host\", \"Port\": \"$port\"}";
    }


    // Lese alle Konfigurationsdaten aus
    public function readStatesFromDevice() {
        $this->buildAndSendCommand('444', 'get_prop', array('power', 'bright', 'ct', 'rgb', 'hue', 'sat', 'color_mode'));
    }

    public function ReceiveData($JSONString)
    {
        $data = json_decode($JSONString);
        $payload = json_decode($data->Buffer);
        //27/12/2017 16:06:33 | Receive | {"id":1, "result":["off","27","2945","255","359","100","2"]}
        // this is our Datafetch from Configuration GUI, which has a fixed sorting of values
        if (isset($payload->id) && '444' == $payload->id) {
            SetValueBoolean(IPS_GetObjectIDByIdent("power", $this->InstanceID), 'on' == $payload->result[0] ? TRUE : FALSE);
            SetValueInteger(IPS_GetObjectIDByIdent("bright", $this->InstanceID), $payload->result[1]);
            SetValueInteger(IPS_GetObjectIDByIdent("ct", $this->InstanceID), $payload->result[2]);
            SetValueInteger(IPS_GetObjectIDByIdent("rgb", $this->InstanceID), $payload->result[3]);
            SetValueString(IPS_GetObjectIDByIdent("hue", $this->InstanceID), $payload->result[4]);
            SetValueInteger(IPS_GetObjectIDByIdent("sat", $this->InstanceID), $payload->result[5]);
            SetValueInteger(IPS_GetObjectIDByIdent("color_mode", $this->InstanceID), $payload->result[6]);
            IPS_LogMessage("Reciever", "done");
            return;
        }

        //IPS_LogMessage("Receiver", utf8_decode($data->Buffer));
        //27/12/2017 17:40:01 | Receiver | {"method":"props","params":{"power":"off"}}
        if (isset($payload->method) && 'props' == $payload->method) {
            foreach ($payload->params as $key => $val) {
                if ('power' == $key) {
                    SetValueBoolean(IPS_GetObjectIDByIdent("power", $this->InstanceID), 'on' == $val ? TRUE : FALSE);
                } else if ('bright' == $key) {
                    SetValueInteger(IPS_GetObjectIDByIdent("bright", $this->InstanceID), $val);
                } else if ('ct' == $key) {
                    SetValueInteger(IPS_GetObjectIDByIdent("ct", $this->InstanceID), $val);
                } else if ('rgb' == $key) {
                    SetValueInteger(IPS_GetObjectIDByIdent("rgb", $this->InstanceID), $val);
                } else if ('hue' == $key) {
                    SetValueString(IPS_GetObjectIDByIdent("hue", $this->InstanceID), $val);
                } else if ('sat' == $key) {
                    SetValueInteger(IPS_GetObjectIDByIdent("sat", $this->InstanceID), $val);
                } else if ('color_mode' == $key) {
                    SetValueInteger(IPS_GetObjectIDByIdent("color_mode", $this->InstanceID), $val);
                }
            }
        } else {
            IPS_LogMessage("YeelightColorBulb", "Unknown Notification received " . utf8_decode($data->Buffer));
        }
    }

    public function RequestAction($Ident, $Value)
    {
        IPS_LogMessage("RequestAction ", utf8_decode($Ident) . " value: " . $Value);
        switch ($Ident) {
            case "power":
                $this->Power($Value);
                break;
            case "bright":
                $this->Brightness($Value);
                break;
            case "rgb":
                $this->RGB($Value);
                break;
            case "sat":
                $this->Saturation($Value);
                break;
            default:
                throw new Exception("Invalid Ident: " . $Ident);
        }
    }

    public function Power($Value)
    {
        $this->buildAndSendCommand(10, "set_power", array($Value ? 'on' : 'off', 'smooth', 500));
    }

    public function Brightness($Value)
    {
        $this->buildAndSendCommand('20', "set_bright", array($Value));
    }

    public function RGB($Value)
    {
        $this->buildAndSendCommand(10, "set_rgb", array($Value, 'smooth', 500));
    }
    public function Saturation($Value)
    {
        $this->buildAndSendCommand(10, "set_hsv", array(0, $Value, 'smooth', 500));
    }
    private function buildAndSendCommand($id, $method, $params)
    {
        $Data = Array(
            'id' => $id,
            'method' => $method,
            'params' => $params
        );
        $payload = json_encode($Data);

        $this->SendDataToParent(json_encode(Array(
            "DataID" => "{79827379-F36E-4ADA-8A95-5F8D1DC92FA9}",
            "Buffer" => $payload . "
"
        )));

    }
}
?>

Hi,

welche Methoden hast Du genau im Modul hinzugefügt?
Ich war der Meinung damals alle Parameter integriert zu haben.
Hast Du die Erweiterung nach dieser Doku vorgenommen: https://www.yeelight.com/download/Yeelight_Inter-Operation_Spec.pdf

Grüße

Hallo,
vielen Dank für das Plugin. Vielleicht kann mir mal jemand schnell auf die Sprünge helfen, wie ich das Plugin in mein IPS 4.4 einfügen kann, und was passieren muss um mehrere Yeelights zu steuern.

Vielen Dank an die Spezialisten hier.

Liebe Grüße
Stromer

Betreut das originale Modul noch wer? Farb-Änderung etc. haben es ja ins Modul noch nicht geschafft. Anpassungen an die Web-Gui auch nicht etc.

Wenn nicht würde ich es Forken und selber anpassen (hab es für die Farbwahl schon gemacht, erst danach gesehen das hier eine Änderung gepostet wurde).

Schau Mal im Store vorbei :wink:
Michael

Du hast also exakt das schon getan, wenn ich das richtig sehe?

Mit Discovery-Instanz, RGB Auswahl und HUE Slider :smiley:
Michael

@Nall-chan: Nachdem Du ja dieses super Modul gebaut hast, bin ich natürlich auch umgestiegen, da es wesentlich besser ist als meins… :smiley:
Ich wollte mal Fragen, ob Du für den Deckenleuchte noch den Moon-Modus integrieren könntest?

active_mode 0: daylight mode / 1: moonlight mode (ceiling light only)

Table 4-2

Witzig, mein Dokument ist auch aus 2015 und da gibt es diese Eigenschaft nicht.
Ich werde mal schauen das ist eine YEELIGHT_SetPowerEx Funktion baue, wo man dann den Modus übergeben kann.
Michael

Irgendwie stehe ich da auf dem Schlauch.
Ich finde das nur bei den Eigenschaften, aber nicht wie ich das setzen könnte.
Hast du da ein Beispiel?

Und kannst du bitte aus dem Debug der Instanz mit den Eintrag ‚Got propertys‘ zeigen; dieser wird erzeugt wenn du die Konfig der Instanz einmal übernimmst.
Ebenso sollte unter Meldungen dann ein Eintrag mit ‚YeelightDevice | Propertys read: XXXX‘ erzeugt werden, und eventuell auch ein weiterer für den fehlenden ‚active_mode‘.
Michael

OK, das könnte der Haken sein. Ich habe die Eigenschaft active_mode nicht. Grund ist, dass ich sämtliche IoT Devices in einem separaten VLAN und WLAN haben. Daher funktioniert leider SSDP nicht. Das klappt trotz mdns „repeater“ auf der PfSense nicht.
Daher bekomme ich auch immer ein:

if (count($this->Capabilitys) == 0) {
       //   $this->LogMessage($this->Translate('Capabilitys of device are unknown. Please check your Firewall.'), KL_WARNING);
}

so, dass ich diese Logmeldung schon selber aaskommentiert habe.
Gibt es eventuell eine Möglichkeit, dass ich diesen active_mode selber zur Lampe ergänze?

Mich wundert eher das überhaupt die Instanzen funktionieren.
Die API sieht vor über SSDP die Fähigkeiten zu ermitteln.
Und ohne die zu kennen, kann die Instanz gar nicht sauber funktionieren :confused:
Wie gesagt, die API sagt nicht aus wo diese Eigenschaft genutzt wird. Wenn du da eine Idee hast, immer her damit :slight_smile:
Michael
Edit: okay das RequestState funktioniert dann bei dir nicht.
Das SSDP geht hier über einen anderen Port 1982, als den üblichen 1900.

Stimmt, da gibt es gar kein eigenes CMD bzw. „method“ laut Doku für.
Ich werde also die Lampe noch ma im anderen WLAN anlernen müssen oder eine Test Instanz in diesem VLAN aufsetzen.
Vielleicht schaffe ich das dieses Wochenende. :slight_smile:

Hallo Michael,

kannst Du damit etwas anfangen?

TXT: 17/10/2019, 22:34:08 |      Ask capabilitys | M-SEARCH * HTTP/1.1<CR><LF>HOST: 172.16.200.221:1982<CR><LF>MAN: "ssdp:discover"<CR><LF>ST: wifi_bulb<CR><LF><CR><LF>
HEX: 17/10/2019, 22:34:08 |      Ask capabilitys | 4D 2D 53 45 41 52 43 48 20 2A 20 48 54 54 50 2F 31 2E 31 0D 0A 48 4F 53 54 3A 20 31 37 32 2E 31 36 2E 32 30 30 2E 32 32 31 3A 31 39 38 32 0D 0A 4D 41 4E 3A 20 22 73 73 64 70 3A 64 69 73 63 6F 76 65 72 22 0D 0A 53 54 3A 20 77 69 66 69 5F 62 75 6C 62 0D 0A 0D 0A 
TXT: 17/10/2019, 22:34:08 |      Got capabilitys | get_prop set_default set_power toggle set_bright start_cf stop_cf set_scene cron_add cron_get cron_del set_ct_abx set_rgb set_hsv set_adjust adjust_bright adjust_ct adjust_color set_music set_name
HEX: 17/10/2019, 22:34:08 |      Got capabilitys | 67 65 74 5F 70 72 6F 70 20 73 65 74 5F 64 65 66 61 75 6C 74 20 73 65 74 5F 70 6F 77 65 72 20 74 6F 67 67 6C 65 20 73 65 74 5F 62 72 69 67 68 74 20 73 74 61 72 74 5F 63 66 20 73 74 6F 70 5F 63 66 20 73 65 74 5F 73 63 65 6E 65 20 63 72 6F 6E 5F 61 64 64 20 63 72 6F 6E 5F 67 65 74 20 63 72 6F 6E 5F 64 65 6C 20 73 65 74 5F 63 74 5F 61 62 78 20 73 65 74 5F 72 67 62 20 73 65 74 5F 68 73 76 20 73 65 74 5F 61 64 6A 75 73 74 20 61 64 6A 75 73 74 5F 62 72 69 67 68 74 20 61 64 6A 75 73 74 5F 63 74 20 61 64 6A 75 73 74 5F 63 6F 6C 6F 72 20 73 65 74 5F 6D 75 73 69 63 20 73 65 74 5F 6E 61 6D 65 
TXT: 17/10/2019, 22:34:08 |        Got propertys | power bright color_mode ct rgb hue sat
HEX: 17/10/2019, 22:34:08 |        Got propertys | 70 6F 77 65 72 20 62 72 69 67 68 74 20 63 6F 6C 6F 72 5F 6D 6F 64 65 20 63 74 20 72 67 62 20 68 75 65 20 73 61 74 
TXT: 17/10/2019, 22:34:08 |                 Send | {"id":4334,"method":"get_prop","params":["power","bright","color_mode","ct","rgb","hue","sat"]}
HEX: 17/10/2019, 22:34:08 |                 Send | 7B 22 69 64 22 3A 34 33 33 34 2C 22 6D 65 74 68 6F 64 22 3A 22 67 65 74 5F 70 72 6F 70 22 2C 22 70 61 72 61 6D 73 22 3A 5B 22 70 6F 77 65 72 22 2C 22 62 72 69 67 68 74 22 2C 22 63 6F 6C 6F 72 5F 6D 6F 64 65 22 2C 22 63 74 22 2C 22 72 67 62 22 2C 22 68 75 65 22 2C 22 73 61 74 22 5D 7D 
TXT: 17/10/2019, 22:34:08 |              Receive | {"id":4334, "result":["off","35","2","2945","","",""]}
HEX: 17/10/2019, 22:34:08 |              Receive | 7B 22 69 64 22 3A 34 33 33 34 2C 20 22 72 65 73 75 6C 74 22 3A 5B 22 6F 66 66 22 2C 22 33 35 22 2C 22 32 22 2C 22 32 39 34 35 22 2C 22 22 2C 22 22 2C 22 22 5D 7D 

Grüße
Steffen