{"id":16824101,"url":"https://github.com/gared/shelly-php-client","last_synced_at":"2025-03-22T03:31:46.765Z","repository":{"id":46212362,"uuid":"332443061","full_name":"Gared/shelly-php-client","owner":"Gared","description":"PHP client for Shelly devices","archived":false,"fork":false,"pushed_at":"2024-09-05T19:11:30.000Z","size":70,"stargazers_count":9,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-01T12:43:57.835Z","etag":null,"topics":["client","library","php","shelly"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Gared.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-24T12:24:11.000Z","updated_at":"2024-11-17T08:24:19.000Z","dependencies_parsed_at":"2024-10-28T18:15:47.613Z","dependency_job_id":null,"html_url":"https://github.com/Gared/shelly-php-client","commit_stats":{"total_commits":28,"total_committers":2,"mean_commits":14.0,"dds":0.0357142857142857,"last_synced_commit":"3020882544ae7ed8cbf165d20a62ec5e33623de7"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gared%2Fshelly-php-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gared%2Fshelly-php-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gared%2Fshelly-php-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gared%2Fshelly-php-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Gared","download_url":"https://codeload.github.com/Gared/shelly-php-client/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244181377,"owners_count":20411601,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","library","php","shelly"],"created_at":"2024-10-13T11:10:07.854Z","updated_at":"2025-03-22T03:31:46.134Z","avatar_url":"https://github.com/Gared.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# shelly-php-client \r\n\r\nYou can use this library to access the HTTP API of a Shelly device.\r\nYou can find the official API documentation [here](https://shelly-api-docs.shelly.cloud). \r\n\r\n## Installation\r\n\r\nUse composer\r\n```gitattributes\r\ncomposer require gared/shelly-php-client\r\n```\r\n\r\n## Getting started\r\n\r\n### Configure client\r\n\r\n```php\r\n$client = new \\ShellyClient\\HTTP\\Client('http://192.168.1.10');\r\n```\r\n\r\nIf you have configured login credentials you have to create the client like this:\r\n```php\r\n$client = new \\ShellyClient\\HTTP\\Client('http://shellyuser:secret@192.168.1.10');\r\n```\r\n\r\n### Get current power usage\r\n\r\n```php\r\n$meter = $client-\u003egetMeter(new \\ShellyClient\\Model\\Request\\MeterRequest());\r\n$power = $meter-\u003egetPower();\r\necho \"Current power usage: \" . $power;\r\n```\r\n\r\n### Power shelly plug \"on\"\r\n\r\n```php\r\n$client-\u003egetRelay(0, \\ShellyClient\\Model\\Request\\RelayRequest::TURN_ON);\r\n```\r\n\r\n\r\n### Full example\r\n\r\n```php\r\n// Create new client for one device\r\n$clientLightA = new \\ShellyClient\\HTTP\\Client('http://192.168.1.10', 'ShellyDeviceLightA');\r\n$clientLightB = new \\ShellyClient\\HTTP\\Client('http://192.168.1.20', 'ShellyDeviceLightB');\r\n\r\n// Switch device on and get relay data\r\n$relayRequest = new \\ShellyClient\\Model\\Request\\RelayRequest();\r\n$relayRequest-\u003esetRelayIndex(0);\r\n$relayRequest-\u003esetTurn(\\ShellyClient\\Model\\Request\\RelayRequest::TURN_ON);\r\n$relay = $clientLightA-\u003egetRelay($relayRequest);\r\n// check if timer has been set\r\nif ($relay-\u003ehasTimer()) {\r\n    // do something\r\n}\r\n\r\n$meter = $clientLightA-\u003egetMeter(new \\ShellyClient\\Model\\Request\\MeterRequest());\r\n// Get total power consumption in kW/h\r\n$kilowattHours = $meter-\u003egetTotalInKilowattHours();\r\n// Get last three watt per minute power consumption values\r\n$counters = $meter-\u003egetCounters();\r\n\r\n// Parallel call informations from device B\r\n$power = $clientLightB-\u003egetMeter(new \\ShellyClient\\Model\\Request\\MeterRequest())-\u003egetPower();\r\n// Get device name set above in construct\r\n$deviceNameDeviceB = $clientLightB-\u003egetDeviceName();\r\n// or use device name set in shelly device\r\n$deviceNameShelly = $clientLightB-\u003egetSettings(new \\ShellyClient\\Model\\Request\\SettingsRequest())-\u003egetName();\r\n```\r\n\r\n## Supported Platforms\r\n\r\n* You need at least PHP 8.1\r\n\r\n## Supported APIs\r\n| API                | Code                          |\r\n| -------------------|-------------------------------|\r\n| /light             | $client-\u003egetLight();          |\r\n| /meter             | $client-\u003egetMeter();          |\r\n| /relay             | $client-\u003egetRelay();          |\r\n| /settings          | $client-\u003egetSettings();       |\r\n| /settings/actions  | $client-\u003egetActions();        |\r\n| /settings/light    | $client-\u003egetSettingsLight();  |\r\n| /status            | $client-\u003egetStatus();         |","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgared%2Fshelly-php-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgared%2Fshelly-php-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgared%2Fshelly-php-client/lists"}