- Updated `shelly` class to support POST request handling (`sendPostRequest`) and server URL validation. - Adjusted `shelly_device_state` to handle object-based `status` and `settings`, adding a `populate` method for data initialization. - Added `shelly_device_switch` helper to manage switching operations via Shelly API. - Removed unused `api_url` property in `shelly` class. - Modified `shelly_i` interface with definitions for `requireValidServerUrl` and `sendPostRequest`.
51 lines
1.5 KiB
PHP
51 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace shelly;
|
|
require_once WD . '/modules/shelly/config/shelly_enabled_c.php';
|
|
require_once WD . '/modules/shelly/config/shelly_secret_key_c.php';
|
|
require_once WD . '/modules/shelly/config/shelly_server_url_c.php';
|
|
// Require helpers
|
|
require_once WD . '/modules/shelly/helpers/shelly_device_state.php';
|
|
require_once WD . '/modules/shelly/helpers/shelly_device_switch.php';
|
|
|
|
require_once WD . '/modules/shelly/helpers/shelly_request_body_get_states.php';
|
|
require_once WD . '/modules/shelly/helpers/shelly_response_body_get_states.php';
|
|
|
|
use shelly\config\shelly_server_url_c;
|
|
use shelly\config\shelly_enabled_c;
|
|
use shelly\config\shelly_secret_key_c;
|
|
use traits\module_config_t;
|
|
|
|
class shelly_c
|
|
{
|
|
use module_config_t;
|
|
|
|
/**
|
|
* The status of the shelly module
|
|
* @var shelly_enabled_c
|
|
*/
|
|
public shelly_enabled_c $enabled;
|
|
/**
|
|
* The secret key for the shelly module (API token)
|
|
* @var shelly_secret_key_c
|
|
*/
|
|
public shelly_secret_key_c $secret_key;
|
|
/**
|
|
* The server url for the shelly module
|
|
* @var shelly_server_url_c
|
|
*/
|
|
public shelly_server_url_c $server_url;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->setupConfig('shelly');
|
|
$this->allowUpdate([
|
|
shelly_enabled_c::class,
|
|
shelly_secret_key_c::class,
|
|
shelly_server_url_c::class
|
|
]);
|
|
$this->enabled = new shelly_enabled_c();
|
|
$this->secret_key = new shelly_secret_key_c();
|
|
$this->server_url = new shelly_server_url_c();
|
|
}
|
|
} |