Autor Thema: How to get FHEM to read a value from a file ?  (Gelesen 245 mal)

Offline @lex99

  • New Member
  • *
  • Beiträge: 9
How to get FHEM to read a value from a file ?
« am: 07 Oktober 2017, 22:20:56 »
Hi,

I have a perl script that runs on my Pi (where FHEM is running) and updates a file with a 0 or 1.

I would like FHEM to read that file at certain times (AT command) and depending on the file contents (0 or 1) do an action (or not).

I am stuck: how to get FHEM to read the file ?

Thanks !

Offline Deudi

  • Full Member
  • ***
  • Beiträge: 499
  • abgeschnitte Kabel sind immer zu kurz ...
Antw:How to get FHEM to read a value from a file ?
« Antwort #1 am: 07 Oktober 2017, 23:05:10 »
How about using a custom reading?
https://fhem.de/commandref.html#CustomReadings
Gigabyte Brix, überwiegend Homematic (4x HMLAN für > 90 Komponenten)
Gefällt mir Gefällt mir x 1 Liste anzeigen

Offline @lex99

  • New Member
  • *
  • Beiträge: 9
Antw:How to get FHEM to read a value from a file ?
« Antwort #2 am: 10 Oktober 2017, 21:56:41 »
Hi,

Thanks, it works OK.  For those interested:

I have a Perl script that checks the weather forecast for my town and writes 0 or 1 in the status.txt file, depending if there will be sunshine or not.
Then FHEM reads the file and puts off the heater if sunshine is expected.

In fhem.cfg:
define myMeteo CustomReadings
attr myMeteo interval 3600
attr myMeteo readingDefinitions chauff:qx(cat /mnt/PiBackup/Chauffage/status.txt)

define Chauffage_6 at *06:01:00 IF ([myMeteo:chauff] eq "0") (set 0_Chaudiere off)

Offline Otto123

  • Hero Member
  • *****
  • Beiträge: 6786
    • Otto's Technik Blog
Antw:How to get FHEM to read a value from a file ?
« Antwort #3 am: 10 Oktober 2017, 22:08:15 »
Hi,
for your Info, there is also a perl function inside FHEM -> https://wiki.fhem.de/wiki/DevelopmentModuleAPI#FileRead
Unfortunately this doku is in german.

Otto
Viele Grüße aus Leipzig
RaspberryPi,HMLAN,HMUART,Homematic,Fritz!Box 7490,Sonos,ET9200,Arduino nano,ESP8266

 

decade-submarginal