Download the PHP package sabinus52/tuyacloudapi without Composer

On this page you can find all versions of the php package sabinus52/tuyacloudapi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package tuyacloudapi

TuyaCloudApi

Library to control the Tuya device

Version 2.0

See release notes

Support devices

Installation

composer require sabinus52/tuyacloudapi

Example

require __DIR__ . '../vendor/autoload.php';

use Sabinus\TuyaCloudApi\TuyaCloudApi;
use Sabinus\TuyaCloudApi\Session\Session;
use Sabinus\TuyaCloudApi\Session\Platform;
use Sabinus\TuyaCloudApi\Device\DeviceFactory;
use Sabinus\TuyaCloudApi\Device\SwitchDevice;
use Sabinus\TuyaCloudApi\Device\SceneDevice;
use Sabinus\TuyaCloudApi\Device\LightDevice;
use Sabinus\TuyaCloudApi\Device\CoverDevice;
use Sabinus\TuyaCloudApi\Device\ClimateDevice;

$codeReturn = [ 0 => 'OK', 1 => 'IN CACHE', 9 => 'ERROR' ];

/**
 * @param String Identifiant de connexion
 * @param String Mot de passe
 * @param String Code pays
 * @param String Plateforme (tuya ou smartlife)
 * @param Float timeout des requêtes http en secondes
 */
$session = new Session($argv[1], $argv[2], '33', Platform::SMART_LIFE, 5.0);
// FACULTATIF : Change le dossier de stockage du jeton, par défaut dans sys_get_temp_dir()
$session->setFolderStorePool('/tmp');

// Initialize object API
$api = new TuyaCloudApi($session);

// Lance une découverte
$isSuccess = $api->discoverDevices();
var_dump($isSuccess);

// Retourne la liste des objets
$devices = $api->getAllDevices();
//var_dump($devices);

/**
 * Création des objets
 */
// Methode 1 : à partir d'un découverte
$device = $api->getDeviceById('012345678901234598');
// Methode 2
$device = new SwitchDevice($session, '012345678901234598');
// Méthose 3
$device = DeviceFactory::createDeviceFromId($session, '012345678901234598', DeviceFactory::TUYA_SWITCH);

/**
 * Scene
 */
$device = new SceneDevice($session, '012345678901234598');
$device->activate();

/**
 * Prise
 */
$device = new SwitchDevice($session, '012345678901234598');
// Allume la prise
$isSuccess = $device->turnOn();
// Eteins la prise
$isSuccess = $device->turnOff();
// Mets à jour l'objet pour récupérer le dernier état
$isSuccess = $device->update();
print 'Etat : ' . $device->getState();

/**
 * Lampe
 */
$device = new LightDevice($session, '012345678901234598');
// Allume la lampe
$isSuccess = $device->turnOn();
// Change la couleur
$isSuccess = $device->setColor(100, 80);
// Luminosité à 50%
$isSuccess = $device->setBrightness(50);
// Eteins la lampe
$isSuccess = $device->turnOff();
print 'Eteins la lampe : ' . $codeReturn[$isSuccess]; print "\n";

/**
 * Volet
 */
$device = new CoverDevice($session, '012345678901234598');
// Ferme le volet
$isSuccess = $device->close();
// Stoppe le volet
$isSuccess = $device->stop();
// Ouvre le volet
$isSuccess = $device->open();

/**
 * Climatisation
 */
$device = new ClimateDevice($session, '012345678901234598');
// Allume la clim
$isSuccess = $device->turnOn();
// Change la température
$isSuccess = $device->setThermostat();
// Eteins la clim
$isSuccess = $device->open();

See the file ./test/exemple.php


All versions of tuyacloudapi with dependencies

PHP Build Version
Package Version
Requires php Version ^5.2|^7|^8
guzzlehttp/guzzle Version ^6.5.7|^7.4.4
mexitek/phpcolors Version 1.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sabinus52/tuyacloudapi contains the following files

Loading the files please wait ....