webproject-xyz / ikea-tradfri-php-api
PHP library to control ikea tradfri hub
Installs: 46
Dependents: 0
Suggesters: 0
Security: 0
Stars: 10
Watchers: 1
Forks: 2
Open Issues: 7
pkg:composer/webproject-xyz/ikea-tradfri-php-api
Requires
- php: ~8.3.0 || ~8.4.0
- ext-filter: *
- ext-json: *
- ext-mbstring: *
- doctrine/collections: ^2.6.0
- psr/log: ^3.0.2
- roave/better-reflection: ^6.69.0
- symfony/polyfill-mbstring: ^1.33.0
- symfony/process: ^7.4.5
- symfony/property-access: ^7.4.4
- symfony/property-info: ^7.4.5
- symfony/serializer: ^7.4.5
- symfony/service-contracts: ^3.6.1
- symfony/validator: ^7.4.5
- webmozart/assert: ^2.1.3
Requires (Dev)
- codeception/codeception: ^5.3.4
- codeception/mockery-module: ^0.5.0
- codeception/module-asserts: ^3.3.0
- ergebnis/license: ^2.7.0
- ergebnis/php-cs-fixer-config: ^6.60.0
- friendsofphp/php-cs-fixer: ^3.94.0
- maglnet/composer-require-checker: ^4.20.0
- mockery/mockery: ^1.6.12
- phpro/grumphp: ^2.19.0
- phpstan/extension-installer: ^1.4.3
- phpstan/phpdoc-parser: ^2.3.2
- phpstan/phpstan: ^2.1.39
- phpstan/phpstan-doctrine: ^2.0.16
- phpstan/phpstan-mockery: ^2.0.0
- phpunit/phpunit: ^12.5.12
- rector/rector: ^2.3.6
- roave/security-advisories: dev-latest
- symfony/var-dumper: ^7.4.4
- wmde/psr-log-test-doubles: ^3.4.0
- dev-main
- 4.1.5
- 4.1.4
- 4.1.3
- 4.1.2
- 4.1.1
- 4.1.0
- 4.0.0
- 3.1.x-dev
- 3.1.0
- 3.0.1
- 3.0.0
- 2.6.x-dev
- 2.6.0
- 2.5.x-dev
- 2.5.1
- 2.5.0
- 2.4.x-dev
- 2.4.0
- 2.3.x-dev
- 2.3.1
- 2.3.0
- 2.2.x-dev
- 2.2.0
- 2.1.0
- 2.0.0
- 1.0.0
- 0.3.13
- 0.3.12
- 0.3.11
- 0.3.10
- 0.3.9
- 0.3.8
- 0.3.7
- 0.3.6
- 0.3.5
- 0.3.4
- 0.3.3
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.0
- dev-renovate/major-symfony
- dev-renovate/major-github-actions
- dev-renovate/major-php-dev-tools
- dev-renovate/doctrine-collections-3.x
- dev-renovate/github-actions
- dev-renovate/lock-file-maintenance
- dev-renovate/phpunit-phpunit-13.x
- dev-renovate/all-minor-patch
This package is auto-updated.
Last update: 2026-02-17 00:44:45 UTC
README
A powerful and easy-to-use PHP library to control your IKEA Tradfri smart lights through the Gateway.
Inspired by hvanderlaan/ikea-smartlight (Python).
🚀 Quick Start
1. Requirements
- PHP 8.3 or higher
coap-client(can be run via Docker)- IKEA Tradfri Gateway
2. Initial Setup
To communicate with the gateway, you need to generate a security key. The easiest way is using our Docker Coap-Client:
# Pull the client docker pull webproject/coap-client:latest # Generate your API User and Shared Key docker run --rm --name coap-client webproject/coap-client -m post -u "Client_identity" -k "<COAP_GATEWAY_SECRET>" -e '{"9090":"php-api-user"}' "coaps://<COAP_GATEWAY_IP>:5684/15011/9063"
💻 Usage Examples
Initialize the API
use IKEA\Tradfri\Dto\CoapGatewayAuthConfigDto; use IKEA\Tradfri\Factory\GatewayServiceFactory; $config = new CoapGatewayAuthConfigDto( username: 'php-api-user', apiKey: 'YOUR_GENERATED_API_KEY', gatewayIp: '192.168.1.xxx', gatewaySecret: 'SECRET_FROM_GATEWAY_BOTTOM' ); $api = (new GatewayServiceFactory($config))();
Control a Light
// Get all lights $lights = $api->getLights(); foreach ($lights as $light) { echo "Found light: " . $light->getName() . " (" . $light->getReadableState() . ") "; // Switch on and dim to 80% if (!$light->isOn()) { $light->switchOn(); } $light->dim(80); }
Control a Group
$groups = $api->getGroups(); if ($groups->count() > 0) { $group = $groups->first(); echo "Controlling group: " . $group->getName() . " "; // Switch off the entire group $group->switchOff(); }
🛠 Features
- List all devices (Lights, Motion Sensors, Remotes)
- Control individual light bulbs (On/Off, Brightness, Color)
- Manage Groups/Rooms
- Docker support for CoAP communication
- Modern PHP 8.3+ features
📖 Documentation
For more detailed information, please refer to:
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
This project is licensed under the MIT License - see the LICENSE.md file for details.