Application Store documentation and sample app - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Application Store (https://forum.logicmachine.net/forumdisplay.php?fid=11) +--- Thread: Application Store documentation and sample app (/showthread.php?tid=85) Pages:
1
2
|
Application Store documentation and sample app - edgars - 28.09.2015 LogicMachine apps reference: https://kb.logicmachine.net/misc/apps/ Upload sample folder to data directory by using FTP with username apps (you have to enabled FTP and set password in System config first). After that you will have sample application visible on the main screen. Apps are written in JavaScript/HTML/CSS on client side and Lua on server side. RE: Application Store documentation and sample app - Hoang189 - 19.10.2015 (28.09.2015, 12:50)edgars Wrote: Please find attached short documentation on Apps and sample application. Upload sample folder to data directory by using FTP with username apps (you have to enabled FTP and set password in System config first). After that you will have sample application visible on the main screen.Help me, I have a smartwatch moto 360. How to connect and control smart home on this watch? Thank so much, RE: Application Store documentation and sample app - edgars - 21.10.2015 There should be a separate application created for Moto 360 integration. RE: Application Store documentation and sample app - Hoang189 - 22.10.2015 (21.10.2015, 13:04)edgars Wrote: There should be a separate application created for Moto 360 integration. Can you give me one a few applications can do it ? thank so much, RE: Application Store documentation and sample app - Pawel - 03.05.2016 When we can expect full documentation of apps on SE's HomeLYnk? Edgars's solution is ok, but dont explain all problems. RE: Application Store documentation and sample app - Erwin van der Zwart - 03.05.2016 (03.05.2016, 19:30)Pawel Wrote: When we can expect full documentation of apps on SE's HomeLYnk? Edgars's solution is ok, but dont explain all problems.Hi Pawel, From FW 1.5 we have access to the app engine, but we have no frontend like explained in Edgars docs. However you can build apps and store them on ftp and call them by direct url or embedded in a iframe. The option to download apps from the appstore is not available in homeLYnk yet. I don't think (not sure) we will publish documentation or application notes for current engine, and you have you wait for full version of the appstore. What problems do you mean? I created a few apps already and i think its working great, I realy like the server cliënt link and access to LUA, storage, DB, sockets, user libs from cliënt and already created some http API's in .lp to call server side LUA results direct from cliënt with javascript. Now anything you can think off can be created.. Please tell me your struggles (: BR, Erwin van der Zwart RE: Application Store documentation and sample app - Pawel - 04.05.2016 For example showing apps on homepage. I thought that I did something wrong. SE's application notes are very helpful when you try something new. I also don RE: Application Store documentation and sample app - Pawel - 04.05.2016 OK, i have "storage tab" app. I have to add via ftp this folder to "data" folder, and then i can see app on "http://IP/apps/data/storage/". But there's no data, and a lot of errors in browser. in code, a found in lua part "require('apps')" but You don't write anywhere to add some library. Also I have empty bootstrap.css, fontawesome.css and style.css files. I assume that i done something wrong, am i right? RE: Application Store documentation and sample app - Erwin van der Zwart - 04.05.2016 Hi Pawel, All the additional plugins / libs / css like bootstrap.css, fontawesome.css and style.css are not default available (yet) on homeLYnk. This is part of the full version that is still in development. You could add them manualy but you need to place them where they are expected by the app. (or change the locations in the app to your new location) I think that your issues are related to this, and your are trying to use fuctions that are not embedded yet... BR, Erwin RE: Application Store documentation and sample app - Pawel - 04.05.2016 so this is why i pleased for full documentation, because for now apps are grate for You, because you now limits and all functions. Can you give us some simple app, that works on HL, and consist of combination of lua script and html? RE: Application Store documentation and sample app - Erwin van der Zwart - 04.05.2016 Hi Pawel, To be honest, i'm just a early adopter and have never any documentation. By the time the documentation is finished and released i'm already playing with the new stuff (; I have just as much info as you do, i have all the information from Edgars sample document and by exploring the Apps that are available... I created some easy commands to give you an idea how to use it: ***************************************************************************** Run in LUA once to create a file with client IP resolve: dst = '/www/user/ip.lp' if not io.exists(dst) then io.writefile(dst, '<? print(ngx.var.remote_addr) ?>') end Or if you want to create new and/or overwrite excisting file dst = '/www/user/ip.lp' io.writefile(dst, '<? print(ngx.var.remote_addr) ?>') and run from custom javascript to get it: inside JS $.get( "/user/ip.lp", function( data ) { res = data.trim(); alert('Client IP is: ' + res); console.log(res); }); or you can test it direct from browser with: http://192.168.0.10/user/ip.lp ***************************************************************************** Run in LUA once to create a file with LUA system time table as JSON object: dst = '/www/user/systemtime.lp' if not io.exists(dst) then io.writefile(dst, [[<? require('json') require('genohm-scada') mydata = os.date('*t') mydata = json.encode(mydata) print(mydata) ?>]]) end Or if you want to create new and/or overwrite excisting file dst = '/www/user/systemtime.lp' io.writefile(dst, [[<? require('json') require('genohm-scada') mydata = os.date('*t') mydata = json.encode(mydata) print(mydata) ?>]]) and run from custom javascript to get it: inside JS $.get( "/user/systemtime.lp", function( data ) { res = data.trim(); alert('Systemtime seconds is: ' + res[0].sec); console.log(res); }); or you can test it direct from browser with: http://192.168.0.10/user/systemtime.lp ***************************************************************************** Run in LUA once to create a file with get storage script: dst = '/www/user/storage.lp' if not io.exists(dst) then io.writefile(dst, [[<? require('json') require('genohm-scada') mydata = storage.get('Sonos_Streams') mydata = json.encode(mydata) print(mydata) ?>]]) end Or if you want to create new and/or overwrite excisting file dst = '/www/user/storage.lp' io.writefile(dst, [[<? require('json') require('genohm-scada') mydata = storage.get('Sonos_Streams') mydata = json.encode(mydata) print(mydata) ?>]]) and run from custom javascript to get it: inside JS $.get( "/user/storage.lp", function( data ) { res = data.trim(); alert('Storage value is: ' + res); console.log(res); }); or you can test it direct from browser with: http://192.168.0.10/user/storage.lp ***************************************************************************** Run in LUA once to create a file with get storage script with variable storagename: dst = '/www/user/dynamicstorage.lp' if not io.exists(dst) then io.writefile(dst, [[<? require('json') require('socket.url') arg1 = socket.url.unescape( getvar('storagename1') ) arg2 = socket.url.unescape( getvar('storagename2') ) mydata1= storage.get(arg1) mydata2 = storage.get(arg2) datatable = {} table.insert(datatable, {storage1 = mydata1, storage2 = mydata2}) datatable = json.encode(datatable) print(datatable) ?>]]) end Or if you want to create new and/or overwrite excisting file dst = '/www/user/dynamicstorage.lp' io.writefile(dst, [[<? require('json') require('socket.url') arg1 = socket.url.unescape( getvar('storagename1') ) arg2 = socket.url.unescape( getvar('storagename2') ) mydata1= storage.get(arg1) mydata2 = storage.get(arg2) datatable = {} table.insert(datatable, {storage1 = mydata1, storage2 = mydata2}) datatable = json.encode(datatable) print(datatable) ?>]]) and run from custom javascript to get it: inside JS $.get( "/user/dynamicstorage.lp?storagename1=storage1&storagename2=storage2", function( data ) { res = data.trim(); res = JSON.parse(res); console.log(res); }); or you can test it direct from browser with: http://192.168.0.10/user/dynamicstorage.lp ***************************************************************************** Run in LUA once to create a file with get db data script: dst = '/www/user/database.lp' if not io.exists(dst) then io.writefile(dst, [[<? require('json') require('genohm-scada') require('dbenv') db = dbenv:new() query = 'SELECT * FROM objects' mydata = db:getall(query) mydata = json.encode(mydata) print(mydata) ?>]]) end Or if you want to create new and/or overwrite excisting file dst = '/www/user/database.lp' io.writefile(dst, [[<? require('json') require('genohm-scada') require('dbenv') db = dbenv:new() query = 'SELECT * FROM objects' mydata = db:getall(query) mydata = json.encode(mydata) print(mydata) ?>]]) and run from custom javascript to get it: inside JS $.get( "/user/database.lp", function( data ) { res = data.trim(); res = JSON.parse(res); console.log(res); }); or you can test it direct from browser with: http://192.168.0.10/user/database.lp You can also use require('user.yourlib') and use the funtion like we used to in LUA, this way if someone opens the .lp file he can't see te functions behind it, only the function call. Deleting .lp can also be done with LUA: os.remove("/www/user/ip.lp") os.remove("/www/user/systemtime.lp") os.remove("/www/user/storage.lp") os.remove("/www/user/dynamicstorage.lp") os.remove("/www/user/database.lp") or directly from APPS FTP folder User BR, Erwin RE: Application Store documentation and sample app - Pawel - 05.05.2016 thanks for nice explanation. I have question about using lua in html page. To use KNX specific HomeLYnk LUA function, is there necessary to import "genohm-scada" library? What with 'storage' function? Is there necessary to import some library to save variables in storage? I need to communicate my app with lua scripts. RE: Application Store documentation and sample app - admin - 05.05.2016 You can do require('apps'), it will include all required libraries RE: Application Store documentation and sample app - Pawel - 05.05.2016 (05.05.2016, 12:25)admin Wrote: You can do require('apps'), it will include all required libraries also with Schneider's HomeLYnk? RE: Application Store documentation and sample app - Erwin van der Zwart - 05.05.2016 Hi Pawel, I created a small HTTP API (as .lp) for you to save and get data from storage from javascript: 1) Create a LUA script and run once to create the storage.lp file that will act as HTTP API: dst = '/www/user/storage.lp' io.writefile(dst, [[<? require('apps') require('socket.url') action = socket.url.unescape( getvar('action') or 'none' ) storagename = socket.url.unescape( getvar('storagename') or 'none') format = socket.url.unescape( getvar('format') or 'string' ) storagevalue = socket.url.unescape( getvar('value') or '{}') if action == 'storageset' then if storagename ~= 'none' then if format == 'json' then storagevalue = json.decode(storagevalue) end storage.set(storagename, storagevalue) print('value saved to storage as ' .. format) end elseif action == 'storageget' then if storagename ~= 'none' then storagevalue = storage.get(storagename) storagevalue = json.encode(storagevalue) print(storagevalue) end end ?>]]) script.disable(_SCRIPTNAME) 2) Put this in your custom javascript: $(function() { // Save json data to storage with name 'mystoragename1' var jsondata = {"name":"Erwin van der Zwart","company":"Schneider Electric","country":"The Netherlands"} jsondata = JSON.stringify(jsondata); $.get( "/user/storage.lp?action=storageset&storagename=mystoragename1&format=json&value=" + jsondata, function( data ) { res = data.trim(); console.log(res); }); // Get json data from storage with name 'mystoragename1' $.get( "/user/storage.lp?action=storageget&storagename=mystoragename1", function( data ) { res = data.trim(); res = JSON.parse(res); console.log(res); }); // Save string data to storage with name 'mystoragename2' var stringdata = "Erwin van der Zwart Schneider Electric The Netherlands" $.get( "/user/storage.lp?action=storageset&storagename=mystoragename2&format=string&value=" + stringdata, function( data ) { res = data.trim(); console.log(res); }); // Get string data from storage with name 'mystoragename2' $.get( "/user/storage.lp?action=storageget&storagename=mystoragename2", function( data ) { res = data.trim(); console.log(res); }); }); By changing the action / storagename / format / value in the URL you can set and get any value from storage with this script. BR, Erwin RE: Application Store documentation and sample app - FatMax - 09.12.2020 Is there a guide somewhere om how to package apps so they can be installed via a file in GUI? RE: Application Store documentation and sample app - admin - 11.12.2020 @FatMax, check PM RE: Application Store documentation and sample app - JRP - 21.04.2021 Hello I am also interested in the instructions for packaging applications. a greeting RE: Application Store documentation and sample app - admin - 21.04.2021 Check PM RE: Application Store documentation and sample app - JRP - 21.04.2021 thanks |