Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Virtual Devices on HCL, worthless without LUA ...?


Question

Posted

Hi,

 

On my HCL, I want to display some input values from my YouLess Energy Meter.

I tried a Virtual Device but this didn't succeed.

 

Does anyone have an example for how to use 'strings' in Virtual Devices?

 

(please no LUA, since only 'strings' are supported by HCL)

 

 

 

Thanks!

19 answers to this question

Recommended Posts

  • 0
  • Inquirer
  • Posted

    Anyone experiance with the use of 'strings' in Virtual Devices, please ?

    • 0
    Posted

    I would like to bring it up + my question on the topic - how to use virtual device (in a more sophisticated way)?

    Lack of LUA programming in HCL is a huge limitation. Is there any chance to use any coding in HCL at all?

    • 0
    Posted

    to be more precise - will callAction allow me to do something similar to fibaro:setSceneEnabled(ID, false) ?

     

    Please login or register to see this link.

    • 0
  • Inquirer
  • Posted

    As far as I no... there's no way for coding in a HCL at all. So, I'm looking for ways to work arround this limitation and there are some thoughts I have that I would like to share here.

     

    I have a Euro 9,- NodeMCU development board which is running LUA and it has several GPIO ports and there's an ESP8266 Wifi module on board.

    So maybe it is possible to send 'strings' from this board via WiFi and my local LAN to Fibaro HCL Virtual Devices to control scene's etc.

     

    However, right now I have no clue how to address the Virtual Devices using 'strings'.....

    • 0
  • Inquirer
  • Posted

    I've had a new brainwave to work around the missing-LUA-on-HCL issue.

     

    Now I'm thinking of installing node.js and use NodeRED on my Raspberry Pi. Using NodeRED it should be possible to interact with the HCL API.

     

    Still need to find out how to use the HCL Virtual devices though....

    Who can help me out with the use of Virtual devices using 'strings' , please..................?

    • 0
    Posted

    Example of a string used for turning off a samsung TV.

    sendir,1:1,1,38028,1,1,173,173,21,65,21,65,21,65,21,21,21,21,21,21,21,21,21,21,21,65,21,65,21,65,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,65,21,65,21,21,21,21,21,65,21,65,21,65,21,65,21,21,21,21,21,65,21,65,21,21,21,1832 0x0D0x0A

    • 0
    Posted

    I've a virtual device with a label where I update "now playing" info for my music system. I'm doing this with a HTTP-call:

    Please login or register to see this code.

    Update the IP to the IP of your HCL.

    deviceID - The id of the virtual device

    mylabelid - The id of the label in the virtual device

    mystringvalue - Whatever string you want to send. Use %20 for whitespace.

     

    To be able to do this, you need to set a request property "Authorization" to "Basic <your auth string>". Your auth string is a Base64 encoded string of your fibaro credentials. <user>:<password>.

     

    An example admin:admin -> YWRtaW46YWRtaW4=

     

    You can use this page: 

    Please login or register to see this link.

     

    If you are already logged in to your HCL in your web browser, you should be able to just copy/paste the URL and it should work if you want to try it out.

     

    Hope this helps.

    • 0
  • Inquirer
  • Posted

    KristianO and Hendrik: Thanks!

     

    As soon as I have time to pick up this issue, I will respond in this topic with the results. (can take some time, need to move to a new house soon...)

    • 0
  • Inquirer
  • Posted

    Please login or register to see this code.

    Update the IP to the IP of your HCL.

    deviceID - The id of the virtual device

    mylabelid - The id of the label in the virtual device

    mystringvalue - Whatever string you want to send. Use %20 for whitespace.

     

    To be able to do this, you need to set a request property "Authorization" to "Basic <your auth string>". Your auth string is a Base64 encoded string of your fibaro credentials. <user>:<password>.

     

     

     

    Hi Henrik,

     

    Thanks, your solution is working fine !

     

    p.s.

    In your signature I read this: " Fibaro Home Center Lite v4.058 Beta > LUA possible! "

    Does this mean you have found a way to use LUA for HCL?

    If so, please let me know how. Thanks!

    • 0
    Posted

    Hi guys,

    I connected a NodeMCU with just using a virtual device named NodeMCU with 2 buttons as follow:

    1. Label: ON , ID: B1, code: /LED=ON

    2. Label: OFF , ID: B2, code: /LED=OFF

     

    The NodeMCU server window reported:

     

    new client
    GET /LED=ON HTTP/1.1
    Client disonnected
     
    new client
    GET /favicon.ico HTTP/1.1
    Client disonnected
     
    new client
    GET /LED=OFF HTTP/1.1
    Client disonnected
     
    new client
    GET /favicon.ico HTTP/1.1
    Client disonnected
     
     
    .....and then....it suddenly stopped responding to the Fibaro buttons.....also the Fibaro SAVE button stays blue.....I have a feeling the Fibaro can't save the virtual button.
    Please advice what went wrong?
    I tried the nodeMCU via a simple http test and it works and switches the LED on and off, which means the Fibaro doesn't serve the communication. All other original z-wave nodes work as is.....
     
    Thanks in advance
    Nick
    • 0
    Posted

    +.... some more info about the problem:

     

    1. Fibaro HCL doesn't forward any data to NodeMCU IP via port 80 although the virtual device is properly set with IP address and port 80;

    2. If port 80 tested via a browser, it provides communication with the NodeMCU.

    • 0
    Posted

    ! PROBLEM SOLVED !

     

    A simple power disconnect for 10 seconds and then powering again the HCL fixed the issue.

    It seems that a simple HCL warm reset is not enough ....... any explanations?

    • 0
  • Inquirer
  • Posted

    ! PROBLEM SOLVED !

     

    A simple power disconnect for 10 seconds and then powering again the HCL fixed the issue.

    It seems that a simple HCL warm reset is not enough ....... any explanations?

     

    Hi, I hope your HCL will stay stable from now! Thanks for letting us know and please keep us informed here... thanks!

     

     

    Could you please upload all the settings of your Virtual Devices please? (screen shots would be very helpfull to me)

     

    Thanks!

    • 0
    Posted

    Hi,

    Hare is the info required:

    1. NodeMCU settings:

    { "id": 67, "name": "NodeMCU", "roomID": 1, "type": "virtual_device", "visible": true, "enabled": true, "properties": { "deviceIcon": 1002, "ip": "10.168.142.102", "port": 80, "log": "", "logTemp": "", "currentIcon": "1002", "mainLoop": "", "visible": "true", "rows": [ { "type": "button", "elements": [ { "id": 1, "lua": false, "waitForResponse": false, "caption": "ON", "name": "Button11", "empty": false, "msg": "/LED=ON", "buttonIcon": 1001, "favourite": false, "main": false }, { "id": 2, "lua": false, "waitForResponse": false, "caption": "OFF", "name": "Button12", "empty": false, "msg": "/LED=OFF", "buttonIcon": 1002, "favourite": false, "main": true } ] } ] }, "actions": { "pressButton": 1, "setSlider": 2, "setProperty": 2 }, "created": 1471776013, "modified": 1471776013, "sortOrder": 20 } ]

     

    2. NodeMCU arduino code:

     

     

    #include <ESP8266WiFi.h>

     
    const char* ssid = "your SSID";
    const char* password = "your PASSWORD";
     
    int ledPin = 13; // GPIO13
    WiFiServer server(80);
     
    void setup() {
      Serial.begin(115200);
      delay(10);
     
      pinMode(ledPin, OUTPUT);
      digitalWrite(ledPin, LOW);
     
      // Connect to WiFi network
      Serial.println();
      Serial.println();
      Serial.print("Connecting to ");
      Serial.println(ssid);
     
      WiFi.begin(ssid, password);
     
      while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
      }
      Serial.println("");
      Serial.println("WiFi connected");
     
      // Start the server
      server.begin();
      Serial.println("Server started");
     
      // Print the IP address
      Serial.print("Use this URL to connect: ");
      Serial.print("http://");
      Serial.print(WiFi.localIP());
      Serial.println("/");
     
    }
     
    void loop() {
      // Check if a client has connected
      WiFiClient client = server.available();
      if (!client) {
        return;
      }
     
      // Wait until the client sends some data
      Serial.println("new client");
      while(!client.available()){
        delay(1);
      }
     
      // Read the first line of the request
      String request = client.readStringUntil('\r');
      Serial.println(request);
      client.flush();
     
      // Match the request
     
      int value = LOW;
      if (request.indexOf("/LED=ON") != -1)  {
        digitalWrite(ledPin, HIGH);
        value = HIGH;
      }
      if (request.indexOf("/LED=OFF") != -1)  {
        digitalWrite(ledPin, LOW);
        value = LOW;
      }
     
    // Set ledPin according to the request
    //digitalWrite(ledPin, value);
     
      // Return the response
      client.println("HTTP/1.1 200 OK");
      client.println("Content-Type: text/html");
      client.println(""); //  do not forget this one
      client.println("<!DOCTYPE HTML>");
      client.println("<html>");
     
      client.print("Led pin is now: ");
     
      if(value == HIGH) {
        client.print("On");
      } else {
        client.print("Off");
      }
      client.println("<br><br>");
      client.println("<a href=\"/LED=ON\"\"><button>Turn On </button></a>");
      client.println("<a href=\"/LED=OFF\"\"><button>Turn Off </button></a><br />");  
      client.println("</html>");
     
      delay(1);
      Serial.println("Client disonnected");
      Serial.println("");
     
    }
     
    BR
    Nick
    • 0
  • Inquirer
  • Posted

     

    Hi,

    Hare is the info required:

    1. NodeMCU settings:

    { "id": 67, "name": "NodeMCU", "roomID": 1, "type": "virtual_device", "visible": true, "enabled": true, "properties": { "deviceIcon": 1002, "ip": "10.168.142.102", "port": 

    }
     
    BR
    Nick

     

     

     

    Thanks a lot Nick!

    This will give me jump start!

     

    I also have problems with setting up the Virtual Device in my HCL.

    Could you also please let me know the exact settings/ screen shots for this?

    Thanks in advance!

    • 0
    Posted

    Here are the dropbox links:

     

    Please login or register to see this link.

     

    Please login or register to see this link.

     

    Please login or register to see this image.

     

    HCL-NodeMCU-01.png?dl=0

     

    Also you have to set static IP for your NodeMCU in your router.

     

    ....the only thing I have to find out is how to read NodeMCU data with Fibaro HCL ???????......anybody to help with??????????????

    • 0
  • Inquirer
  • Posted

     

    ....the only thing I have to find out is how to read NodeMCU data with Fibaro HCL ???????......anybody to help with??????????????

     

    Hi Nick,

     

    I was able to read values with my browser. Thanks to post #10 from Hendrik:

     

    Please login or register to see this link.

     

     

    Is this what you are looking for?

     

    Did you also take care about the authorization string before trying to read values?

    • 0
    Posted

    Hi PeterG,

    Can you please guide me with a link or some explanations about using/writing the authorization string?

    Thanks in advance

    Nick

    • 0
  • Inquirer
  • Posted (edited)

    Hi Nick,

     

    I only tested this with my browser. To avoid authorization issues at that time, I also stayed logged in on the HCL with my browser.

    This way the authorization string was not needed while I was testing. I know this is a bit simple and not usable for real, it's only for fooling around with value changes....

     

    Somewhere I read about authorization using JSON on a HC2, perhaps it was on this forum. The following is what I saved to remember myself:

     

    Authentication("admin","admin") response = HC2:GET("/api/settings/location") response = json.decode(response) response.ntpServer = "pl.pool.ntp.org"; response.ntp = true; local payload = response; payload = json.encode(payload) response, status, errorCode = HC2:PUT('/api/settings/location', payload)",
                "buttonIcon": 0,

                "favourite": false,

     

     

    I guess this is for no use to you but perhaps it can be a start to find out more?

     

    Or have a look at what Henrik said in his post #8:

     

    To be able to do this, you need to set a request property "Authorization" to "Basic <your auth string>". Your auth string is a Base64 encoded string of your fibaro credentials. <user>:<password>.

    Edited by PieterG

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...