FHEM Forum

FHEM => Anfängerfragen => Thema gestartet von: imranm am 21 September 2017, 13:56:19

Titel: Fhem rest api for node js
Beitrag von: imranm am 21 September 2017, 13:56:19
I am new to Fhem. I like to know that how can I access Fhem api using node js. I am  creating my application for home automation on node js with front end in angular. I will host my application over Orange Pi. I want to communicate with Fhem in my node application and I do not know how to do that.
I am looking for Fhem api that i can hit from my node application and perform my relevant action. For example setting new devices in Fhem through node.Teach them. Get all list of devices available. Turn on/off switches, lights.

I want to be able to add EnOcean based devices
I want to be able to add multiple floors to a building
I want to be able to add multiple rooms to a floor
I want to be able to add multiple products to a room
I want to be able to change (add, delete, move) a product from one room to the other

The main question is how to connect Fhem with node and perform this action. Is there any api exposed from Fhem to do these action
Titel: Antw:Fhem rest api for node js
Beitrag von: amenomade am 22 September 2017, 13:17:05
You can always control Fhem either with http(s)/curl or with telnet or nc. You will have to cope with authentication and csrfToken, but it should be no problem for you.

Some hints here:

https://wiki.fhem.de/wiki/FHEMWEB#apiWeb_Instanz
https://wiki.fhem.de/wiki/CsrfToken-HowTo
Titel: Antw:Fhem rest api for node js
Beitrag von: justme1968 am 22 September 2017, 13:34:53
there is a nose module to do than somewhere on the forum or on github.

if you want to do it yourself you can also look at alexa-fhem and the homebridge-fhem modules. they are both for node.js
Titel: Antw:Fhem rest api for node js
Beitrag von: amenomade am 22 September 2017, 14:15:09
Do you mean this one? https://github.com/winne27/fhem.js/tree/master
Titel: Antw:Fhem rest api for node js
Beitrag von: justme1968 am 22 September 2017, 19:23:13
that is one of them. there is also a rest api patch for fhemweb somewhere in the forum.
Titel: Antw:Fhem rest api for node js
Beitrag von: imranm am 25 September 2017, 08:56:23
Thanks a lot for the reply. It was great help. Moreover I have few more questions If you guys can help up.

Is there any OrangePi simulator I can use before acutally purchasing a OrangePI device. I searched but was unable to find one.

Secondly, In my application there will be a learning phase. in which the actuators of the software are connected to the end device (e.g. a heater) for the very first time and where the software sets up a connection to the product that needs to be managed. Is there any way to manage new connection by our self. Not by Fhem?

What i have understood so far ever device need to configured first in Fhem.
Titel: HTTP call to FHEM
Beitrag von: imranm am 26 September 2017, 12:23:33
I Like to know few basic thing for connection of my angular front End with Fhem. I have read The control of the devices is a simple HTTP call to FHEM.An code example will be real help I donnot know how to do that. Any blog or recent post can great help/

How did you create the connection to FHEM?
What call will I make to know list of devices, In what format it will be? and What it will return to me.What format the result will be in?
Mainly I want to know how to communicate with fhem from a simple node application. What will get and post URL to hit fhem to retirve information.what will be its format.

Titel: Antw:HTTP call to FHEM
Beitrag von: MadMax-FHEM am 26 September 2017, 13:00:06
Did this post not tell all?

https://forum.fhem.de/index.php/topic,76959.msg688842.html#msg688842

Here you find some examples:

https://forum.fhem.de/index.php/topic,66920.0.html

But be aware of csrfToken...

Regards, Joachim
Titel: Antw:HTTP call to FHEM
Beitrag von: imranm am 26 September 2017, 13:14:23
Did this post not tell all?

https://forum.fhem.de/index.php/topic,76959.msg688842.html#msg688842

It was not of any help as much.
Titel: Antw:HTTP call to FHEM
Beitrag von: Amenophis86 am 26 September 2017, 14:10:41
Please do not double post for the same theme. If you are not satisfied with the answer in the other Posts, ask for more help or specifie you question.

The Topics have been merged.