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


Connecting Fibaro HC2 to an ESP8266 - two tutorials


ianbren

Recommended Posts

Hi,

 

I am a newbie, so I do not know how to handle your hint.

This is what browser shows.... 

Please login or register to see this attachment.

Link to comment
Share on other sites

Started to create simple VD... just to get json

Please login or register to see this attachment.

local thisdevice = fibaro:getSelfId() 

-- the next line uses the VD information on the ESP8266 
-- to create a HTTP connection object 

local conn = Net.FHttp(fibaro:getValue(thisdevice, 'IPAddress'), fibaro:getValue(thisdevice, 'TCPPort')) 

-- if there's a path name, then put it in the GET() method. 

response, status, errorCode = conn:GET('/json:') 

-- "response"  will hold the JSON coming back 

if response == nil then 
  fibaro:debug('response  = nil ')
elseif response ~= nil then
  fibaro:debug('response  ' .. response)
end
fibaro:debug('status  ' .. status)
fibaro:debug('errorCode   ' .. errorCode)

-- good practice 

fibaro:sleep(1) 

if errorCode == 0 then 
    -- so , you got something back ok 
    -- the Status is not really needed, unless you're going to deal with non-200 HTTP Status codes 

    -- Example processing JSON 

  -- fibaro:debug ("Try to get table")
  jsonTable = json.decode(response) 
  
  --fibaro:debug (json.encode(response))
    
  -- there are three elements that come back in the "101" sample ESP8266 code

  --fibaro:call(thisdevice, "setProperty", "ui.Label1.value", jsonTable.w_temperature)
  --fibaro:call(thisdevice, "setProperty", "ui.Label2.value", jsonTable.Data2) 
  --fibaro:call(thisdevice, "setProperty", "ui.Label3.value", jsonTable.myText) 
else 

    -- so we had a non-zero error code - something went wrong

  fibaro:debug("Error: Code  " .. errorCode) 

end 

Link to comment
Share on other sites

so, it's VD

 

AFAIK(R) custom headers available... only in scenes, not virtual devices.

Link to comment
Share on other sites

I do not find solution how to send http://192.168.1.1/control?cmd=GPIO,12,1 command to esp8266 with Espeasy. I create virtual switch on hc2 and tryng send this but without luck.

Link to comment
Share on other sites

  • 4 weeks later...
On 9/20/2017 at 1:23 PM, 10der said:

JFYI:

 

1) ESP8266 Serial ESP-12F Wi-Fi Witty Cloud Development Board + DHT22

Please login or register to see this spoiler.

Hi 10der@,

 

Coole script!
i have qestion, can i take multiple sensors on the same board(total 3), and youse it on fibaro as a different sensors for different rooms?

 

Best regards

Link to comment
Share on other sites

1 minute ago, Gravity said:

i have qestion, can i take multiple sensors on the same board(total 3), and youse it on fibaro as a different sensors for different rooms?

 

not clear for me... why not? :)

but, one notice VD is not Z-wave device and you can't use it as default sensor in Fibaro  UI, etc

Link to comment
Share on other sites

Thanks for so fast answer!

I am not so good with coding and use mostly copy, paste function.;)

Sensors will be used in basements in different rooms to monitor temperature, and humidity, and start scens.  I guess in

Please login or register to see this attachment.

need to change

// Connect DHT
DHT dht(D1, DHT22);

DHT dht?(D0, DHT22)

DHT dht?(D5,DHT22)

but what i need to change in VD to know a value from different sensors because is on a same ip adress?

 

Thanks..

Link to comment
Share on other sites

43 minutes ago, Gravity said:

but what i need to change in VD to know a value from different sensors because is on a same ip adress?

 

first. i still not clear understand you =)

 

1) (let) I have 5 (five) DHT sensors on my Arduino

2) (let) this Arduino is ESP8266. Otherwise, you should connect Arduino via  0/1 pin to ESP to 1/0 pin as COM

3) on ESP create Web Service. (let) for example, Arduino have 192.168.1.77 address and WebServer port is 80

4) code Arduino www handler and endpoint /sensor and /1 /2 /3 /4 /5 - endpoints for DHT sensors data

5) VD in HC2: 

 

Please login or register to see this code.

Please login or register to see this code.

 

NB: the provided code I was wrote here in this forum html editor. so, it can don't works :)

Link to comment
Share on other sites

  • 10 months later...

Just stumbled upon this thread and hopes one of You guys can help.

 

I am using my fibaro system also as an alarm system for my house, but would really like a better way to know if the alarm is armed or disarmed.

 

I recently bought a Wemos D1 min and a 0.96" oled screen for another project and is now wondering if it would be possible to get the Wemos to retrieve a GlobalVariable value and present it on the screen??

 

Example: When alarm is armed the display states "Alarm Armed" and "Alarm Disarmed" when the alarm is not armed..

 

I have no knowledge of coding, so this is where i need a little help..

 

Is this in any way possible??

Link to comment
Share on other sites

1) this OLED will dead after 1-1.5y with artefactes etc (just fact, I have 2 OLED with same results)

2) yes you can grab global values. for example 

Please login or register to see this code.

where 192.168.1.36 - HC ID address

AlarmStatus - your global value

 

and do not freget provide basic auth header

 

good luck

 

Link to comment
Share on other sites

Thanks a lot for your fast reply.. :-)

 

The Oleds are so cheap, so it would be easy to replace them if they die out..

 

Is it possible for your to help me with the actual code, I have to flash onto the Wemos? I have absolutely no knowledge of the coding..

 

At the moment i'm using the present Wemos as a monitor for my 3D printer (using this code).. I assume the code for what i want here must be a mix of this and some of that You have written here in the forum a couple of posts up?

Link to comment
Share on other sites

  • 3 years later...

Hello

 I have quickapp in HC3 that have some buttons I want to call from ESP8266 with it's URL All buttons API is working fine in browser the project consist of {ESP8266, IR Receiver} that is it I want to make conditions for the buttons that IR receive I will get it's HEX from serial monitor and every button it's condition come true is calling Certain button in fibaro quickapp through API How can I make API call under every (condition) OR (case) from arduino

Link to comment
Share on other sites

  • 2 months later...

maybie something here can help : 

 

It shows esp code as well as very basic fibaro device. 

 

Edited by vifefref45
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...