Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Sdk Domoticz Bundle Laravel Package

dodev34/sdk-domoticz-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation

    composer require dodev34/sdk-domoticz-bundle
    

    Ensure your project uses Symfony 2.x/3.x (last release was 2017).

  2. Register the Bundle Add to app/AppKernel.php:

    new M12U\Bundle\Sdk\DomoticzBundle\M12USdkDomoticzBundle(),
    
  3. Configure Domoticz Connection Add to app/config/config.yml:

    m12_u_sdk_domoticz:
        username: YOUR_DOMOTICZ_USERNAME
        password: YOUR_DOMOTICZ_PASSWORD
        base_uri: http://<DOMOTICZ_IP>:8080
    

    Verify Domoticz has a user with API access enabled.

  4. First Use Case: Fetch Sunrise/Sunset Inject the service and call:

    $provider = $this->get('m12u.sdk.domoticz.provider_proxy');
    $command = $provider->getClient('command');
    $sunTimes = $command->getSunRiseSet();
    

Implementation Patterns

Workflows

  1. Device Management

    • Fetch all devices:
      $deviceClient = $provider->getClient('device');
      $devices = $deviceClient->getDevices();
      
    • Retrieve a specific device’s status:
      $device = $deviceClient->getDevice(DEVICE_ID);
      
  2. Light/Switch Control

    • Toggle a light:
      $command = $provider->getClient('command');
      $command->switchLight(DEVICE_ID, true/false);
      
    • Adjust brightness (if supported):
      $command->setColbrightnessValue(DEVICE_ID, 50); // 0-100
      
  3. Logging

    • Add debug/log messages to Domoticz:
      $command->addLogMessage("System rebooted at " . date('Y-m-d H:i:s'));
      

Integration Tips

  • Error Handling: Wrap API calls in try-catch blocks. The bundle returns JSON responses like {"status":"OK"} or {"status":"ERROR"}.
  • Dependency Injection: Prefer constructor injection for the provider_proxy service in controllers/services.
  • Caching: Cache frequent calls (e.g., getDevices()) using Symfony’s cache layer if Domoticz updates are infrequent.
  • Async Tasks: Use Symfony’s Messenger component to queue long-running operations (e.g., bulk device updates).

Gotchas and Tips

Pitfalls

  1. Deprecated Symfony Version

    • The bundle was last updated in 2017 for Symfony 2.x/3.x. Test thoroughly on newer versions (e.g., Symfony 5+ may require compatibility layers).
    • Workaround: Use a wrapper service or fork the bundle for modern Symfony.
  2. No Rate Limiting

    • Domoticz may throttle rapid API calls. Implement exponential backoff in your code:
      try {
          $result = $command->switchLight($id, $state);
      } catch (\Exception $e) {
          if (strpos($e->getMessage(), 'timeout') !== false) {
              sleep(2); // Retry after delay
          }
      }
      
  3. Undocumented Responses

    • Some methods (e.g., switchLight) lack clear return-value docs. Inspect raw responses:
      var_dump($command->switchLight($id, true)); // Check structure
      
  4. Base URI Quirks

    • Ensure base_uri includes the port (e.g., :8080) and no trailing slash. Test with:
      base_uri: http://192.168.1.100:8080/
      

Debugging

  • Enable API Debugging in Domoticz: Navigate to Settings > Advanced and enable "Enable API" and "Verbose API logging".
  • Log Raw Requests: Extend the bundle’s client to log requests/responses:
    $client = $provider->getClient('command');
    $client->setLogger($this->get('logger')); // Requires custom extension
    

Extension Points

  1. Custom Commands

    • Extend the bundle by adding new methods to the DomoticzClient class (requires modifying the bundle or creating a decorator service).
  2. Authentication

    • Override the default auth by implementing a custom Authenticator service and binding it to the bundle’s authenticator tag.
  3. Response Transformers

    • Use Symfony’s response_transformer to normalize responses:
      # config/services.yml
      services:
          app.domoticz.response_transformer:
              class: App\Service\DomoticzResponseTransformer
              tags: [m12u.sdk.domoticz.response_transformer]
      
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky