Autor Thema: Connect to FHEM from own software?  (Gelesen 2057 mal)

Offline kennybl

  • Jr. Member
  • **
  • Beiträge: 52
Connect to FHEM from own software?
« am: 27 September 2020, 18:15:53 »
Hello,

Is it possible to connect to FHEM on the same server (raspberry pi) using my own software?
Maybe via PHP, python, javascript etc?

I would like to be able to set desired temperatures to my MAX! radiator thermostats and if possible read the temperatures as accurate (and quickly) as possible?
Do i need telnet or is there a better way to achieve this?

Offline Otto123

  • Tester
  • Hero Member
  • ****
  • Beiträge: 19508
  • schon mal restore trainiert?
    • Otto's Technik Blog
Antw:Connect to FHEM from own software?
« Antwort #1 am: 27 September 2020, 18:59:33 »
Hi,

you could achieve this via telnet, but it could be also done over http. I wrote a small set of scripts to be care about the csrf token.
https://github.com/heinz-otto/fhemcl
You could use any FHEM commandline syntax like set, get or {perl} commands and you will get the response.

For some programming languages there will be also a kind of API libs available.

Otto
Viele Grüße aus Leipzig
RaspberryPi B B+ B2 B3 B3+ ZeroW,HMLAN,HMUART,Homematic,Fritz!Box 7490+7412,WRT1900ACS-OpenWrt,Sonos,VU+,Arduino nano,ESP8266

Offline Prof. Dr. Peter Henning

  • Developer
  • Hero Member
  • ****
  • Beiträge: 8131
Antw:Connect to FHEM from own software?
« Antwort #2 am: 09 Oktober 2020, 05:11:47 »
Yes. Apart from the REST API (which is not very well documented, but some good ideas are given here: https://forum.fhem.de/index.php?topic=14491.0)
there is also a Python connector to FHEM.

https://pypi.org/project/fhem/

Regards

pah

Offline kennybl

  • Jr. Member
  • **
  • Beiträge: 52
Antw:Connect to FHEM from own software?
« Antwort #3 am: 09 Oktober 2020, 19:40:36 »
Thank you, I will look after that, now I first have to solve some other problems  :o (https://forum.fhem.de/index.php/topic,114896.0.html).

Offline Sörn

  • New Member
  • *
  • Beiträge: 6
Antw:Connect to FHEM from own software?
« Antwort #4 am: 08 Dezember 2020, 21:16:23 »
I'd recommend using mqtt for communication among FHEM and other applications. Standardized, simple, supported by fhem and you've got large variety of libs to choose from in your $favourite language ;)


I'm running a custom serial protocol (over RS485) for my switches in my house and using a custom piece of software attached to the serial interfaces translates commands coming from the switches to mqtt.
64 Relais + 8xULN2803 + 4x MCP23017 im Schaltschrank für ALLES
Custom Prokoll über RS485 für Taster, Temperatur und Feuchtesensoren

Offline Prof. Dr. Peter Henning

  • Developer
  • Hero Member
  • ****
  • Beiträge: 8131
Antw:Connect to FHEM from own software?
« Antwort #5 am: 09 Dezember 2020, 18:29:48 »
Always nice to get recommendations from FHEM newbies...

pah