Coding and Dismantling Stuff

Don't thank me, it's what I do.

About the author

Russell is a .Net developer based in Lancashire in the UK.  His day job is as a C# developer for the UK's largest online white-goods retailer, DRL Limited.

His weekend job entails alternately demolishing and constructing various bits of his home, much to the distress of his fiance Kelly, 3-year-old daughter Amelie, and menagerie of pets.

TextBox

  1. Fix dodgy keywords Google is scraping from my blog
  2. Complete migration of NHaml from Google Code to GitHub
  3. ReTelnet Mock Telnet Server à la Jetty
  4. Learn to use Git
  5. Complete beta release FHEMDotNet
  6. Publish FHEMDotNet on Google Code
  7. Learn NancyFX library
  8. Pull RussPAll/NHaml into NHaml/NHaml
  9. Open Source Blackberry Twitter app
  10. Other stuff

FHEM Setup on Windows Home Server - Part 2 of 2

In Part 1 of this tutorial, we installed Perl onto our server, we setup a CUL device and did some basic testing to prove the hardware was working and installed correctly.  In this second part, we're going to install FHEM, configure a basic FHEM setup and install the necessary add-ons to Perl to get it all working.

Install & Configure FHEM

  1. Download the newest version (currently v5.0) from http://www.koeniglich.de/fhem/fhem.html
  2. Extract FHEM to a suitable location on your PC, in my case I've extracted it to "c:\strawberry\fhem"
  3. Create a text file called "config,txt" in the same location as the "fhem.pl" script, I'm going to key in the following minimal configuration:
    attr global logfile c:\strawberry\fhem\fhem.log
    attr global modpath .
    attr global nofork 1
    # "global" keyword at the end of following command allows connection from any host
    attr global port 7072 global
    attr global statefile c:\strawberry\fhem\fhem.save
    attr global verbose 5
    
    define CUL CUL com8@9600 1234
  4. The above configuration should be fairly self explanatory, obviously at this point you can choose whichever port you'd like, and choose where you'd like to keep your log and save files.
  5. Important - Make sure you enter the correct port number for your CUL device, in the example above I've used "com8".
  6. Open a command prompt and navigate to your Fhem install location, if you've configured Perl correctly as in the previous post, you can now just enter "perl fhem.pl config.txt" to try and launch the server.
  7. If nothing seems to happen and you're dumped back at the command prompt, look to see if Fhem has created a logfile, and if so you'll probably read, "Can't locate Win32/SerialPort.pm", so we now need to install the Win32:SerialPort Perl extension.

Installing Perl Win32:SerialPort extension

This one's easy:

  1. From a command prompt, enter the command "cpan Win32::SerialPort"
  2. Watch Perl download and install the extension
  3. The install will take a few moments to run through, but when it's done try again to run your Fhem.pl server as in step 6 above, and this time your should see your command prompt appear to lock up, this means that the Fhem server is running and waiting for connections

Completing Your Fhem Installation

To finish off your Fhem installation, you're going to need to configure your devices as follows:

  1. Check the log file and make sure you can see a line with "Server started" somewhere - this usually means your hardware is all working correctly.
  2. Wait several minutes and check your logfile again, you should now find a whole bunch of lines "CUL: Unknown FHT device detected" (or you may see other devices mentioned, depending on what hardware you have)
  3. For each error message, you'll see the raw message captured, for example "CUL/RAW: /Txxxx00A600FE", where xxxx is the House code and Device code.
  4. For each FHT device detected, you now need to work out which room corresponds to which device, this can be done by getting the house code and device code from each device, and using Windows Calculator to convert these decimal values into their two-digit HEX equivalents, then combining the two into a four-digit value.
  5. Now that you know which 4-digit code corresponds to which room, you can define your devices in your config.txt file, each device will need an entry like:

    define roomname FHT 1122
    attr roomname retrycount 3
  6. In my case, my basic config file looks like:
    attr global logfile c:\strawberry\fhem\fhem.log
    attr global modpath .
    attr global nofork 1
    attr global port 1234 global
    attr global statefile c:\strawberry\fhem\fhem.save
    attr global verbose 5
    
    define CUL CUL com8@9600 1234
    
    define bathroom FHT 1122
    define bedroom FHT 3344
    define dining FHT 5566
    define hallway FHT 7788
    define living FHT 99aa
    define nursery FHT bbcc
    
    attr bathroom retrycount 3
    attr bedroom retrycount 3
    attr dining retrycount 3
    attr hallway retrycount 3
    attr living retrycount 3
    attr nursery retrycount 3
  7. I've got some additional stuff on my config file, and the port number/device codes are obviously faked, but that's the gist of it.

Test Your FHEM Installation

All that remains is to test your FHEM installation.

  1. Fire up PuTTY (we used this in the previous session to test the COM port)
  2. Select "Telnet" for your connection type
  3. Enter the name of your server and the port number you've configured in your config.txt file
  4. Important - If you don't do this bit, it won't work!  Select the Terminal option on the right, and check the box "Implicit CR in every LF"
  5.  Click Open to open your connection
  6. Assuming you've got no funky firewall issues going on (which I appear to have!), you should now be able to enter the command "help" (might need to append a space to that for some reason), you get a list of FHEM commands returned, and you're done.

Congratulations!

Congratulations, you now have a running instance of FHEM, and complete control over all of your thermostats.


Categories: FHEM
Permalink | Comments (3)

Comments (3) -

Hartmut Germany

01 November 2010 14:09

Hartmut

Hi Russel, thats very nice. But can you tell with this easy words also how I can bring the firmware to the CUL under WindowsXP?

russell United States

01 November 2010 14:14

russell

Hi Hartmut,

I'll try and write a post about flashing the CUL - in brief however I think what I did was to insert the device while pressing in the little button on the underside, then I was able to flash using the Atmel device and the firmware that's referenced on the FHEM site.

Russ

Alex Netherlands

12 January 2011 16:27

Alex

Hi Russel,

Great job! I'm trying to do the same on my standard WHS server. So far so good, but how do I get the frontends to work? Going to localhost:8083/fhem doesn't work. Any ideas?
btw , fhem is working, started and I get response on port 7072 with telnet.

Thanks,
Alex

Pingbacks and trackbacks (1)+

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading