Mac OSX

From Domoticz
Jump to: navigation, search

Purpose of this set is to get Domoticz running on OS X systems. (El Capitan Tested)

This page explains how to build it from source with Homebrew, you can also get ready to run version from http://www.domoticz.com/downloads/ but note that Z-Wave is NOT included in that version, you have to compile it yourself to use Z-Wave or use the unofficial binary.


Preparing your OS X for Domoticz

Get Xcode command line tools

Compiling requires Xcode, which can be installed with command line:

xcode-select --install

It is suggested to installed the Xcode app from the app store (around 3,5 GB). In case you install it, run the app at first once and accept the guarantee terms.
Prior to Domoticz installation, mac can be prepared alternatively with Homebrew or MacPorts.

Homebrew

Homebrew installation

Use commande line:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

In case you have Homebrew already installed make sure is up to date via command line:

brew update
brew upgrade

X11

It is recommended to install X11.app, via XQuartz: [1]

Homebrew installation check

Prior to install libraries, it is better to check Homebrew installation with command:

brew doctor

In case you get the warning:
"You have an outdated version of /usr/bin/install_name_tool installed. This will cause binary package installations to fail. This can happen if you install osx-gcc-installer or RailsInstaller. To restore it, you must reinstall OS X or restore the binary from the OS packages."
do not go ahead until you getit solved. It can happen that some app/tool had modified the "install_name_tool". You can find the proper version of "install_name_tool" for OS X Mavericks (working also for Yosemite) on [2]. Just download it and overwrite on folder /usr/bin/. Run again "brew doctor" and warning should disappear.

Install necessary libraries

Run following command lines in the terminal:

brew install cmake
brew install boost --with-python
brew install boost-python
brew install libusb
brew install libusb-compat
brew install zlib
brew install openssl
brew link openssl --force
brew install python3
brew linkapps python3
brew install lua
luarocks install luasocket
export LDFLAGS=-L/usr/local/opt/openssl/lib
export CPPFLAGS=-I/usr/local/opt/openssl/include

Installing the Stable Binary

Use the Terminal and execute the commands below note that Z-Wave is not included you have to compile that yourself:

mkdir ~/domoticz
cd ~/domoticz
curl -O https://releases.domoticz.com/releases/release/domoticz_osx_x86_64.tgz
tar -zxvf domoticz_osx_x86_64.tgz
rm domoticz_osx_x86_64.tgz

continue at section: Make Domoticz startup at boot time (Also needed for Web Update)

Installing the Beta Binary

Use the Terminal and execute the commands below note that Z-Wave is not included you have to compile that yourself:

mkdir ~/domoticz
cd ~/domoticz
curl -O https://releases.domoticz.com/releases/beta/domoticz_osx_x86_64.tgz
tar -zxvf domoticz_osx_x86_64.tgz
rm domoticz_osx_x86_64.tgz

continue at section: Make Domoticz startup at boot time

Installing Unofficial Binary with Z-Wave

Clean install pre-compiled with openzwave for El Capitan.

domoticz osx 3.5284

this is not an official release but from a forum member: TRiXWooD use at your own risk. It is possible it will run on previous version of OSX, not tested :-)

Installing from Source

Please read carefully!!!

Download Domoticz source

Move to the father folder where you want to install Domoticz and run:

git clone https://github.com/domoticz/domoticz.git domoticz

Compile OpenZWave

You can skip this section about z-wave if you do not use it. If you use Z-Wave the brew version is a very old and z-wave is not standard included in domoticz on OSX so you have to compile it to use Z-Wave, compile it in the same root folder as domoticz (thus not inside the domoticz folder).

git clone https://github.com/OpenZWave/open-zwave.git
ln -s open-zwave open-zwave-read-only
cd open-zwave
make
make install
cd ..

Most people make the mistake to clone open-zwave into the domoticz folder.


DO NOT DO THAT, SERIOUSLY DO NOT DO THAT

Please ensure the SIP protection is disabled on newer OSX (El Capitan, Sierra)

Please make sure that your folder look like this in the terminal

pluto.local:~ Trixwood$ls
domoticz		open-zwave-read-only
open-zwave

With the domoticz and the open-zwave, open-zwave-read-only in the same folder

Compile Domoticz

Before you begin compilling domoticz.

Speed Up

Search and replace in main/Scheduler.cpp and in main/SQLHelper.cpp the following:

"sleep_seconds(1)" to "sleep_milliseconds(50);"

For old systems. If this value is not working for you, try 100 milliseconds or change it back to 1 second.

[3]

LUA Fix

Edit lua/src/luaconf.h

#if defined(LUA_USE_MACOSX)
#define LUA_USE_POSIX
#define LUA_USE_DLOPEN      /* does not need -ldl */
#define LUA_USE_READLINE   /* needs an extra library: -lreadline */
#define LUA_USE_STRTODHEX   /* assume 'strtod' handles hex formats */
#define LUA_USE_AFORMAT      /* assume 'printf' handles 'aA' specifiers */
#define LUA_USE_LONGLONG   /* assume support for long long */
#endif

removed the #if defines and #endif to force right compiler options...

#define LUA_USE_POSIX
#define LUA_USE_DLOPEN      /* does not need -ldl */
#define LUA_USE_READLINE   /* needs an extra library: -lreadline */
#define LUA_USE_STRTODHEX   /* assume 'strtod' handles hex formats */
#define LUA_USE_AFORMAT      /* assume 'printf' handles 'aA' specifiers */
#define LUA_USE_LONGLONG   /* assume support for long long */

[4]

Compile

Compile domoticz with commands:

cd domoticz
cmake -DCMAKE_BUILD_TYPE=Release  -DPYTHON_INCLUDE_DIR=/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/Headers -DPYTHON_LIBRARY=/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/libpython3.5.dylib CMakeLists.txt
make

If the Python version installed by Homebrew changes the Python version numbers will need to be adjusted accordingly. To get a clean version run

sudo make install

unfortunate it is written to the default /opt/domoticz with root owner so you have to move it and own it

sudo mv /opt/domoticz ~
sudo chown -R yourusername:staff ~/domoticz

where yourusername is your user name.

OpenSSL

If you are having problems with openssl, see forum topic or this forum topic

Compiling Domoticz with OpenZWave support for MacOS Sierra (10.12)

Preparations

Follow instructions above for Xcode, Homebrew and X11. Note: if you have compiled openzwave befoe, you’ll see quite a number of warnings when you run brew doctor (notably ’unbrewed’ OpenZWave dylib and header files).

Installing libraries

brew install cmake
brew install boost
brew install boost-python
brew install libusb
brew install libusb-compat
brew install openssl
brew link openssl --force
brew install python3
brew linkapps python3
brew install lua
luarocks install luasocket

Installing and linking openssl comes with a number of warnings and caveats which do not prevent you from completing the finalcompilation of Domoticz successfully.

Download Domoticz and OpenZwave source

Move to the folder where you want to create the Domoticz folder (eg within your home directory).

git clone https://github.com/domoticz/domoticz.git domoticz

The open-zwave directory has to be created in the same folder (next to the domoticz folder).

git clone https://github.com/OpenZWave/open-zwave.git

Compile OpenZwave

Before compiling OpenZWave make sure you disable MacOS’s System Integrity Protection (SIP) (and to return it to its original state after the compilation is completed). This is only required for OpenZWave. Now compile OpenZwave. Please note you are still required to use sudo for make install even while you have disabled SIP.

ln -s open-zwave open-zwave-read-only
cd open-zwave
make
sudo make install
cd ..

Compile Domoticz

You can follow trixwood’s instruction to modify the Domoticz source above (sleep and LUA) but this is not required for a successful compilation. The export statements below replace the original export statements listed above for LDFLAGS and CPPFLAGS.

cd domoticz
export OPENSSL_ROOT_DIR=/usr/local/opt/openssl/
export OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include/
cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_INCLUDE_DIR=/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/Headers -DPYTHON_LIBRARY=/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/libpython3.6m.dylib -DUSE_PYTHON_PLUGINS=NO CMakeLists.txt
make

Note you may have to change the references to the Python folders in the cmake statement depending on your Python version. Simply follow the folders in the Cellar directory to find the correct folders for you.
Now you should have the domoticz executable in the Domoticz folder.

MacOS Sierra Instructions above are a summary of a slightly more detailed description posted in the Domoticz forum

Domoticz start and stop

You can start and stop Domticz via terminal or via script.

From Terminal

This solution will keep terminal busy.

Start Domoticz

Enter domoticz folder and run:

./domoticz

The open Safari and go to webpage: http://localhost:8080

Stop Domoticz

From terminal just press ctrl+z

Make Domoticz startup at boot time

Starting and stopping a OSX script/app can best be done by using launchctl
Create a file named com.domoticz.server.plist in /Library/LaunchAgents:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Disabled</key>
        <false/>
        <key>Label</key>
        <string>com.domoticz.server</string>
        <key>ProgramArguments</key>
        <array>
          <string>/opt/domoticz/domoticz</string>
                <string>-www</string>
                <string>8080</string>
                <string>-log</string>
                <string>/var/log/domoticz.log</string>
                <string>-loglevel</string>
                <string>0</string>
        </array>
        <key>OnDemand</key>
        <false/>
        <key>KeepAlive</key>
        <true/>
        <key>RunAtLoad</key>
        <true/>
        <key>WorkingDirectory</key>
        <string>/opt/domoticz</string>
</dict>
</plist>

Install the launch script with:

launchctl load /Library/LaunchAgents/com.domoticz.server.plist

and start it:

launchctl start com.domoticz.server

Or use a GUI interface: LaunchControl

Not Working

These items will not work tested version 3.48-3.52

Also note that using sockets in LUA is broken in the release version, to fix that compile it yourself :-)

Usefull Links

iMessage Notification

iMessage Notification iMessage

Airplay / iTunes

[5]

Voice Commands: Talk to Domoticz

Voice Commands: Talk to Domoticz (offline, make sure you check that box!) Voice Recognition Voice Commands

Text To Speech (TTS)

Text To Speech (TTS) Text To Speech Config & Text To Speech Command Line

Camera Motion Detection

Camera Motion Detection: You can split one camera into 4, making it possible to detect walk direction with on cheap usb camera, since it uses applescript you can easily communicate with domoticz SecuritySpy [bit.ly/1Tw3Vgj .] and for some fine-tunning Webcam Settings Zone & Walking Direction Motion Sensors

Scripts

Scripts Event Scripts