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

displaying the sonoff status in VD


Krzynio

Question

Hello. I have a script adapted by @Auto Frank "Extractor_Fan.vfib". The problem is that it does not change my status from On to Off in the module. Please help. I am enclosing the script from the main loop.

Please login or register to see this link.

 

 

Hello. I have a script adapted by @Auto Frank "Extractor_Fan.vfib". The problem is that it does not change my status from On to Off in the module. Please help. I am enclosing the script from the main loop.

 

 

local device    = fibaro:getSelfId()
local zone         = fibaro:getName(device)
local ipaddress = fibaro:getValue(device, "IPAddress")
local port         = fibaro:getValue(device, "TCPPort")

s = Net.FHttp(ipaddress, port)
rS1 = s:GET("/cm?cmnd=Status")
rS2 = s:GET("/cm?cmnd=Status%2010")

if rS1 ~= nil and rS1 ~= "" then
      jS = json.decode(rS1)
      if jS.Status.Power == 0 then
           fibaro:call(device,"setProperty","ui.extfan.value", "Off")
      fibaro:call(device, "setProperty", "currentIcon", 1085)
        fibaro:setGlobal("SonoffFanGuestEns", 0) 
        fibaro:debug("fan is off")
    
       elseif jS.Status.Power == 1 then
          fibaro:call(device,"setProperty","ui.extfan.value", "On")
        fibaro:call(device, "setProperty", "currentIcon", 1006)
        fibaro:setGlobal("SonoffFanGuestEns", 1) 
           fibaro:debug("fan is on")
    end
else
  fibaro:debug("Sonoff appears to be offline")
  fibaro:call(device,"setProperty","ui.status.value", "OFFLINE")
end
if rS2 ~= nil and rS2 ~= "" then
      jS = json.decode(rS2)
      local Temp = jS.StatusSNS.DHT11.Temperature
      local Humidity = jS.StatusSNS.DHT11.Humidity
      fibaro:setGlobal("SonoffFanGuestEnsT", Temp) 
      fibaro:setGlobal("SonoffFanGuestEnsH", Humidity) 
       fibaro:call(device,"setProperty","ui.temp.value", Temp.." C")
    fibaro:call(device,"setProperty","ui.humidity.value", Humidity.." RH")
      local fanState = fibaro:getGlobalValue("SonoffFanGuestEns")
      if fanState == "1" then fanStat = "Off" else fanStat = "On" end
    status = ""..fanStat.." / "..Temp.." C / "..Humidity.." RH"
      fibaro:debug(status)
      fibaro:call(device,"setProperty","ui.status.value",status)


end

local upt = ""..os.date("%d").." "..os.date("%b").." @ "..os.date("%H:%M")..""
fibaro:log("Updated: "..upt)    

fibaro:sleep(5000)

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

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