Exemplo n.º 1
0
function put($arr)
{
    $hue = new Hue();
    if (isset($arr['toggle'])) {
        $hue->toggleLight($arr['toggle']);
        http_response_code(202);
    }
    if (isset($arr['bri'], $arr['protocol'], $arr['value'])) {
        switch ($arr['protocol']) {
            case 'hue':
                $hue->setBrightness($arr['bri'], $arr['value']);
                http_response_code(202);
            default:
                http_response_code(404);
        }
    }
    if (isset($arr['color'], $arr['value'])) {
        $hue->setColor($arr['color'], $arr['value']);
        http_response_code(202);
    }
    if (isset($arr['on'], $arr['protocol'], $arr['value'])) {
        switch ($arr['protocol']) {
            case 'hue':
                $hue->on($arr['on'], $arr['value']);
                http_response_code(202);
            default:
                http_response_code(404);
        }
    }
    if (isset($arr['set'], $arr['room'], $arr['name'], $arr['uid'])) {
        $light = $arr['set'];
        $arr['room'] == -1 ? $room = NULL : ($room = $arr['room']);
        setRoom($light, $room);
        $hue->setName($arr['uid'], $arr['name']);
        (new Sync())->update(Sync::LIGHTS);
        http_response_code(202);
    }
}