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


Send push notification on mobile device via virtual device


Ankit Gupta

Recommended Posts

Hi everyone,

 

I am trying to send a push notification on my mobile through my Fibaro HC2. I want that whenever my virtual device is ON/OFF, HC2 sends a push notification on my mobile device. Even I tried that with Lua script, but I am stuck. If anybody has the idea how to do it, please help me out in this case. 

 

Thanks in advance. 

 

Link to comment
Share on other sites

  • Topic Author
  • Hello everyone,

     

    I have made some progress in the code. I am now able to push notifications through ON/OFF buttons when pressed manually. But I am still unable to run the code in the main loop. The code somehow starts running in the loop and the notifications keeps coming continuously. Here is the code.  Now can somebody please tell me where to put my code to trigger the notifications. I have created the variable and used the variable to trigger the notification and created a scene. Now I am triggering the scene whenever the virtual device turns ON/OFF. I am not sure where to enter the code to trigger the scene in the main loop. 

     

    function updateStatus()
        local deviceID = fibaro:getSelfId();
        local ipaddress = fibaro:getValue(deviceID, "IPAddress");
        local port = fibaro:getValue(deviceID, "TCPPort");
        
        local rPi = Net.FHttp(ipaddress, port);
        local resp, status, result = rPi:GET("/cm?cmnd=status");
        
        local stat = "ERR";
          local icon = 6
        
        if ((result == 0) and (status == "200")) then      
            local status = json.decode(resp)["Status"]["Power"]
            if (status == 1) then icon = 5 else icon = 1006 end
            if status == 1 then stat = "ON" else stat = "OFF" end
        
       
        
        else
            --fibaro:debug("Result = "..result)
            --fibaro:debug("Status = "..status)
        end

          fibaro:call(deviceID, "setProperty", "currentIcon", icon);
        fibaro:call(deviceID, "setProperty", "ui.".."lblStatus"..".value", stat);  

      
    end

    updateStatus();

    Link to comment
    Share on other sites

    Join the conversation

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

    Guest
    Reply to this topic...

    ×   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...