inverse / tuya-client
This package is abandoned and no longer maintained.
No replacement package was suggested.
API client for Tuya
0.4.0-alpha
2021-01-14 20:27 UTC
Requires
- php: ^7.1
- ext-json: *
- guzzlehttp/guzzle: ^6.3
- webmozart/assert: ^1.3
Requires (Dev)
- phpunit/phpunit: ^7.2
This package is auto-updated.
Last update: 2023-11-12 19:02:19 UTC
README
An WIP API Client for controlling Tuya products, heavily inspired by tuyapy.
From my understanding the API that this library uses is no longer supported and as such you'll have better luck leveraging a package such as: https://github.com/ground-creative/tuyapiphp
Currently Supporting
- Switch devices
Installation
composer require inverse/tuya-client
Example
<?php require __DIR__ . '/vendor/autoload.php'; use Inverse\TuyaClient\Session; use Inverse\TuyaClient\ApiClient; use Inverse\TuyaClient\Device\SwitchDevice; use Inverse\TuyaClient\BizType; // Setup credentials $username = getenv('TUYA_USERNAME'); $password = getenv('TUYA_PASSWORD'); $countryCode = getenv('TUYA_COUNTRYCODE'); $bizType = new BizType(BizType::TUYA); // Make client $session = new Session($username, $password, $countryCode, $bizType); $apiClient = new ApiClient($session); // Get all devices $devices = $apiClient->discoverDevices(); // Switch on all switches foreach ($devices as $device) { if ($device instanceOf SwitchDevice) { if (!$device->isOn()) { $apiClient->sendEvent($device->getOnEvent()); } } }
Testing
Copy phpunit.xml.dist
to phpunit.xml
and replace the server variables with your credentials.
Licence
MIT