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


  • 1

Sonoff basic


wiesiekr

Question

Hello.

Does anyone have an idea how to make a virtual device to control Sonoff Basic with the loaded espeasy or other software so that you can switch on and off the device with the HCL.
  Is it possible to read states in the HCL or is switched on or off.

Link to comment
Share on other sites

Recommended Posts

  • 0

 

Sonoff with Tasmota firmware in HCL virtual device for command on / off. You just need to replace the IP.

Please login or register to see this attachment.

FOR ON 

GET /cm?cmnd=Power%20On HTTP/1.1
Host: 192.168.0.....
0x0D0x0A0x0D0x0A

FOR OFF

GET /cm?cmnd=Power%20off HTTP/1.1
Host: 192.168.0.....
0x0D0x0A0x0D0x0A

Edited by gabi chirilescu
Link to comment
Share on other sites

  • 0

I got this intresting article on this site: 

Please login or register to see this link.

 

Can it be included in this project

Link to comment
Share on other sites

  • 0
On 3/16/2018 at 5:03 PM, 10der said:

LUA. :(

 

NMm7n3r5aS.png

but as I can see HCL can send "telnet" command.

so you can send 

/cm?cmnd=Power1%20ON or /cm?cmnd=Power1%20OFF

command as "string"

Hi , What is the TCP port value for Sonoff??

Link to comment
Share on other sites

  • 0
W dniu 16.03.2018 o 17:18, 10der napisał:

witam. nie. ja mam HC2. LUA VD :(

 

 

Please login or register to see this attachment.

Please login or register to see this attachment.

to forum blad :(

Witam, Czy można ten  skrypt przerobić pod sterowanie softem AFE. Sterownik zwraca wartość  {"device":"relay","name":"S2CH_1_2","command":"get","value":"off","status":"success"} a komenda do włączenia to 

Please login or register to see this link.

toggle ???

Link to comment
Share on other sites

  • 0
W dniu 16.03.2018 o 17:18, 10der napisał:

witam. nie. ja mam HC2. LUA VD :(

 

 

Please login or register to see this attachment.

Please login or register to see this attachment.

to forum blad :(

Hello, I tried to apply this VD to my sonoff and everything works on Tasmota software. The problem is only with the status check. After turning on Sonoff through the onboard switch in VD, the status does not change

Link to comment
Share on other sites

  • 0

@ptekien can you turn on via onboard button and get status in browser manuall

 

Please login or register to see this link.

 

where 

Please login or register to see this link.

 sonoff ip address 

Link to comment
Share on other sites

  • 0

In the previous post I wrote the result from sonoff 4CH, Sonoff dual replies: 

Please login or register to see this code.

Link to comment
Share on other sites

  • 0

In vd from AutoFrank @ his state changes but there is no icon change in it. It has a main loop

 

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

s = Net.FHttp(ipaddress, port)
r = s:GET("/cm?cmnd=Status")

if r ~= nil and r ~= "" then
      jS = json.decode(r)
      if jS.Status.Power == 0 then
           fibaro:call(deviceID,"setProperty","ui.status.value", "Lamp Off")
        --fibaro:call(device, "setProperty", "currentIcon", 1009)
        fibaro:setGlobal("SonoffHallLamp", 0) 
        
           fibaro:debug("Lamp is off")
       elseif jS.Status.Power == 1 then
          fibaro:call(deviceID,"setProperty","ui.status.value", "Lamp On")
        --fibaro:call(device, "setProperty", "currentIcon", 1010)
        fibaro:setGlobal("SonoffHallLamp", 1) 
           fibaro:debug("Lamp is on")
    end
else
  fibaro:debug("Sonoff appears to be offline")
  fibaro:call(device,"setProperty","ui.status.value", "OFFLINE")
end

fibaro:sleep(1000)

Link to comment
Share on other sites

  • 0

As I can see unexpected answer here for SonOff 

imho you have a new FW. Or something else 

cuz 

13 hours ago, ptekien said:

Power":0

Mean what your SonOff device if OFF

alas

Edited by 10der
Link to comment
Share on other sites

  • 0
On 6/11/2019 at 8:29 AM, JEAU said:

I got this intresting article on this site: 

Please login or register to see this link.

 

Can it be included in this project

ITLEAD closed this functionality it’s cuz  SONOTA project was stopped 

Please login or register to see this link.

Link to comment
Share on other sites

  • 0
2 godziny temu, 10der napisał:

As I can see unexpected answer here for SonOff 

imho you have a new FW. Or something else 

cuz 

Mean what your SonOff device if OFF

alas

Feedback is ok. If it is turned on it returns the value power ": 1, power": 2, or power ": 3. The problem is only that in VD the state of the switch does not refresh after turning on the switch itself. The point is that I need a state because I want to use sonoff touch which can be turned on directly.

Link to comment
Share on other sites

  • 0

Ok let me check

5 min

 

UPD:

can't reproduce!

Please login or register to see this image.

/monthly_2019_11/image.png.e82a4ea8e917974deff8d31db3e377e3.png" />

 

image.png.43dd2bcd0a7824aa802bde3f1304b64a.png

 

image.png.fa36d878c43559bfec46ae6f34638228.png

 

 

 

Edited by 10der
Link to comment
Share on other sites

  • 0

Unfortunately, it doesn't work for me, maybe it's a bug in the main loop.

 

function updateStatus()
      local deviceID = fibaro:getSelfId();
    local ipaddress = fibaro:getValue(deviceID, "IPAddress");
    local port = fibaro:getValue(deviceID, "TCPPort");
  
      local state = 0;
    local rPi = Net.FHttp(ipaddress, port);
    local resp, status, result = rPi:GET("/cm?cmnd=status");
    if ((result == 0) and (status == "200")) then
        state = tonumber(json.decode(resp)["Status"]["Power"])
    else
          --fibaro:debug("Result = "..result)
        --fibaro:debug("Status = "..status)
    end
  
      local icon = 1009  
      local status = {0, 0}
      if state == 1 then status[1] = 0; status[2] = 1; icon = 1004 end
      if state == 2 then status[1] = 1; status[2] = 0; icon = 1010 end
      if state == 3 then status[1] = 1; status[2] = 1; icon = 1003 end
    
      --0 = '00',
    --1 = '01',
    --2 = '10',
    --3 = '11',
     
-- L         = 1004
-- R         = 1010
-- L + R     = 1003
-- default    = 1009
  
      fibaro:call(deviceID, "setProperty", "ui.".."lblStatus1"..".value", status[2] );
      fibaro:call(deviceID, "setProperty", "ui.".."lblStatus2"..".value", status[1] );
      fibaro:call(deviceID, "setProperty", "ui.".."lblStatus"..".value",  status[2] .." | " .. status[1] );
      fibaro:call(deviceID, "setProperty", "currentIcon", icon); 
end


-- updateStatus()
 

 

Please login or register to see this attachment.

Please login or register to see this attachment.

Please login or register to see this attachment.

Link to comment
Share on other sites

  • 0

Btw Fibaro UI sometimes not update UI lanes 

btw2 Fibaro UI VD updates every 3sec 

btw3 add Fibaro debug to main loop and you can see what happens 

Link to comment
Share on other sites

  • 0

Can you write what it is supposed to look like because I can't help it myself.  Unfortunately I am not fluent in LUA

Link to comment
Share on other sites

  • 0

OK! remove main loop! at all! please

 

replace with this code  

 

Please login or register to see this code.

 

click debug button / click start button

leave this windows as is 

and click button on your sonoiff device

 

provice result of debug winow here

 

example

Please login or register to see this image.

/monthly_2019_12/image.png.d799055375fe2804fa009d3fce2cc72f.png" />

 

Link to comment
Share on other sites

  • 0

the debug result shows the correct state when pressed, but how to apply it to the previous loop so that the icons and status also change?

Please login or register to see this attachment.

Please login or register to see this attachment.

Link to comment
Share on other sites

  • 0

aha got.

all was easy

 

return original loop

goto end of code

REMOVE line

Please login or register to see this code.

[ SAVE]

PS: for preventing high CPU usage VD update own status every minute (sic!)

Link to comment
Share on other sites

  • 0

But this line was not in the original loop.

function updateStatus()
      local deviceID = fibaro:getSelfId();
    local ipaddress = fibaro:getValue(deviceID, "IPAddress");
    local port = fibaro:getValue(deviceID, "TCPPort");
  
      local state = 0;
    local rPi = Net.FHttp(ipaddress, port);
    local resp, status, result = rPi:GET("/cm?cmnd=status");
    if ((result == 0) and (status == "200")) then
        state = tonumber(json.decode(resp)["Status"]["Power"])
    else
          --fibaro:debug("Result = "..result)
        --fibaro:debug("Status = "..status)
    end
  
      local icon = 1009  
      local status = {0, 0}
      if state == 1 then status[1] = 0; status[2] = 1; icon = 1004 end
      if state == 2 then status[1] = 1; status[2] = 0; icon = 1010 end
      if state == 3 then status[1] = 1; status[2] = 1; icon = 1003 end
    
      --0 = '00',
    --1 = '01',
    --2 = '10',
    --3 = '11',
     
-- L         = 1004
-- R         = 1010
-- L + R     = 1003
-- default    = 1009
  
      fibaro:call(deviceID, "setProperty", "ui.".."lblStatus1"..".value", status[2] );
      fibaro:call(deviceID, "setProperty", "ui.".."lblStatus2"..".value", status[1] );
      fibaro:call(deviceID, "setProperty", "ui.".."lblStatus"..".value",  status[2] .." | " .. status[1] );
      fibaro:call(deviceID, "setProperty", "currentIcon", icon); 
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
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...