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 device icon for main power button..


Question

Posted

Dear Member,

 

I have created a virtual device with one button.. this button switches my plugwise wall plug on and off. 

This works flawless.

 

The problem is that the main button (under devices) won't change color blue when activated just like a normal existing switch.

 

Please login or register to see this attachment.

(on/off button won't change color)

 

 

Please login or register to see this attachment.

(Example blue button from existing switch)

 

 

What code do i use to update the main on/off button?

 

Below my current code..

 

--[[

%% properties
 
%% globals
--]]
 
-- Get the value of the 'status' global variable
local value = fibaro:getGlobalValue("plugwise1")
 
if (value == '0') then
plugwise = Net.FHttp("192.168.1.2", 80)
plugwise:setBasicAuthentication("stretch", "sgxfzdxj")
response = plugwise:POST("/minirest/appliances;id=b601b5816f0743a5b111bda80787ab19/power_state=on", "\n\r")
fibaro:log(response)
  fibaro:sleep(1000)
  fibaro:setGlobal("plugwise1", "1")
else
plugwise = Net.FHttp("192.168.1.2", 80)
plugwise:setBasicAuthentication("stretch", "sgxfzdxj")
response = plugwise:POST("/minirest/appliances;id=b601b5816f0743a5b111bda80787ab19/power_state=off", "\n\r")
fibaro:log(response)
  fibaro:sleep(1000)
  fibaro:setGlobal("plugwise1", "0")
end
 
Thank you for your time!!
 
br
Vincent

4 answers to this question

Recommended Posts

  • 0
Posted

You are comparing virtual devices and plugins, two completely different things. There is no way to keep the button blue in virtual device, however you can change the icon depending on a state of device.

  • 0
Posted

Hello

 

How do I get a virtual device to change icon? I have a Denon virtual device, however I can only chose 1 icon when I click on the change icon button.

 

Thanks!

  • 0
Guest spazpeker
Posted (edited)

something like this, you need to change the icon 1004 & 1003 to values of the icons you want 

 

local vdID = fibaro:getSelfId()

-- ID of switch
local S1ID = "your device id

local status1 = tonumber(fibaro:getValue(S1ID, "value"));

 

if ( tonumber(status1) > 0) 
  then 
fibaro:call(vdID, "setProperty", "currentIcon", 1004);

else 
fibaro:call(vdID, "setProperty", "currentIcon", 1003);  

end

Edited by spazpeker
  • 0
Posted

Thank you spazpeker!!

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