How to get FHEM to read a value from a file ?

Begonnen von @lex99, 07 Oktober 2017, 22:20:56

Vorheriges Thema - Nächstes Thema

@lex99

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 !

Deudi

Gigabyte Brix, Ubuntu 16.04.3 LTS, Homematic, Z-Wave, EnOcean, Shelly@MQTT, SIGNALduino, JeeLink DAVIS-Sketch

@lex99

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)

Otto123

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  ⇉  nächster Stammtisch an der Lindennaundorfer Mühle
RaspberryPi B B+ B2 B3 B3+ ZeroW,HMLAN,HMUART,Homematic,Fritz!Box 7590,WRT3200ACS-OpenWrt,Sonos,VU+,Arduino nano,ESP8266,MQTT,Zigbee,deconz