{"id":20035857,"url":"https://github.com/igor-ad/vkmodule-socket","last_synced_at":"2025-07-09T13:08:09.594Z","repository":{"id":262501296,"uuid":"887200360","full_name":"Igor-ad/vkmodule-socket","owner":"Igor-ad","description":"PHP driver library for use with VKmodule 'Socket-N' type electronic devices.","archived":false,"fork":false,"pushed_at":"2025-07-07T20:44:01.000Z","size":371,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-09T13:06:38.123Z","etag":null,"topics":["api-client","cli-app","client","library-automation","library-management","php-driver","php8","remote-control","smart-home","vkmodule"],"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/Igor-ad.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,"zenodo":null}},"created_at":"2024-11-12T10:40:39.000Z","updated_at":"2025-07-07T20:44:04.000Z","dependencies_parsed_at":"2024-11-27T13:29:01.154Z","dependency_job_id":"5b38a16c-5b8b-4dd6-8bd6-4ac776bf3e8a","html_url":"https://github.com/Igor-ad/vkmodule-socket","commit_stats":null,"previous_names":["igor-ad/vkmodule-socket"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Igor-ad/vkmodule-socket","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Igor-ad%2Fvkmodule-socket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Igor-ad%2Fvkmodule-socket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Igor-ad%2Fvkmodule-socket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Igor-ad%2Fvkmodule-socket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Igor-ad","download_url":"https://codeload.github.com/Igor-ad/vkmodule-socket/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Igor-ad%2Fvkmodule-socket/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264465846,"owners_count":23612580,"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":["api-client","cli-app","client","library-automation","library-management","php-driver","php8","remote-control","smart-home","vkmodule"],"created_at":"2024-11-13T10:09:30.628Z","updated_at":"2025-07-09T13:08:09.587Z","avatar_url":"https://github.com/Igor-ad.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## VKmodule PHP Socket-client Library \nPHP driver library for use with VKmodule 'Socket-N' type electronic devices. Control and monitoring modules via the Ethernet network.\n\n**The logo and trademark \"VKmodule\" belong to the manufacturer of the devices, the company \"VKmodule\".**\n\n[![VKmodule Socket PHP client Library](https://vkmodule.com.ua/images/vkmodule_logo.png)](https://vkmodule.com.ua/Ethernet_ua.html)\n\n\n![License MIT](https://img.shields.io/badge/License-MIT-blue)\n[![Supported PHP Versions](https://img.shields.io/badge/PHP-8.2,%208.3,%208.4-blue)](https://github.com/Igor-ad/VKmodule-php-client-library/)\n![GitHub release](https://img.shields.io/badge/Release-Beta_0.9.8-green)\n\n\nHome page of the manufacturer of Socket-N controller modules -\nhttps://vkmodule.com.ua/Ethernet_ua.html\n\n## Table of Contents.\n   * [VKmodule PHP Socket-client Library](README.md)\n   * [Table of Contents](#table-of-contents)\n   * [Description](#description-of-library)\n     * [System requirements](#system-requirements)\n     * [Compatibility with devices](#compatibility-with-devices)\n     * [Protocols](#protocols-tcpip-http)\n     * [System Configuration](#system-configuration)\n     * [Installation](#installation)\n   * [CLI](#cli)\n     * [Available console command](#available-console-commands)\n       * [Common console commands](#common-console-commands)\n         * [Example for a single-module system](#example-for-a-single-module-system)\n         * [Example for a multi-module system](#examples-of-console-commands-with-a-query-string-for-a-multi-module-system)\n       * [Module control commands](#module-control-commands)\n   * [API](#api)\n     * [Api console command](#api-commands)\n   * [Tests](#unit-tests) \n\n## Description of library.\n\nOpen-source PHP library\n\n#### System requirements.\nPHP 8.2 and higher, Composer, cron or Cli.\n\nThe library's API can be used as part of the framework or with any HTTP server.\n\n#### Compatibility with devices.\n\nCurrently, the library supports interaction with modules of the following types:\n* Socket-1\n* Socket-2\n* Socket-2W\n* Socket-3\n* Socket-4\n* Socket-5\n* Socket-Giant\n\nThe hardware modules are configured as a SERVER, the library operates as a CLIENT.    \n\nWorking with modules is not yet supported:\n\n* EM-marine card readers (VRD-E)\n\n#### Protocols (TCP/IP, HTTP).\n\nThe above modules are equipped with a built-in HTTP server for configuring operating modes and network parameters. Therefore, the library does not currently implement the HTTP protocol. Only the TCP/IP protocol is used.\n\n#### System configuration.\n\nTo control a system with a single-module implementation, it is enough to specify the module parameters in the configuration file -\n`./config/vk_module.php`.\nWhen simultaneously managing different modules in a multi-module system, the module parameters must be sent in each request as a JSON string, for example -\n\n```'{\"module\":{\"host\":\"192.168.4.191\",\"port\":9761,\"type\":\"Socket-2\"}}'```\nOtherwise, the default module parameters specified in the configuration file will be accepted.\n#### Installation.\nThe library can be used by simply copying the files to the working directory. When using\nas a cron worker or from the command line, an HTTP server is not required.\n\nInit application:\n```\nmkdir projects\ncd projects\ngit clone https://github.com/Igor-ad/vkmodule-socket.git\ncd ./vkmodule-socket\nchmode +x ./console/cli.php\ncomposer install\ncomposer dump-autoload\n```\n\nThe name and directory of the log file can be changed in the configuration file.\n\n\n\n## CLI\n\nThe executable file for console commands is  `./console/cli.php`\n\nSyntax: `./console/cli.php \u003ccommand\u003e \u003cJSON query string (optional)\u003e`\n\nCommand and module response debug logs will be written to the log file `./log/socket_module.log`\n\n### Available console commands.\n\n### Common console commands.\n\nGeneral-purpose commands are supported by all module types and do not require a query string for a single-module system. Module parameters for a single-module system are retrieved from the configuration file - `./config/vk_module.php`\n\n```\nconnection\nfirmware\nreboot\nuid\n```\n\n#### Example for a single-module system:\n```\n# Checking the connection to the module\n./console/cli.php connection\n\n# Extracting information about the module firmware version\n./console/cli.php firmware\n\n# Module Reboot command\n./console/cli.php reboot\n\n# Command to get a unique module identifier\n./console/cli.php uid\n```\n\n#### Examples of console commands with a query string for a multi-module system.\nTwo parameters are passed to the executable file`./console/cli.php`, the first parameter is the command name, the second parameter is the query string in JSON format. Controller parameters are passed in the query string.\n\nCommand - Connection:\n```\n./console/cli.php connection '{\"module\":{\"host\":\"192.168.4.191\",\"port\":9761,\"type\":\"Socket-2\"}}'\n```\n\nResponse:\n```\n{\n    \"success\": true,\n    \"event\": {\n        \"id\": \"01\",\n        \"description\": \"CheckConnect\",\n        \"data\": {\n            \"status\": \"online\"\n        }\n    }\n}\n```\n\nCommand - Firmware:\n```\n./console/cli.php firmware '{\"module\":{\"host\":\"192.168.4.191\",\"port\":9761,\"type\":\"Socket-2\"}}' \n```\n\nResponse:\n```\n{\n    \"success\": true,\n    \"event\": {\n        \"id\": \"03\",\n        \"description\": \"GetFirmware\",\n        \"data\": {\n            \"controllerType\": \"Socket-3\",\n            \"version\": \"0000\",\n            \"firmwareType\": \"regular\",\n            \"firmware\": \"04000000\"\n        }\n    }\n}\n```\n\nCommand - Reboot:\n```\n./console/cli.php reboot '{\"module\":{\"host\":\"192.168.4.191\",\"port\":9761,\"type\":\"Socket-2\"}}'\n```\n\nResponse:\n```\n{\n    \"success\": true,\n    \"event\": {\n        \"id\": \"02\",\n        \"description\": \"RebootController\",\n        \"data\": null\n    }\n}\n```\n\nCommand - Uid:\n```\n./console/cli.php uid '{\"module\":{\"host\":\"192.168.4.191\",\"port\":9761,\"type\":\"Socket-3\"}}' \n```\n\nResponse:\n```\n{\n    \"success\": true,\n    \"event\": {\n        \"id\": \"04\",\n        \"description\": \"GetUid\",\n        \"data\": {\n            \"uid\": 873\n        }\n    }\n}\n```\n\n### Module control commands.\n\nCommands for control and monitoring of modules:\n```\n name of command     |  modules types support\t |  description\n_____________________|___________________________|_____________________________________\t\ncli_full_control **  | for all types of modules\t | any command by ID\ninput_analog         | Socket-2W only            | analog input voltage value\ninput_setup *        | Socket-(1,2,5,Giant)      | configure digital input \ninput_status *       | Socket-(1,2,5,Giant)      | digital input status\ninput_temperature0   | Socket-3 only             | sensor 0 temperature value\ninput_temperature1   | Socket-3 only             | sensor 1 temperature value\nrelay_control *      | Socket-(2,3,4,5,Giant)    | relay control\nrelay_group_control *| Socket-Giant only         | control all module relays\nrelay_off *          | Socket-(2,3,4,5,Giant)    | turn off relay\nrelay_on *           | Socket-(2,3,4,5,Giant)    | turn on relay \nstatus               | for all types of modules  | get the state of all inputs/outputs\n```\n#### Notes\n\n*_**The command requires sending a query string with data - the digital input or relay number and control parameters (optional).**_\n\n**_**The command requires sending the module command ID in the query string and knowledge of the module manufacturer's documentation**_.\n\n\nThe console command name corresponds to the command class name. You can write the console command name in both snake case and kebab case, as well as camel case and pascal case. For convenience, all console command names in this file are written in snake case.\n\n#### Example of console commands.\n\n\nCommand - FullControl:\n```\n./console/cli.php cli_full_control '{\"command\":{\"id\":\"43\",\"data\":{\"relay\":{\"relayNumber\":0,\"action\":1,\"interval\":30}}},\"module\":{\"host\":\"192.168.4.191\",\"port\":9761,\"type\":\"Socket-3\"}}'\n```\nResponse:\n```\n{\n    \"success\": true,\n    \"event\": {\n        \"id\": \"43\",\n        \"description\": \"Socket3RelayAction\",\n            \"relay\": {\n                \"relayNumber\": 0,\n                \"action\": 1,\n                \"interval\": 30\n            }\n    }\n}\n```\nOnly a complete and formatted query string:\n```\n{\n    \"command\": {\n        \"id\": \"43\",\n        \"data\": {\n            \"relay\": {\n                \"relayNumber\": 0,\n                \"action\": 1,\n                \"interval\": 30\n            }\n        }\n    },\n    \"module\": {\n        \"host\": \"192.168.4.191\",\n        \"port\": 9761,\n        \"type\": \"Socket-3\"\n    }\n}\n```\n\nCommand - InputSetup:\n```\n./console/cli.php input_setup '{\"command\":{\"data\":{\"input\":{\"inputNumber\":1,\"action\":1,\"antiBounce\":5}}}}'\n```\nResponse:\n```\n{\n    \"success\": true,\n    \"event\": {\n        \"id\": \"20\",\n        \"description\": \"SetInput\",\n        \"data\": {\n            \"input\": {\n                \"inputNumber\": 1,\n                \"triggerAction\": \"Open\",\n                \"antiBounce\": 5\n            }\n        }\n    }\n}\n```\nCommand - InputStatus:\n```\n./console/cli.php input_status '{\"command\":{\"data\":{\"input\":{\"inputNumber\":0}}}}'\n```\nResponse:\n```\n{\n    \"success\": true,\n    \"event\": {\n        \"id\": \"20\",\n        \"description\": \"SetInput\",\n        \"data\": {\n            \"input\": {\n                \"inputNumber\": 0,\n                \"triggerAction\": \"Open\",\n                \"antiBounce\": 4\n            }\n        }\n    }\n}\n```\n\nCommand - RelayControl:\n```\n./console/cli.php relay_control '{\"command\":{\"data\":{\"relay\":{\"relayNumber\":0,\"action\":1,\"interval\":5}}}}' \n```\nResponse:\n```\n{\n    \"success\": true,\n    \"event\": {\n        \"id\": \"22\",\n        \"description\": \"RelayAction\",\n        \"data\": {\n            \"relay\": {\n                \"relayNumber\": 0,\n                \"action\": \"On\",\n                \"interval\": 5\n            }\n        }\n    }\n}\n```\n\nCommand - RelayOn:\n```\n./console/cli.php relay_on '{\"command\":{\"data\":{\"relay\":{\"relayNumber\":0}}}}'\n```\nResponse:\n```\n{\n    \"success\": true,\n    \"event\": {\n        \"id\": \"22\",\n        \"description\": \"RelayAction\",\n        \"data\": {\n            \"relay\": {\n                \"relayNumber\": 0,\n                \"action\": \"On\",\n                \"interval\": 0\n            }\n        }\n    }\n}\n```\n\nCommand - RelayOff:\n```\n./console/cli.php relay_off '{\"command\":{\"data\":{\"relay\":{\"relayNumber\":0}}},\"module\":{\"host\":\"192.168.4.191\",\"port\":9761,\"type\":\"Socket-3\"}}'\n```\n\nResponse:\n```\n{\n    \"success\": true,\n    \"event\": {\n        \"id\": \"43\",\n        \"description\": \"Socket3RelayAction\",\n        \"data\": {\n            \"relay\": {\n                \"relayNumber\": 0,\n                \"action\": \"Off\",\n                \"interval\": 0\n            }\n        }\n    }\n}\n```\n\nCommand - InputTemperature0:\n```\n./console/cli.php input_temperature0 '{\"module\":{\"host\":\"192.168.4.191\",\"port\":9761,\"type\":\"Socket-3\"}}'\n```\nResponse:\n```\n{\n    \"success\": true,\n    \"event\": {\n        \"id\": \"41\",\n        \"description\": \"GetTemperatureSensor0\",\n        \"data\": {\n            \"input\": {\n                \"sensor0\": {\n                    \"sign\": \"+\",\n                    \"temperature\": 21\n                }\n            }\n        }\n    }\n}\n```\n\nCommand - InputTemperature1:\n```\n./console/cli.php input_temperature1 '{\"module\":{\"host\":\"192.168.4.191\",\"port\":9761,\"type\":\"Socket-3\"}}'\n```\nResponse:\n```\n{\n    \"success\": true,\n    \"event\": {\n        \"id\": \"42\",\n        \"description\": \"GetTemperatureSensor1\",\n        \"data\": {\n            \"input\": {\n                \"sensor1\": {\n                    \"sign\": \"+\",\n                    \"temperature\": 28\n                }\n            }\n        }\n    }\n}\n```\n\nCommand - Status\n```\n./console/cli.php status '{\"module\":{\"host\":\"192.168.4.191\",\"port\":9761,\"type\":\"Socket-3\"}}'\n```\nResponse:\n```\n{\n    \"success\": true,\n    \"event\": {\n        \"id\": \"44\",\n        \"description\": \"Socket3GetAllStatus\",\n        \"data\": {\n            \"input\": {\n                \"sensor0\": {\n                    \"sign\": \"+\",\n                    \"temperature\": 21\n                },\n                \"sensor1\": {\n                    \"sign\": \"+\",\n                    \"temperature\": 31\n                }\n            },\n            \"relay\": {\n                \"relay0\": \"Off\",\n                \"relay1\": \"Off\"\n            }\n        }\n    }\n}\n```\n\nExample of recording in a log file:\n```\n2024-11-08 11:42:11 | pid: 24169 | info: Start |  \n2024-11-08 11:42:11 | pid: 24169 | info: {\"module\":{\"host\":\"192.168.4.191\",\"port\":9761,\"type\":\"Socket-3\"}} |  \n2024-11-08 11:42:11 | pid: 24169 | debug: {\"success\":true,\"event\":{\"id\":\"44\",\"description\":\"Socket3GetAllStatus\",\"data\":[\"15\",\"1f\",\"00\",\"00\"]}} | CommandToJson: {\"command\":{\"id\":\"44\",\"description\":\"Socket3GetAllStatus\",\"data\":null}} | HexCommandData:  \n2024-11-08 11:42:11 | pid: 24169 | info: ResponseToJson: {\"success\":true,\"event\":{\"id\":\"44\",\"description\":\"Socket3GetAllStatus\",\"data\":{\"input\":{\"sensor0\":{\"sign\":\"+\",\"temperature\":21},\"sensor1\":{\"sign\":\"+\",\"temperature\":31}},\"relay\":{\"relay0\":\"Off\",\"relay1\":\"Off\"}}}} |  \n2024-11-08 11:42:11 | pid: 24169 | info: End |   \n```\n\n## API\n\nFunctionally and in syntax, all API commands correspond to Cli commands.\n\nDifferences:\n* there is no recording of debugging information about the command and module response in the Log file;\n* all API commands return a JSON string - the result of parsing the module response;\n* all API command names have the prefix \"api_\" (\"Api\" for command classes);\n\n\nTo use the API as part of any framework or with any HTTP server, you can\nuse the example from the `./public/index_api.php` file.\nThe file accepts a request with two string parameters:\n1. cmd - command name;\n2. query - JSON query string (optional);\n\nThe query string is similar to the string for Cli commands.\n### Api commands\n\nCommon commands (supported by all modules):\n```\napi_connection\napi_firmware\napi_reboot\napi_uid\n```\nAPI commands for control and monitoring of modules:\n```\napi_full_control **\napi_input_analog\napi_input_setup *\napi_input_status *\napi_input_temperature0 \napi_input_temperature1\napi_relay_control *\napi_relay_group_control *\napi_relay_off *\napi_relay_on *\napi_status\n```\n[* Notes](#notes)\n\n### Unit Tests\n\nIn progress, coverage is about 80%.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figor-ad%2Fvkmodule-socket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figor-ad%2Fvkmodule-socket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figor-ad%2Fvkmodule-socket/lists"}