Jump to content
🌟 NEW Shelly Products Reveal Video! 🌟 NEUE Shelly-Produkte-Enthüllungsvideo! 🌟 ×
NOTICE / HINWEIS: iOS 18 Update and Today Widgets ×

Dimitar

Administrators
  • Posts

    428
  • Joined

  • Letzter Besuch

  • Days Won

    124

Everything posted by Dimitar

  1. Example how to read data from 3 Pro EM meters measuring the consumption on the 3 different zones and script which is run on Pro3EM with ADD-ON to EV Charger which disconnects (EV charging) for 30 min if the total power (represented by the consuming value on the right of the picture) is above a certain value. A JScript which can do that: // Configuration var deviceIPs = ['192.168.3.102', '192.168.3.246', '192.168.0.240']; // Add your device IPs here const switchOff = 2000 ; // Total power in W above this device will switch off output // Function to read data from a single Shelly Pro3EM function readEMData(ip, callback) { Shelly.call( "http.get", { url: "http://" + ip + "/rpc/EM.GetStatus?id=0" }, function (response, error_code, error_message) { if (response && response.message && response.code === 200) { var data = JSON.parse(response.body); var total_power = Math.round(data.total_aprt_power); callback(null, total_power); // Pass the total power to the callback } else { callback("Error: " + response.message, null); } } ); } // Function to calculate the total power from multiple devices function calculateTotalPower(ips) { var totalPower = 0; var count = 0; ips.forEach(function(ip) { readEMData(ip, function(err, power) { if (err) { print(err); // Handle the error, for example by logging it } else { totalPower += power; } count++; // Check if all requests are processed if (count === ips.length) { print("Total power: " + totalPower + " W"); if (totalPower > switchOff) { Shelly.call("Switch.set", {'id': 100, 'on': false}); print("Switch OFF!"); } } }); }); } // Execution: Timer.set(5000 /* ms */, true /* repeating */, function () { calculateTotalPower(deviceIPs); } ); Then you need to set Auto-ON in the Add-on relay: As a last step do not forget to set a script to start when device boot. With firmware 1.4, All pro devices will support virtual components. This will allow to monitor total consumption from the Shelly App and control the max power. I will update this script when this new feature are available.
  2. Update your device to fw 1.30 and then try again.
  3. With firmware 1.3+ we open a new world of possible integration. Now with Gen3 devices (Mini and soon Plus/Pro) you can control any 3th party device if they have API using Virtual components and JScripts. You can have local and cloud scenes based on Virtual devices values and changes. As example I can control and automate my EV charger with Virtual devices and JScript executed on Shelly Mini PM. Charging power are balanced based of Pro 3EM data for the house consumption. Soon we will add also allow historical data to be stored in the cloud.
  4. until
    Shelly X - the next step!
  5. You will have it to end of the months! We just finish testing them.
  6. In next firmware release we implement a filtering which solve such a problems. You will have it in 2 weeks.
  7. There is a way using BLU H&T and scripting. This will work without internet, but need more experience and not easy to be maintenanced.
  8. No you can't execute NETCAT command inside a Shelly Dimmer.
  9. All Gen3 devices are based on Shelly-C3F8 MCU. The Shelly-C38F are fully compatible with ESP32-C3, but with build-in more Flash and RAM which allow to save space into devices and give us possibility to add more features.
  10. Thart's should be easy with chatGPT, just paste one example and ask him to create it.
  11. We working on that and soon such a option will be added.
  12. Dimitar

    Something went wrong!

    Hello, this is outdated information, we have fix this problem already.
  13. Hello, Google do not support Gas Sensors yet. This is the reason to not see as a part of your devices in Google Home.
  14. And it's done. Tuya enabled Air-conditioner connected to HA with Tuya Integration and controlled from Shelly App via Shelly Gen3 device. Crazy! END TO END REACTION TIME < 1 SEC 🙂 You can see what Virtual components must be created. This is the script: // Replace these with your actual Home Assistant URL and access token let homeAssistantUrl = 'IP:port'; let accessToken = "ACCESS Token"; let entityId = 'Air.conditioner.ID'; // Replace with the actual entity ID const headers = { "Authorization": "Bearer " + accessToken, "Content-Type": "application/json", }; const url = homeAssistantUrl + "api/states/" + entityId; function checkStatus() { Shelly.call("http.request", { method: "GET", url: url, headers: headers }, function (response, error_code, error_message) { if (response.code === 200 && response.body) { let responseBody = JSON.parse(response.body); if (responseBody.hasOwnProperty('state')) { let state = responseBody.state; print("state: " + state); Shelly.call("enum.set", { id: 200, value: state }); } // Print 'current_temperature' and 'temperature' from attributes if (responseBody.attributes) { if (responseBody.attributes.hasOwnProperty('current_temperature')) { let currenttemp = JSON.stringify(responseBody.attributes.current_temperature); print("current_temperature: " + currenttemp); Shelly.call("number.set", { id: 200, value: currenttemp }); } if (responseBody.attributes.hasOwnProperty('temperature')) { let targettemp = JSON.stringify(responseBody.attributes.temperature); print("temperature: " + targettemp); Shelly.call("number.set", { id: 201, value: targettemp }); } } } else { // Handle errors print("Error Code: " + error_code + " - Message: " + error_message); } }); } // Function to change the temperature function setTemperature(newTemp) { const temperatureUrl = homeAssistantUrl + "api/services/climate/set_temperature"; Shelly.call("http.request", { method: "POST", url: temperatureUrl, headers: headers, body: JSON.stringify({ entity_id: entityId, temperature: newTemp }) }, function (response, error_code, error_message) { if (response && response.code === 200) { print("Temperature set to " + newTemp); } else { print("Error setting temperature - Code: " + error_code + " - Message: " + error_message); } }); } function setHvacMode(mode) { const hvacModeUrl = homeAssistantUrl + "api/services/climate/set_hvac_mode"; Shelly.call("http.request", { method: "POST", url: hvacModeUrl, headers: headers, body: JSON.stringify({ entity_id: entityId, hvac_mode: mode }) }, function (response, error_code, error_message) { if (response && response.code === 200) { print("HVAC mode set to " + mode); } else { print("Error setting HVAC mode - Code: " + error_code + " - Message: " + error_message); } }); } Shelly.addStatusHandler(function(event) { // print (event.component); if (event.component === "enum:200") { let newmode = Shelly.getComponentStatus("enum", 200)["value"]; setHvacMode(newmode); } if (event.component === "number:201") { let newTemp = Shelly.getComponentStatus("number", 201)["value"]; setTemperature(newTemp); } }); Timer.set( /* number of miliseconds */ 5000, /* repeat? */ true, /* callback */ checkStatus ); Enjoy
  15. Interesting script I make today. You can use HomeAssistant to unify App access to any device ZigBee, Tuya, Thread in all integrations and you then you can control device from Shelly App. Still working on it but hope during Xmas will be ready. You are welcome to comment, I may open a github repository where everyone can commit and make changes.
  16. very good, you can control brightness with num components, 0% can swhich them off, any > 0% can switch them on and set a brightness.
  17. Will bring up this question to developers, and hopefully they will agree with you and add them.
  18. Then status will be very very long and cannot be send because limitations. You need to check components and then read them if there is.
  19. @Lyubomir Petrov Please post your script for Tesla Charger. Benefits: Load balancing , Choose proper type for charging, Limit current depends of house consumption.
  20. If someone has experience with Sonoff local API, can make a script which control it with virtual component.
  21. If someone has experience with Tuya cloud, will be interesting to make a script which control Tuya Device.
  22. This script show how to use components to control 3th party device. Also show how dynamically to change label and icon of the virtual components. let CONFIG = { token: "My token", // Replace with your actual token ip: "192.168.3.111:8443", // Replace with the IP of your TaHoma Hub hub: "io://1218-1660-0674/", // hubID encodedhub: "io%3A%2F%2F1218-1660-0674%2F" }; let devices = [ { url: "15077540", label: "Livingroom central", virtualComponentId: 200 }, { url: "11848943", label: "Livingroom left", virtualComponentId: 201 }, { url: "13858948", label: "Kitchen balcony", virtualComponentId: 202 }, { url: "11743604", label: "Lower room left", virtualComponentId: 203 }, { url: "14407349", label: "Lower room right", virtualComponentId: 204 }, { url: "7827441", label: "Bassement left", virtualComponentId: 205 }, { url: "13430515", label: "Bassement right", virtualComponentId: 206 } // Add more devices as needed ]; let checkInterval = 1000; // Adjust as needed for processing time let currentDeviceIndex = 0; let initializationDone = false; function getDevices(device, isInitialization) { if (isInitialization === undefined) { isInitialization = false; } let url = "https://" + CONFIG.ip + "/enduser-mobile-web/1/enduserAPI/setup/devices/" + CONFIG.encodedhub + device.url + "/states"; let payload = { method: "GET", ssl_ca: "*", headers: { "Authorization": "Bearer " + CONFIG.token }, url: url }; Shelly.call("HTTP.REQUEST", payload, function(res, err_code, err_msg) { if (err_code) { console.log("Error getting device state: ", err_msg); return; } try { let deviceData = JSON.parse(res.body); let openClosedState, closureState, nameState, movingState; for (let i = 0; i < deviceData.length; i++) { if (deviceData[i].name === "core:OpenClosedState") { openClosedState = deviceData[i].value; } else if (deviceData[i].name === "core:ClosureState") { closureState = deviceData[i].value; } else if (deviceData[i].name === "core:NameState") { nameState = deviceData[i].value; } else if (deviceData[i].name === "core:MovingState") { movingState = deviceData[i].value; } } console.log(device.virtualComponentId, " Device Name: ", nameState, " ", openClosedState, " ", closureState , " ", movingState ); if (movingState === false) { Shelly.call("number.set", { id: device.virtualComponentId, value: closureState }); // icon(closureState, device.virtualComponentId); } if (isInitialization) { device.lastScriptPosition = closureState; // Set initial script position Shelly.call("number.set", { id: device.virtualComponentId, value: closureState }); icon(closureState, device.virtualComponentId); } else { if (movingState === false && device.wasMoving) { // Shelly.call("number.setconfig", { id: device.virtualComponentId, config: { name: device.label } }); icon(closureState, device.virtualComponentId); device.wasMoving = false; device.lastScriptPosition = closureState; // Update last position set by the script } else if (movingState === true) { device.wasMoving = true; // Shelly.call("number.setconfig", { id: device.virtualComponentId, config: { name: device.label + " MOVING" } }); } device.wasMoving = true; // } } } catch (e) { console.log("Error parsing response: ", e.message); } }); } function sendSetPositionCommand(position, device) { let commandUrl = "https://" + CONFIG.ip + "/enduser-mobile-web/1/enduserAPI/exec/apply"; let payload = { method: "POST", ssl_ca: "*", headers: { "Authorization": "Bearer " + CONFIG.token, "Content-Type": "application/json" }, url: commandUrl, body: JSON.stringify({ actions: [{ deviceURL: CONFIG.hub + device.url, commands: [{ name: "setClosure", parameters: [position] }] }] }) }; Shelly.call("HTTP.REQUEST", payload, function(res, err_code, err_msg) { if (err_code) { console.log("Error sending set position command: ", err_msg); return; } console.log("Set position command sent successfully: ", res.body); device.lastScriptPosition = position; // Update the last position set by the script }); } function icon(state, device) { if (state == 100) { iconurl = "http://minhome.net:8080/close.png" } else if (state == 0) { iconurl = "http://minhome.net:8080/open.png" } else { iconurl = "http://minhome.net:8080/halfopen.png" } const currentConfig = Shelly.getComponentConfig("number:" + device); currentConfig.ui.icon = iconurl; Shelly.call("Number.setconfig",{ id: device, config: currentConfig}); } function processNextDevice() { if (currentDeviceIndex >= devices.length) { currentDeviceIndex = 0; // Reset index for regular monitoring if (!initializationDone) { // Initialization completed, now start regular checks initializationDone = true; Timer.set(checkInterval, true, processNextDevice); // Set regular interval } return; // Exit function to avoid further execution in this cycle } let device = devices[currentDeviceIndex++]; getDevices(device, !initializationDone); // Pass true for initialization on first run if (!initializationDone) { // Use a shorter delay during initialization Timer.set(1000, false, processNextDevice); } } function initializeDevices() { currentDeviceIndex = 0; initializationDone = false; processNextDevice(); // Start the initialization process } Shelly.addStatusHandler(function(event) { if (event.component.indexOf("number:") === 0) { const componentId = parseInt(event.component.split(":")[1]); // Manually searching for the device in the array let device = null; for (let i = 0; i < devices.length; i++) { if (devices[i].virtualComponentId === componentId) { device = devices[i]; break; } } if (device) { const newPosition = event.delta.value; sendSetPositionCommand(newPosition, device); } } }); // Remove any additional Timer.set calls that are outside of your functions initializeDevices(); // Only call this once to start the process
  23. To work you need to create virtual same virtual components and then change ID in the script: let CONFIG = { accuWeatherAPIKEY: "YOUR KEY", weatherForecastEndpoint: "http://dataservice.accuweather.com/forecasts/v1/daily/1day/", weatherCurrentEndpoint: "http://dataservice.accuweather.com/currentconditions/v1/", locations: { Chicago: 348308, Miami: 347936, Mosfellsbaer: 190395, Sofia: 51097 }, }; let checkInterval = 10000; let timerID = null; let roomtemp = 0; //Event register Shelly.addEventHandler(function (event) { if (event.name === "script" && event.id === 5) { roomtemp = event.info.data.temp; Shelly.call("number.set", { id: 204, value: roomtemp }); print ("Room temp: " + roomtemp); } }); // Initialize timer outside the updateSettings function timerID = Timer.set(checkInterval, true, function() { // console.log("Checking weather"); let city = Shelly.getComponentStatus("enum", 200)["value"]; // print(city); TemperatureControlLocation(city); }); // Add a new endpoint to serve the form for updating the API key HTTPServer.registerEndpoint("update-api-key-form", function(req, res) { let htmlForm = '<html>' + '<head>' + '<style>' + 'body {' + 'background-color: #11191f;' + 'font-family: Arial, sans-serif;' + 'text-align: center;' + 'padding-top: 50px;' + '}' + 'form {' + 'background: #C0C0C0;' + 'padding: 20px;' + 'border-radius: 8px;' + 'box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);' + 'display: inline-block;' + 'margin-top: 20px;' + '}' + 'input, button {' + 'margin-bottom: 15px;' + 'padding: 10px;' + 'width: 250px;' + 'border-radius: 4px;' + 'border: 1px solid #ddd;' + '}' + 'button {' + 'background-color: #007bff;' + 'color: white;' + 'border: none;' + 'cursor: pointer;' + 'width: 270px;' + '}' + 'button:hover {' + 'background-color: #0056b3;' + '}' + 'label {' + 'display: block;' + 'margin-bottom: 5px;' + '}' + '</style>' + '</head>' + '<body>' + '<div style="text-align: center;">' + '<img src="https://info.shelly.cloud/wp-content/uploads/2021/07/shelly_logo_blue.png" alt="Shelly Logo" style="max-width: 200px; margin-top: 20px;">' + '</div>' + '<form id="updateForm" action="/script/1/update-settings" method="post" style="margin: auto; width: 300px;">' + '<label for="apikey"><img src="http://minhome.net:8080/key.png" alt="Key Icon" class="key-icon">AccuWeather API Key:</label>' + '<input type="text" id="apikey" name="apikey" value="' + CONFIG.accuWeatherAPIKEY + '"><br>' + '<label for="checkInterval">Check Interval (ms):</label>' + '<input type="number" id="checkInterval" name="checkInterval" value="' + checkInterval + '"><br>' + '<button type="submit">Update Settings</button>' + '</form>' + '<div style="margin-top: 20px;">' + '<a href="#" onclick="this.href=\'http://\' + window.location.hostname + \'/#\'" style="text-decoration: none; color: inherit;">' + '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home">' + '<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path>' + '<polyline points="9 22 9 12 15 12 15 22"></polyline>' + '</svg>' + '</a>' + '<a href="#" onclick="this.href=\'http://\' + window.location.hostname + \'/#/script/1\'" style="text-decoration: none; color: inherit; margin-left: 10px;">' + '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-code">' + '<polyline points="16 18 22 12 16 6"></polyline>' + '<polyline points="8 6 2 12 8 18"></polyline>' + '</svg>' + '</a>' + '</div>' + '</body>' + '</html>
  24. Virtual Components Virtual components are a special set of components that do not exist in the device initially and are created dynamically by the user. All virtual components use the general component interface, which means that they can be accessed using the standard methods <Component>.GetStatus, <Component>.GetConfig, and <Component>.SetConfig. Creation and deletion of components is done through 2 methods from the Virtual namespace. Virtual.Add to create new virtual component Virtual.Delete to remove existing virtual component There is a limit of 10 instances per device. IDs for these components start from 200 and are limited to 299. A list with all virtual components can be fetched only by Shelly.GetComponents method. Available virtual components: Boolean Number Text Enum Group Interaction with virtual components Virtual components are used to store/transfer data between scripts or runs, but they provide the possibility for the user to interact with them from the device's local home page. Each virtual group is added to the home page and is made up of cards. Each component has its own card with different inputs inside, based on the component's configuration. Methods Virtual.Add Request Properties: Property Type Description type string The type of virtual component to be created. Range of values: boolean, text, number, enum, group. Required config object Configuration to be used for the new component. Optional Response The result from calling this method is a JSON object, with an id on success, otherwise it will return an error. Received attributes: Property Type Description id number ID of the newly created component. Virtual.Delete Request Properties: Property Type Description key string Component key (in format <type>:<cid>, for example boolean:200). Required Response The result from calling this method is null on success, otherwise it will return an error. Examples Virtual.Add example Virtual.Add HTTP GET Request Virtual.Add Curl Request Virtual.Add Mos Request http://192.168.33.1/rpc/Virtual.Add?type="boolean" Response { "id": 200 } Virtual.Delete example Virtual.Delete HTTP GET Request Virtual.Delete Curl Request Virtual.Delete Mos Request http://192.168.33.1/rpc/Virtual.Delete?key="boolean:200" Response null Boolean The virtual Boolean component is used to store a true/false value. It uses Boolean as RPC namespace and has the following methods: Boolean.SetConfig to update the component's configuration Boolean.GetConfig to obtain the component's configuration Boolean.GetStatus to obtain the component's status Boolean.Set to update the component's value Methods Boolean.SetConfig Property Type Description id number Id of the component instance config object Configuration that the method takes Find more about the config properties in config section Boolean.GetConfig Properties: Property Type Description id number Id of the component instance Find the Boolean.GetConfig response properties in config section Boolean.GetStatus Properties: Property Type Description id number Id of the component instance Find more about the status response properties in status section Boolean.Set This method updates the value of the Boolean component. It can be used to trigger webhooks. More information about the events triggering webhooks available for this component can be found below. Request Parameters: Property Type Description id number Id of the component instance. Required value boolean For truthy value only true is accepted, everything else is parsed as false. Required Configuration The configuration of the Boolean component contains information about the default value, whether it should persist after reboot, and properties of how it will be rendered in the UI. To Get/Set the configuration of the Boolean component its id must be specified. Properties: Property Type Description id number Id of the component instance name string or null Name of the component instance persisted boolean true for the value to be persist, default false default_value boolean Value, applied on reboot if persisted is set to false ui object Properties of how the component will be rendered in the UI Property Type Description view string Specifies the type of card used for showing the component. Supported values: "" (empty string), button, toggle, label. icon string or null Allows setting custom icon for the component's card by providing an external hosted image via link. titles array of strings or null Allows setting custom titles for both (Truthy/Falsy) states. Item at index 0 is is used for the title when the value is set to false, at index 1 - for true, both are of type string. Default values are ["False", "True"] for view=button and ["Off", "On"] for view=toggle. buttonIcons array of strings or null Allows setting custom titles for both (Truthy/Falsy) states. Item at index 0 is is used for the url for icon shown when the value is set to false, at index 1 - for true, both are of type string. INFO "" (empty string): The component does not have a card; "button": Card with a button (value=true while holding, otherwise value=false); "toggle": Card with a toggle button (Changes its value on each hit); "label": Card showing the title for the value. Status The status of the Boolean component contains information about its current value, the timestamp for the value update, and the source of the last command. To obtain the status of the Boolean component its id must be specified. Properties: Property Type Description source string Source of the last command value boolean Value of the component last_update_ts number Unix timestamp for the value update Webhook Events Currently, there are two events related to the Boolean component that can trigger webhooks: boolean.true - produced when the value changes from false to true boolean.false - produced when the value changes from true to false Examples Boolean.SetConfig example Boolean.SetConfig HTTP GET Request Boolean.SetConfig Curl Request Boolean.SetConfig Mos Request http://192.168.33.1/rpc/Boolean.SetConfig?id=200&config={"name":"Gate status","ui":{"titles":["Close","Open"]}} Response { "restart_required": false } Boolean.GetConfig example Boolean.GetConfig HTTP GET Request Boolean.GetConfig Curl Request Boolean.GetConfig Mos Request http://192.168.33.1/rpc/Boolean.GetConfig?id=200 Response { "id": 200, "name": "Gate status", "ui": { "view": "label", "titles": [ "Close", "Open" ], "buttonIcons": [ "http://192.168.25.2:7999/icon_close.png", "http://192.168.25.2:7999/icon_open.png" ], "icon": "http://192.168.25.2:7999/icon_gate.png" }, "persisted": true, "default_value": false } Boolean.GetStatus example Boolean.GetStatus HTTP GET Request Boolean.GetStatus Curl Request Boolean.GetStatus Mos Request http://192.168.33.1/rpc/Boolean.GetStatus?id=200 Response { "value": true, "source": "rpc", "last_update_ts": 1700864253 } Boolean.Set example Boolean.Set HTTP GET Request Boolean.Set Curl Request Boolean.Set Mos Request http://192.168.33.1/rpc/Boolean.Set?id=200&value=true Response null Number The virtual Number component is used to store a numeric value. It uses Number as RPC namespace and has the following methods: Number.SetConfig to update the component's configuration Number.GetConfig to obtain the component's configuration Number.GetStatus to obtain the component's status Number.Set to update the component's value Methods Number.SetConfig Property Type Description id number Id of the component instance config object Configuration that the method takes Find more about the config properties in config section Number.GetConfig Properties: Property Type Description id number Id of the component instance Find the Number.GetConfig response properties in config section Number.GetStatus Properties: Property Type Description id number Id of the component instance Find more about the status response properties in status section Number.Set This method updates the value of the Number component. It can be used to trigger webhooks. More information about the events triggering webhooks available for this component can be found below. Request Parameters: Property Type Description id number Id of the component instance. Required value number String to be saved Required Configuration The configuration of the Number component contains information about the default value, whether it should persist after reboot, and properties of how it will be rendered in the UI. To Get/Set the configuration of the Number component its id must be specified. Properties: Property Type Description id number Id of the component instance name string or null Name of the component instance persisted boolean true for the value to be persist, default false default_value number Number, applied on reboot if persisted is set to false ui object Properties of how the component will be rendered in the UI Property Type Description view string Specifies the type of card used for showing the component. Supported values: "" (empty string), field, slider, progressbar, label. unit string Allows settings unit to the value, its appended after the value. step number Specifies the minimum value change for view=slider and view=field icon string or null Allows setting custom icon for the component's card by providing an external hosted image via link. INFO "" (empty string): The component does not have a card; "field": Card with a input field; "slider": Card showing a slider. "progressbar": Card showing progressbar. "label": Card showing the value. Status The status of the Number component contains information about its current value, the timestamp for the value update, and the source of the last command. To obtain the status of the Number component its id must be specified. Properties: Property Type Description source string Source of the last command value number Value of the component last_update_ts number Unix timestamp for the value update Webhook Events Currently, there are two events related to the Number component that can trigger webhooks: number.change - produced when the value changes. Examples Number.SetConfig example Number.SetConfig HTTP GET Request Number.SetConfig Curl Request Number.SetConfig Mos Request http://192.168.33.1/rpc/Number.SetConfig?id=200&config={"name":"Savings","min":0,"ui":{"view":"field","step":0.01,"unit":"$"}} Response { "restart_required": false } Number.GetConfig example Number.GetConfig HTTP GET Request Number.GetConfig Curl Request Number.GetConfig Mos Request http://192.168.33.1/rpc/Number.GetConfig?id=200 Response { "id": 200, "name": "Savings", "min": 0, "max": 999999999999999, "ui": { "view": "field", "unit": "$", "step": 0.01, "icon": null }, "persisted": false, "default_value": 0 } Number.GetStatus example Number.GetStatus HTTP GET Request Number.GetStatus Curl Request Number.GetStatus Mos Request http://192.168.33.1/rpc/Number.GetStatus?id=200 Response { "value": 25.6, "source": "rpc", "last_update_ts": 1700864253 } Number.Set example Number.Set HTTP GET Request Number.Set Curl Request Number.Set Mos Request http://192.168.33.1/rpc/Number.Set?id=200&value=25.6 Response null Text The virtual Text component is used to store a string value. It uses Text as RPC namespace and has the following methods: Text.SetConfig to update the component's configuration Text.GetConfig to obtain the component's configuration Text.GetStatus to obtain the component's status Text.Set to update the component's value Methods Text.SetConfig Property Type Description id number Id of the component instance config object Configuration that the method takes Find more about the config properties in config section Text.GetConfig Properties: Property Type Description id number Id of the component instance Find the Text.GetConfig response properties in config section Text.GetStatus Properties: Property Type Description id number Id of the component instance Find more about the status response properties in status section Text.Set This method updates the value of the Text component. It can be used to trigger webhooks. More information about the events triggering webhooks available for this component can be found below. Request Parameters: Property Type Description id number Id of the Text component instance. Required value string String to be saved Required Configuration The configuration of the Text component contains information about the default value, whether it should persist after reboot, and properties of how it will be rendered in the UI. To Get/Set the configuration of the Text component its id must be specified. Properties: Property Type Description id number Id of the component instance name string or null Name of the component instance persisted boolean true for the value to be persist, default false default_value string String, applied on reboot if persisted is set to false ui object Properties of how the component will be rendered in the UI Property Type Description view string Specifies the type of card used for showing the component. Supported values: "" (empty string), field, image, label. icon string or null Allows setting custom icon for the component's card by providing an external hosted image via link. INFO "" (empty string): The component does not have a card; "field": Card with a input field; "image": Card that interprets the current value as url and shows its content (used for displaying images); "label": Card showing the title for the value. Status The status of the Text component contains information about its current value, the timestamp for the value update, and the source of the last command. To obtain the status of the Text component its id must be specified. Properties: Property Type Description source string Source of the last command value string Value of the component last_update_ts number Unix timestamp for the value update Webhook Events Currently, there are two events related to the Text component that can trigger webhooks: text.change - produced when the value changes. Examples Text.SetConfig example Text.SetConfig HTTP GET Request Text.SetConfig Curl Request Text.SetConfig Mos Request http://192.168.33.1/rpc/Text.SetConfig?id=200&config={"name":"City name","ui":{"view":"label"}} Response { "restart_required": false } Text.GetConfig example Text.GetConfig HTTP GET Request Text.GetConfig Curl Request Text.GetConfig Mos Request http://192.168.33.1/rpc/Text.GetConfig?id=200 Response { "id": 200, "name": "", "max_len": 255, "ui": { "name": "City name", "view": "label" }, "persisted": false, "default_value": "Sofia" } Text.GetStatus example Text.GetStatus HTTP GET Request Text.GetStatus Curl Request Text.GetStatus Mos Request http://192.168.33.1/rpc/Text.GetStatus?id=200 Response { "value": "Miami", "source": "rpc", "last_update_ts": 1700864253 } Text.Set example Text.Set HTTP GET Request Text.Set Curl Request Text.Set Mos Request http://192.168.33.1/rpc/Text.Set?id=200&value="Miami" Response null Enum The virtual Enum component is used to store a set of constant values. It uses Enum as RPC namespace and has the following methods: Enum.SetConfig to update the component's configuration Enum.GetConfig to obtain the component's configuration Enum.GetStatus to obtain the component's status Enum.Set to update the component's value Methods Enum.SetConfig Property Type Description id number Id of the component instance config object Configuration that the method takes Find more about the config properties in config section Enum.GetConfig Properties: Property Type Description id number Id of the component instance Find the Enum.GetConfig response properties in config section Enum.GetStatus Properties: Property Type Description id number Id of the component instance Find more about the status response properties in status section Enum.Set This method updates the value of the Enum component. It can be used to trigger webhooks. More information about the events triggering webhooks available for this component can be found below. Request Parameters: Property Type Description id number Id of the component instance. Required value string or null One of the items from options or null Required Configuration The configuration of the Enum component contains information about the default value, whether it should persist after reboot, and properties of how it will be rendered in the UI. To Get/Set the configuration of the Enum component its id must be specified. Properties: Property Type Description id number Id of the component instance name string or null Name of the component instance persisted boolean true for the value to be persist, default false default_value number or string or null Option selected on reboot if persisted is set to false options array of options of type number or string String values that can be set for this enum instance Required ui object Properties of how the component will be rendered in the UI Property Type Description view string Specifies the type of card used for showing the component. Supported values: "" (empty string), dropdown, label. titles object Allows defining custom titles for each option in format (option: title). images object Allows defining custom images for each option in format (option: image url). Only for view=label. icon string or null Allows setting custom icon for the component's card by providing an external hosted image via link. INFO "" (empty string): The component does not have a card; "dropdown": Card with a dropdown field; "label": Card showing an image if defined, otherwise the title. Status The status of the Enum component contains information about its current value, the timestamp for the value update, and the source of the last command. To obtain the status of the Enum component its id must be specified. Properties: Property Type Description source string Source of the last command value string or null One of the items from options or null last_update_ts number Unix timestamp for the value update Webhook Events Currently, there are two events related to the Enum component that can trigger webhooks: enum.change - produced when the value changes. Examples Enum.SetConfig example Enum.SetConfig HTTP GET Request Enum.SetConfig Curl Request Enum.SetConfig Mos Request http://192.168.33.1/rpc/Enum.SetConfig?id=200&config={"name":"Light to toggle","options":["kitchen_light","bedroom_light","bathroom_light","entrance_light"],"ui":{"titles":{"kitchen_light":"Kitchen light","bedroom_light":"Bedroom light","bathroom_light":"Bathroom light","entrance_light":"Entrance light"}}} Response { "restart_required": false } Enum.GetConfig example Enum.GetConfig HTTP GET Request Enum.GetConfig Curl Request Enum.GetConfig Mos Request http://192.168.33.1/rpc/Enum.GetConfig?id=200 Response { "id": 200, "name": "", "options": [ "kitchen_light", "bedroom_light", "bathroom_light", "entrance_light" ], "ui": { "view": "", "titles": { "kitchen_light": "Kitchen light", "bedroom_light": "Bedroom light", "bathroom_light": "Bathroom light", "entrance_light": "Entrance light" }, "icon": "", "images": {} }, "persisted": true, "default_value": "kitchen_light" } Enum.GetStatus example Enum.GetStatus HTTP GET Request Enum.GetStatus Curl Request Enum.GetStatus Mos Request http://192.168.33.1/rpc/Enum.GetStatus?id=200 Response { "value": "kitchen_light", "source": "rpc", "last_update_ts": 1700864253 } Enum.Set example Enum.Set HTTP GET Request Enum.Set Curl Request Enum.Set Mos Request http://192.168.33.1/rpc/Enum.Set?id=200&value="kitchen_light" Response null Group The virtual Group component is used to store a list of components keys. It uses Group as RPC namespace and has the following methods: Group.SetConfig to update the component's configuration Group.GetConfig to obtain the component's configuration Group.GetStatus to obtain the component's status Group.Set to update the component's value Methods Group.SetConfig Property Type Description id number Id of the component instance config object Configuration that the method takes Find more about the config properties in config section Group.GetConfig Properties: Property Type Description id number Id of the component instance Find the Group.GetConfig response properties in config section Group.GetStatus Properties: Property Type Description id number Id of the component instance Find more about the status response properties in status section Group.Set This method updates the value of the Group component. Request Parameters: Property Type Description id number Id of the component instance. Required value array of strings List of valid components keys (in format <type>:<cid>, e.g. boolean:200) Required Configuration The configuration of the Group component contains information about the default value, whether it should persist after reboot, and properties of how it will be rendered in the UI. To Get/Set the configuration of the Group component its id must be specified. Properties: Property Type Description id number Id of the component instance name string or null Name of the component instance ui object Properties of how the component will be rendered in the UI Status The status of the Group component contains information about its current value, the timestamp for the value update, and the source of the last command. To obtain the status of the Group component its id must be specified. Properties: Property Type Description source string Source of the last command value array of strings List of valid components keys (in format <type>:<cid>, e.g. boolean:200) last_update_ts number Unix timestamp for the value update Examples Group.SetConfig example Group.SetConfig HTTP GET Request Group.SetConfig Curl Request Group.SetConfig Mos Request http://192.168.33.1/rpc/Group.SetConfig?id=200&config={"name":"Thermostat"} Response { "restart_required": false } Group.GetConfig example Group.GetConfig HTTP GET Request Group.GetConfig Curl Request Group.GetConfig Mos Request http://192.168.33.1/rpc/Group.GetConfig?id=200 Response { "id": 200, "name": "Thermostat" } Group.GetStatus example Group.GetStatus HTTP GET Request Group.GetStatus Curl Request Group.GetStatus Mos Request http://192.168.33.1/rpc/Group.GetStatus?id=200 Response { "value": [ "boolean:200", "enum:200" ], "source": "rpc", "last_update_ts": 1700864253 } Group.Set example Group.Set HTTP GET Request Group.Set Curl Request Group.Set Mos Request http://192.168.33.1/rpc/Group.Set?id=200&value=["boolean:200","enum:200"] Response null
×
×
  • Erstelle neue...