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


How to integrate devices via REST API if Lua cannot provide access


Recommended Posts

Posted (edited)

Folks,

 

over time I have optimized the integration of different appliances via REST; I could not access these devices directly from HC3 with Lua, mostly as I'm using components in other languages that are simply not available in Lua. The information in this forum helped me to get things done, hence I'm happy to share back. I could improve my code documentation skills at some point..... 

 

I hope this is useful starting point for others. You might recognize code snippets of some of masterminds here ;-)

 

I'm sharing here an example of managing a Comfee MDDF-20DEN7-WF dehumidifier. We can read status to be alerted when the tank is full, and send commands such as "Turn on" and Turn Off". The solution consists of:

 

1. Python scripts that access the devices, including Flask server to expose some methods to a JSON API

2. Dockerfile to containerize 1 & 2 so that it can run on different HW platforms

3. QA that picks up and controls via the API. I store state data in UserDescription field, and get notified when the water tank is full.

 

1. Python script "app.py" that access the devices

 

Please login or register to see this code.

 

2. Dockerfile to containerize 1 & 2 so that it can run on different HW platforms. Put it in the same directory as app.py

 

Please login or register to see this code.

 

2b. requirements.txt

Please login or register to see this code.

 

3. QA that picks up and controls via the API

Please login or register to see this code.

 

Edited by jayrock
typos
  • Like 1

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