FHEM on OS X: Unterschied zwischen den Versionen

Aus FHEMWiki
K (Correct missing reference)
 
(8 dazwischenliegende Versionen von 6 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
Most of the the time Fhem is installed on Linux based systems. That could be the reason why most of the HowTos, FAQs and Tips are dealing with Unix issues. As you may know, Apple's OS X is based on Unix as well and it is no big deal to run Fhem on OS X.
Most of the the time FHEM is installed on Linux based systems. That could be the reason why most of the HowTos, FAQs and Tips are dealing with Unix issues. As you may know, Apple's OS X is based on FreeBSD (a UNIX derivate) which is similar to Linux to some extent and therefore it is no big deal to run '''FHEM on OS X'''.


 
In some sections an alternate (and simplified) installation method is also described and marked with "'''Simpler:'''"
= HOWTO install Fhem on OS X =
== Description ==
This HOWTO describes the necessary steps to install Fhem on a Mac running OS X. Especially Fhem in combination with the FHZ 1000 Device.


== Overview ==
== Overview ==
To install Fhem on a Mac, you have to follow these steps:
To install FHEM on a Mac, you have to follow these steps:
 
* Install USB Driver for FHZ 1X00 PC
* Install USB Driver for FHZ 1X00 PC
* Install the C Compiler from XTools
* Install the C Compiler from XTools
* Install SerialPort Sources from CPAN
* Install SerialPort Sources from CPAN
* Modify Fhem Makefile
* Modify FHEM Makefile
* Install Fhem
* Install FHEM
 
== USB Driver for FHZ 1X00 PC ==
== USB Driver for FHZ 1X00 PC ==
FHZ 1000 PC (and the newer version FHZ 1300 PC) is an interface device between the FS20 radio protocol and a PC via an USB interface.
[[FHZ 1000]] PC (and the newer version [[FHZ_nn00|FHZ 1300 PC]]) is an [[Interface|interface]] device between the FS20 radio protocol and a PC via an USB interface. FHZ 1000 PC has a fairly straight forward structure based on standard components. It is built around a PIC16F628 processor and uses a FT232AM (FT8U232AM) chip from FTDI for USB communication. The vendor of this chip provides drivers for Mac OS X 10.3, 10.4, 10.5 and 10.6. Please download and install the most recent version from their website: [http://www.ftdichip.com/Drivers/VCP.htm FTDIUSBSerialDriver]
FHZ 1000 PC has a fairly straight forward structure based on standard components. It is build around a PIC16F628 processor and uses a FT232AM (FT8U232AM) chip from FTDI for USB communication.
The vendor of this chip provides drivers for Mac OS X 10.3, 10.4, 10.5 and 10.6. Please download and install the most recent version from their website: [http://www.ftdichip.com/Drivers/VCP.htm FTDIUSBSerialDriver]


When the computer has rebooted, plug in the device and check if the device is installed properly.  
When the computer has rebooted, plug in the device and check if the device is installed properly.  
Take a look at the the OS X System Logfile (/var/log/system.log). The FHZ1000 device should recognize by the system as follows:
Take a look at the the OS X System Logfile (/var/log/system.log). The FHZ1000 device should have been recognized by the system as follows:
:<code>kernel [0]: FTDIUSBSerialDriver: 0 403f06f start - ok</code>


<nowiki>kernel [0]: FTDIUSBSerialDriver: 0 403f06f start - ok</nowiki>
If not, please check the device and the USB cable on a different system (e.g. Linux &gt; 2.6).
If not, please check the device and the USB cable on a different system (e.g. Linux &gt; 2.6).


After that, you will see two entries in the ''/dev''directory. To check this, open the OS X Terminal Application and execute the following command:
After that, you will see two entries in the ''/dev''directory. To check this, open the OS X Terminal application and execute the following command:


  <nowiki>$ls /dev/cu.*
  $ls /dev/cu.*
/dev/cu.usbserial-xxxxxxxx
/dev/cu.usbserial-xxxxxxxx
$ls /dev/tty.*
$ls /dev/tty.*
/dev/tty.usbserial-xxxxxxxx</nowiki>
/dev/tty.usbserial-xxxxxxxx
where ''xxxxxxxx''is either the device's serial number.


Now you can talk to the box via ''/dev/tty.usbserial-xxxx''using the FS20 Protocol.
where ''xxxxxxxx''is the device's serial number.
 
Now you can talk to the box via ''/dev/tty.usbserial-xxxx'' using the FS20 Protocol.


=== Symbolic Link to ttyUSB0 ===
=== Symbolic Link to ttyUSB0 ===
Because Fhem is talking to the device using ''/dev/ttyUSB0', for better handling you should define a symbolic link: ''Open the OS X Terminal Application and execute the following command:
Because FHEM is talking to the device using ''/dev/ttyUSB0'', for better handling you should define a symbolic link: Open the OS X Terminal Application and execute the following command:
 
:<code>$ sudo ln -s /dev/tty.usbserial-xxxxxx /dev/ttyUSB0</code>
<nowiki>$ sudo ln -s /dev/tty.usbserial-xxxxxx /dev/ttyUSB0</nowiki>
'''NOTE!'''Under specific circumstances, the symlink disappears after a reboot.
If someone can solve this issue or know the reason for that, please edit this paragraph!
 
 


The issue can simply be fixed by specifying the /dev/cu.usbmodem-xxxx instead of /dev/ttyUSB0 as the serial device in fhem.cfg.
'''NOTE!''': Under specific circumstances, the symlink disappears after a reboot. If someone can solve this issue or knows the reason for that, please edit this paragraph!


The issue can simply be fixed by specifying the /dev/cu.usbmodem-xxxx instead of /dev/ttyUSB0 as the serial device in the FHEM [[Konfiguration|configuration]].


OS X will give each device a unique device name. a device that is unplugged and reconnected will receive the same device file. so these unique names should be used in fhem instead of the symbolic links.
'''Simpler:''' OS X will give each device a unique device name. a device that is unplugged and reconnected will receive the same device file, so these unique names should be used in fhem instead of the symbolic links.


== GNU C Compiler ==
== GNU C Compiler ==
Apple's brand-name for the 'developer tools' is 'XCode Tools', it is GCC and a few other bits and bobs. To install it is a simple matter, you simply install the package on your OS X DVD. I'm led to believe the CD version of Mac OS X has a dedicated CD called 'X-Code Tools'.
Apple's brand-name for the 'developer tools' is 'XCode Tools', it is GCC and a few other bits and bobs. To install it is a simple matter, you simply install the package on your OS X DVD. I'm led to believe the CD version of Mac OS X has a dedicated CD called 'X-Code Tools'. If you have lost the DVD already then you can download X-code tools from [http://developer.apple.com/technologies/xcode.html Apple's website]. Although you must sign-in to be able to to get the file.
If you have lost the DVD already then you can download X-code tools from [http://developer.apple.com/technologies/xcode.html Apple's website]. Although you must sign-in to be able to to get the file.
 


'''NOTE!'''Always make sure to install the latest available version of Xcode Tools for your Mac OS X release; using outdated versions of Xcode Tools may cause port install failures. Also note that Xcode Tools are not updated via Mac OS X's Software Update utility.
'''NOTE''': Always make sure to install the latest available version of Xcode Tools for your Mac OS X release; using outdated versions of Xcode Tools may cause port install failures. Also note that Xcode Tools are not updated via Mac OS X's Software Update utility.


* Run the Xcode Tools package installer.
* Run the Xcode Tools package installer.
Zeile 60: Zeile 50:
* Ensure that the option for command line development, which is labeled Unix Development in the Xcode 3.x installer, is checked.
* Ensure that the option for command line development, which is labeled Unix Development in the Xcode 3.x installer, is checked.


 
== SerialPort Perl Module ==
 
== SerialPort Perl Modul ==
SerialPort for Linux is a user interface to Serial API calls. The module provides an object-based user interface essentially identical to the one provided by the Win32::SerialPort module.
SerialPort for Linux is a user interface to Serial API calls. The module provides an object-based user interface essentially identical to the one provided by the Win32::SerialPort module.
To install this modul you can get the right sources from the CPAN Website.
To install this module you can get the right sources from the CPAN Website.


Open the OS X Terminal Application and execute the following command:
Open the OS X Terminal Application and execute the following command:
 
:<code>sudo perl –MCPAN –e shell</code>
<nowiki>sudo perl –MCPAN –e shell</nowiki>
If you do this the first time, Perl may ask you a few questions... just enter YES. At the end you will read something like ''cpan shell -- CPAN exploration and modules installation (v1.9205)''. Within the CPAN Shell, you have to execute the following two commands:  
If you do this the first time, Perl may ask you a few questions... just enter YES.
At the end you will read something like ''cpan shell -- CPAN exploration and modules installation (v1.9205)''. Within the CPAN Shell, you have to execute the following two commands:  


  <nowiki>[cpan[1]&gt;] install Bundle::CPAN
  <nowiki>[cpan[1]&gt;] install Bundle::CPAN
[cpan[1]&gt;] install Device::SerialPort
[cpan[1]&gt;] install Device::SerialPort
[cpan[1]&gt;] quit</nowiki>
[cpan[1]&gt;] quit</nowiki>
=== Some testing ===
=== Some testing ===
Now you should be ready to use the Module ''Device::SerialPort''. If have already configured your Hardware (CUN, CUL, FHZ1000...) you can check the functionality with a little Perl script:
Now you should be ready to use the Module ''Device::SerialPort''. If you have already configured your hardware (CUN, CUL, FHZ1000...) you can check the functionality with a little Perl script:
[http://fhz4linux.info/tiki-download_file.php?fileId=4 elv.pl]
[http://fhz4linux.info/tiki-download_file.php?fileId=4 elv.pl]


Zeile 88: Zeile 75:
Got: 4c09 [2]</nowiki>
Got: 4c09 [2]</nowiki>


 
== Install FHEM ==
== Install Fhem ==
Download the most recent version of FHEM from [http://www.fhem.de Rudi's Website],
Download the most recent version of Fhem from [http://www.koeniglich.de/fhem/fhem.html Rudi's Website].
extract the archive, and install the Software as described.
Extract the archive and install the Software as described on the Website.  


You most likely will have fhem installed in some custom directory, so you need to adapt the first lines in the Makefile, for example change to:
You most likely will have fhem installed in some custom directory, so you need to adapt the first lines in the Makefile, for example change to:
Zeile 104: Zeile 90:


  <nowiki>sudo make install-pgm2</nowiki>
  <nowiki>sudo make install-pgm2</nowiki>


Comment fhainz:
Comment fhainz:
Zeile 116: Zeile 101:
works on OSX 10.9.1
works on OSX 10.9.1


'''Simpler:''' just unpack the source tar and move/rename the unpacked top-level directory to the location that you want. keep all subdirectories as they are.


=== Modify fhem.cfg ===
=== Modify fhem.cfg ===
You have to modify the main configuration file on your personal effort.  
You have to modify the main configuration file on your personal effort.  
There are many samples an descriptions on the web...
There are many samples and descriptions on the web...


== Run Fhem ==
== Run FHEM ==
To make sure that Fhem Server is starting on every Reboot, just place a start script under /Library/StartupItems.
To make sure that FHEM Server is starting on every Reboot, just place a start script under /Library/StartupItems.


Create a startup script:
Create a startup script:


=== Launchd ===
=== Launchd ===
The more modern way would be to create a lauch daemon like the following example.
The more modern way would be to create a launch daemon like the following example.


  <nowiki>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  <nowiki>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
Zeile 153: Zeile 139:
You might run into some permission problems if not running fhem as "root", but running as root is not a good idea, so go out and fix the file permissions for the user fhem runs as.
You might run into some permission problems if not running fhem as "root", but running as root is not a good idea, so go out and fix the file permissions for the user fhem runs as.


'''Simpler:''' the tar file referenced in this {{Link2Forum|Topic=19989|Message=142757|LinkText=forum post}} can be unpacked to <code>/Library/StartupItems</code>. In <code>/Library/StartupItems/FHEM/FHEM</code> the path and fhemuser should be adjusted to your installation.


[[Kategorie:HOWTOS]]
[[Kategorie:HOWTOS]]
[[Kategorie:OSX]]
[[Kategorie:OSX]]

Aktuelle Version vom 6. Februar 2018, 21:39 Uhr

Most of the the time FHEM is installed on Linux based systems. That could be the reason why most of the HowTos, FAQs and Tips are dealing with Unix issues. As you may know, Apple's OS X is based on FreeBSD (a UNIX derivate) which is similar to Linux to some extent and therefore it is no big deal to run FHEM on OS X.

In some sections an alternate (and simplified) installation method is also described and marked with "Simpler:"

Overview

To install FHEM on a Mac, you have to follow these steps:

  • Install USB Driver for FHZ 1X00 PC
  • Install the C Compiler from XTools
  • Install SerialPort Sources from CPAN
  • Modify FHEM Makefile
  • Install FHEM

USB Driver for FHZ 1X00 PC

FHZ 1000 PC (and the newer version FHZ 1300 PC) is an interface device between the FS20 radio protocol and a PC via an USB interface. FHZ 1000 PC has a fairly straight forward structure based on standard components. It is built around a PIC16F628 processor and uses a FT232AM (FT8U232AM) chip from FTDI for USB communication. The vendor of this chip provides drivers for Mac OS X 10.3, 10.4, 10.5 and 10.6. Please download and install the most recent version from their website: FTDIUSBSerialDriver

When the computer has rebooted, plug in the device and check if the device is installed properly. Take a look at the the OS X System Logfile (/var/log/system.log). The FHZ1000 device should have been recognized by the system as follows:

kernel [0]: FTDIUSBSerialDriver: 0 403f06f start - ok

If not, please check the device and the USB cable on a different system (e.g. Linux > 2.6).

After that, you will see two entries in the /devdirectory. To check this, open the OS X Terminal application and execute the following command:

$ls /dev/cu.*
/dev/cu.usbserial-xxxxxxxx
$ls /dev/tty.*
/dev/tty.usbserial-xxxxxxxx

where xxxxxxxxis the device's serial number.

Now you can talk to the box via /dev/tty.usbserial-xxxx using the FS20 Protocol.

Symbolic Link to ttyUSB0

Because FHEM is talking to the device using /dev/ttyUSB0, for better handling you should define a symbolic link: Open the OS X Terminal Application and execute the following command:

$ sudo ln -s /dev/tty.usbserial-xxxxxx /dev/ttyUSB0

NOTE!: Under specific circumstances, the symlink disappears after a reboot. If someone can solve this issue or knows the reason for that, please edit this paragraph!

The issue can simply be fixed by specifying the /dev/cu.usbmodem-xxxx instead of /dev/ttyUSB0 as the serial device in the FHEM configuration.

Simpler: OS X will give each device a unique device name. a device that is unplugged and reconnected will receive the same device file, so these unique names should be used in fhem instead of the symbolic links.

GNU C Compiler

Apple's brand-name for the 'developer tools' is 'XCode Tools', it is GCC and a few other bits and bobs. To install it is a simple matter, you simply install the package on your OS X DVD. I'm led to believe the CD version of Mac OS X has a dedicated CD called 'X-Code Tools'. If you have lost the DVD already then you can download X-code tools from Apple's website. Although you must sign-in to be able to to get the file.

NOTE: Always make sure to install the latest available version of Xcode Tools for your Mac OS X release; using outdated versions of Xcode Tools may cause port install failures. Also note that Xcode Tools are not updated via Mac OS X's Software Update utility.

  • Run the Xcode Tools package installer.
  • Click the button Customize, expand the Applications category and click the check box beside X11 SDK to add it to the default items.
  • Ensure that the option for command line development, which is labeled Unix Development in the Xcode 3.x installer, is checked.

SerialPort Perl Module

SerialPort for Linux is a user interface to Serial API calls. The module provides an object-based user interface essentially identical to the one provided by the Win32::SerialPort module. To install this module you can get the right sources from the CPAN Website.

Open the OS X Terminal Application and execute the following command:

sudo perl –MCPAN –e shell

If you do this the first time, Perl may ask you a few questions... just enter YES. At the end you will read something like cpan shell -- CPAN exploration and modules installation (v1.9205). Within the CPAN Shell, you have to execute the following two commands:

[cpan[1]>] install Bundle::CPAN
[cpan[1]>] install Device::SerialPort
[cpan[1]>] quit

Some testing

Now you should be ready to use the Module Device::SerialPort. If you have already configured your hardware (CUN, CUL, FHZ1000...) you can check the functionality with a little Perl script: elv.pl

As a result, you will get something link this:

# ./elv.pl 
Sending ...8106c98602011f64 
Got: 810bc93b01021f0278075c44f8 [0]
Sending ...810804afc90184570208 Result: 10
Got: 810fc9ae010284010807f8136e3118 [1]
Got: 4c09 [2]

Install FHEM

Download the most recent version of FHEM from Rudi's Website, extract the archive, and install the Software as described.

You most likely will have fhem installed in some custom directory, so you need to adapt the first lines in the Makefile, for example change to:

BINDIR=/usr/local/bin
MODDIR=/usr/local/share/fhem
VARDIR=/var/log/fhem
DOCDIR=/usr/local/share/doc/fhem
MANDIR=/usr/local/share/man/man1
ETCDIR=/usr/local/etc

Open the OS X Terminal Application and execute the following command:

sudo make install-pgm2

Comment fhainz:

sudo make install-pgm2 won't work. --> make: *** No rule to make target `install-pgm2'. Stop.

This

 sudo make install

works on OSX 10.9.1

Simpler: just unpack the source tar and move/rename the unpacked top-level directory to the location that you want. keep all subdirectories as they are.

Modify fhem.cfg

You have to modify the main configuration file on your personal effort. There are many samples and descriptions on the web...

Run FHEM

To make sure that FHEM Server is starting on every Reboot, just place a start script under /Library/StartupItems.

Create a startup script:

Launchd

The more modern way would be to create a launch daemon like the following example.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
    "[http://www.apple.com/DTDs/PropertyList-1.0.dtd http://www.apple.com/DTDs/PropertyList-1.0.dtd]">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>de.fhemwiki.fhem</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/perl</string>
        <string>/usr/local/bin/fhem.pl</string>
        <string>/usr/local/etc/fhem.cfg</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>UserName</key>
    <string>YOURUSERNAMETORUNFHEM</string>
</dict>
</plist>

Save this to a file named de.fhemwiki.fhem.plist in the directory /Library/LaunchDaemons/ For this to work, you must add "attr global nofork 1" to fhem.cfg.

You might run into some permission problems if not running fhem as "root", but running as root is not a good idea, so go out and fix the file permissions for the user fhem runs as.

Simpler: the tar file referenced in this forum post can be unpacked to /Library/StartupItems. In /Library/StartupItems/FHEM/FHEM the path and fhemuser should be adjusted to your installation.