Module for Current Cost Envir

Begonnen von pendul, 01 Januar 2014, 21:34:58

Vorheriges Thema - Nächstes Thema

pendul

ls,

At the moment I am trying to write a module for the CurrentCost Envir device. For those who do not know the device, it is a rather cheap device for measuring your power consumption. For more information see: http://www.currentcost.com/download/CurrentCost%20EnviR%20Man-Singles.pdf.

Now I must admit, my programming skills in Perl are rather basic and limited, but I want to give it a try.

On the net I already found a perl-script which could be a good start: https://github.com/JackKelly/CurrentCostLogger. This is a simple Perl script for logging data from the Current Cost EnviR.

From that I decided to hack the M232 script written by Boris Neubert, to see I could make it work for the Envir device. However,  I didn`t got me that far, probably due to my limited Perl-skills.

What I have got so far is the CURRENTCOST_Initialize subroutine and the CURRENTCOST_Define($$) and Undef subroutine, but after that I am a bit stuck. I tried to read the wiki on development, but I must admit I am a bit clueless, are there any suggestions to point me in the right direction?

Thanks!

Pendul










rudolfkoenig

There is no HOWTO for writing a FHEM Module yet, I am only describing it briefly from time to time, the best bet is to study existing modules.

There is a sample module in the contrib called 00_TAHR.pm, which is better suited as a starting point IMHO. It is a sample for a one-level module, i.e. where you control your device directly. There is no sample for the two-level model, where you have a physical module for the device directly attached (like ZWDongle, CUL, TCM, etc) and logical modules for devices controlled by the directly attached device (like ZWave, FS20, EnOcean, etc), in this case you have to resort to the examples just mentioned.

By defining a device you normally open some connection, and register this filedescriptor with the global select loop (this is capsulated e.g. by DevIo_open). If there is data available from your device, then FHEM will call your ReadFn function, which then reads & parses the data, issuing events via the readings*Update functions.

Another way is to register a function with InternalTimer, and poll the device.

Tommy

Any update / fhem module to support the current cost device ?