Guide to iRTrans Server on rPI3

Client tools or tools that can connect with Domoticz. Tools for Windows, iOS, Android, Linux etc.
Post Reply
User avatar
emme
Posts: 644
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi
Domoticz version: latest
Location: Milano, Italy
Contact:

Guide to iRTrans Server on rPI3

Post by emme » Tuesday 05 July 2016 9:07

Hi,

Based on my poor experience in coding in a linux enviroment, I'm quite pround to have been able to install a full function iRTrans server on my rPI3 running Domoticz.
Most of the information here came form a deep reading of the iRTrans nonsupport forum (in deutch! :evil: ... while I'm italian and I don't nothing about german language)
I would like to share my personal guide in order to help other users.

Here's what I did:

SCENARIO
  • Raspberry PI3,
  • Domoticz SD Card image
NEEDS
Use iRTans LAN with NO DB Support to control devices (Sky, air cond/heat split, TV and any other iR Device)
The choice of iRTrans is because... I have this available.... :P

IRSERVER SETUP
In case of device with no buit-in iRDB support, iRTrans can be used via iRServer software.

iRServer, in a linux enviroment, is available in 2 option:
Compiled for x86 and x64 Intel enviroments (rPI is ARM) or Source Code witch need to be recompiled (this is my case)

first I created a temp directory named irserver and another folder named arm under /home/pi and then I downloaded and unpack the server source code

Code: Select all

mkdir /home/pi/irserver
mkdir /home/pi/irserver/arm
cd /home/pi/irserver
wget http://www.irtrans.de/download/Server/Linux/irserver-src.tar.gz
tar -xvf irserver-src.tar.gz 
At this point we should just start compiling the code, BUT, we first need to change few lines in makefile or we will get errors that will stop compiling

Code: Select all

nano makefile
the file will need to looks like this (you can cut/paste and delete the other lines)

Code: Select all

SHELL = /bin/sh

CC = gcc

CFLAGS = 
CPPFLAGS = -DLINUX -DMEDIACENTER
LDFLAGS =
LIBS =
#ODIR = x86
#ODIR64 = x64
ODIRARM = arm

_OBJS = fileio.o linuxserio.o lowlevel.o server.o errormessage.o flashrom.o webserver.o xap.o lanio.o ascii.o mce.o xbmc.o
#OBJS = $(patsubst %,$(ODIR)/%,$(_OBJS))
#OBJS64 = $(patsubst %,$(ODIR64)/%,$(_OBJS))
OBJSARM = $(patsubst %,$(ODIRARM)/%,$(_OBJS))


#irserver: $(OBJS) $(ODIR)/ccf.o 
#	$(CC) $(CFLAGS) $(OBJS) $(ODIR)/ccf.o -m32 -o irserver $(LDFLAGS)

#irserver_noccf: $(OBJS) $(ODIR)/noccf.o
#	$(CC) $(CFLAGS) $(OBJS) $(ODIR)/noccf.o -m32 -o irserver $(LDFLAGS)

#irserver64: $(OBJS64) $(ODIR64)/ccf.o 
#	$(CC) $(CFLAGS) -DX64 $(OBJS64) $(ODIR64)/ccf.o -m64 -o irserver64 $(LDFLAGS)

#irserver64_noccf: $(OBJS64) $(ODIR64)/noccf.o
#	$(CC) $(CFLAGS) -DX64 $(OBJS64) $(ODIR64)/noccf.o -m64 -o irserver64 $(LDFLAGS)

#irserver_arm: $(OBJSARM) $(ODIRARM)/ccf.o 
#	$(CC) $(CFLAGS) $(OBJSARM) $(ODIRARM)/ccf.o -o irserver $(LDFLAGS)

irserver_arm_noccf: $(OBJSARM) $(ODIRARM)/noccf.o 
$(CC) $(CFLAGS) $(OBJSARM) $(ODIRARM)/noccf.o -o irserver $(LDFLAGS)

#all: irserver irserver64

#arm: irserver_arm

arm_noccf: irserver_arm_noccf

clean:
#	-rm $(OBJS) x86/noccf.o
#	-rm $(OBJS64) x64/noccf.o
-rm $(OBJSARM) arm/noccf.o


#$(ODIR)/%.o: %.c dbstruct.h fileio.h lowlevel.h network.h serio.h pictures.h remote.h makefile
#	$(CC) $(CPPFLAGS) $(CFLAGS) -m32 -c $< -o [email protected]


#$(ODIR64)/%.o: %.c dbstruct.h fileio.h lowlevel.h network.h serio.h pictures.h remote.h makefile
#	$(CC) $(CPPFLAGS) $(CFLAGS) -DX64 -m64 -c $< -o [email protected]

$(ODIRARM)/%.o: %.c dbstruct.h fileio.h lowlevel.h network.h serio.h pictures.h remote.h makefile
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o [email protected]

irclient: client.c
$(CC) $(CPPFLAGS) $(CFLAGS) client.c -o irclient $(LDFLAGS)
Please note that you MUST indent with a TAB as shown
save and overwrite the file with CTRL-X

we are now ready to compile:

Code: Select all

sudo make
you maybe could get some warnings, but don't care...
if everythig went fine you should have irserver file in the current directory

irserver came with a internal www server witch is almost useless and crash often
a simple syntax to test it is: irserver <irTransLAN ip address>
try to run it, but first have it executable:

Code: Select all

sudo chmod +x irserver
sudo ./irserver 192.168.0.124
if you don't get any error.... we are supposed it is running, and it would be a good idea to running it as a daemon

Code: Select all

sudo ./irserver -daemon 192.168.0.124
IrServer to be used needs the GUICient (available for Mono/Windows/Mac) to learn iRCodes and populare the irDB on the server side
GUIClient use in quite simple, I will not talk about it here, but you can read the handbook

IRCLIENT SETUP
once you have learned all the needed irCodes and organized them in remote/commands, it's time to install irClient witch is needed to send commands to the server.
Like for the server, irClient for ARM cames in source code and needs to be compiled.
The process is almost the same:

Code: Select all

mkdir /home/pi/irclient
mkdir /home/pi/irclient/arm
cd /home/pi/irclient
wget http://www.irtrans.de/download/Client/irclient-src.tar.gz
tar -xvf irclient-src.tar.gz
now edit makefile

Code: Select all

nano makefile
and have it like this (you can copy this and delete the old lines)

Code: Select all

SHELL = /bin/sh

CC = gcc

CFLAGS = 
CPPFLAGS = -DLINUX 
LDFLAGS =
LIBS =
#ODIR = x86
#ODIR64 = x64
ODIRARM = arm

_OBJS = client.o
#OBJS = $(patsubst %,$(ODIR)/%,$(_OBJS))
#OBJS64 = $(patsubst %,$(ODIR64)/%,$(_OBJS))
OBJSARM = $(patsubst %,$(ODIRARM)/%,$(_OBJS))


#irclient: $(OBJS) 
#	$(CC) $(CFLAGS) $(OBJS) -m32 -o irclient $(LDFLAGS)

#irclient64: $(OBJS64)
#	$(CC) $(CFLAGS) -DX64 $(OBJS64) -m64 -o irclient64 $(LDFLAGS)

irclient_arm: $(OBJSARM)
	$(CC) $(CFLAGS) $(OBJSARM) -o irclient $(LDFLAGS)


all: irclient irclient64

arm: irclient_arm


clean:
#	-rm $(OBJS)
#	-rm $(OBJS64)
	-rm $(OBJSARM)


#$(ODIR)/%.o: %.c flash.h errcode.h network.h remote.h makefile
#	$(CC) $(CPPFLAGS) $(CFLAGS) -m32 -c $< -o [email protected]


#$(ODIR64)/%.o: %.c flash.h errcode.h network.h remote.h makefile
#	$(CC) $(CPPFLAGS) $(CFLAGS) -DX64 -m64 -c $< -o [email protected]

$(ODIRARM)/%.o: %.c  flash.h errcode.h network.h remote.h makefile
	$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o [email protected]
Remeber to indent with a TAB, save with CTRL-X , confirm overwrite
now, let's compile it!

Code: Select all

sudo make
we're almost done!...

now let's make it executable

Code: Select all

sudo chmod +x irclient
it's now time to test it!
the syntax is simple: irclient <ip> <remote> <command> where:
  • ip: the SERVER ip address (127.0.0.1 is your're running ir server on the same rPI), not hte LAN device ;)
  • remote: remote name you use in the GUI Client (ie: myskyhd)
  • command: learned irCode name under GUIClient (ie: KEY_POWER)
so the command should looks like

Code: Select all

./irclient 127.0.0.1 myskyhd KEY_POWER
that's all!

now let's integrate it in Domoticz! :D
after having create a virtual switch and named as you like (mine is 'TestIR'), create a LUA script (under events) name script_device_<something>.lua witch contain:

Code: Select all

commandArray = {}

- - change the name of the sensor
local sensor = 'TestIR'

if (devicechanged[sensor] == 'On') then
    os.execute ("/home/pi/irclient/irclient 127.0.0.1 myskyhd KEY_POWER")
end

return commandArray
...that's all
I home this would help!
ciao
M
That's one small step for a programmer, one giant leap for me!
- - - - -
Raspberry Pi3 + AeonStick G5 + RFXCOMM433 + iRTrans Server + NodeJS
There's no stress in the mess!!

User avatar
emme
Posts: 644
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Guide to iRTrans Server on rPI3

Post by emme » Tuesday 05 July 2016 9:34

uh.. I forgot....
I'm too much newbe to add instruction about how to run irserver at startup... if someone could integrate it I would really appreciate :P :P

=== EDIT ===
ok... I've just added the irserver startup string in the /etc/rc.local :P :P
That's one small step for a programmer, one giant leap for me!
- - - - -
Raspberry Pi3 + AeonStick G5 + RFXCOMM433 + iRTrans Server + NodeJS
There's no stress in the mess!!

schoe024
Posts: 10
Joined: Wednesday 10 June 2015 16:19
Target OS: Windows
Domoticz version:
Contact:

Re: Guide to iRTrans Server on rPI3

Post by schoe024 » Thursday 25 August 2016 8:18

Running server as a deamon: do I need to setup 1 line for every irtrans unit? Or wil -LAN work?
Thank you for all the work you did. Very happy that now IRSERVER is working with domoticz

User avatar
emme
Posts: 644
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Guide to iRTrans Server on rPI3

Post by emme » Sunday 28 August 2016 20:17

I got just one, so I don't really know... but running with LAN parameters hould issue the command to all IR device available in the network
That's one small step for a programmer, one giant leap for me!
- - - - -
Raspberry Pi3 + AeonStick G5 + RFXCOMM433 + iRTrans Server + NodeJS
There's no stress in the mess!!

schoe024
Posts: 10
Joined: Wednesday 10 June 2015 16:19
Target OS: Windows
Domoticz version:
Contact:

Re: Guide to iRTrans Server on rPI3

Post by schoe024 » Saturday 17 September 2016 13:47

What exactly did you put in /etc/rc.local?

User avatar
emme
Posts: 644
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Guide to iRTrans Server on rPI3

Post by emme » Sunday 18 September 2016 21:04

./home/pi/irtrans/irserver -daemon 192.168.0.14 &

the IP represent my irtrans LAN device
That's one small step for a programmer, one giant leap for me!
- - - - -
Raspberry Pi3 + AeonStick G5 + RFXCOMM433 + iRTrans Server + NodeJS
There's no stress in the mess!!

schoe024
Posts: 10
Joined: Wednesday 10 June 2015 16:19
Target OS: Windows
Domoticz version:
Contact:

Re: Guide to iRTrans Server on rPI3

Post by schoe024 » Monday 19 September 2016 1:39

Thx a lot, now it is working. No experience with ubuntu, just followed your instructions.

schoe024
Posts: 10
Joined: Wednesday 10 June 2015 16:19
Target OS: Windows
Domoticz version:
Contact:

Re: Guide to iRTrans Server on rPI3

Post by schoe024 » Wednesday 15 February 2017 13:08

Now we can sent ir commands from domoticz.
But is there a way to update the virtual switch based on received ir code?

User avatar
emme
Posts: 644
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Guide to iRTrans Server on rPI3

Post by emme » Thursday 16 February 2017 9:15

I don't think the receiver led can be used for other purpuse than learning ir codes.

This question should be addressed to irTrans directly :P

ciao
M
That's one small step for a programmer, one giant leap for me!
- - - - -
Raspberry Pi3 + AeonStick G5 + RFXCOMM433 + iRTrans Server + NodeJS
There's no stress in the mess!!

User avatar
emme
Posts: 644
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Guide to iRTrans Server on rPI3

Post by emme » Thursday 02 March 2017 9:47

at least I were able to create correctly the service for the iRserver... here's the How-To:

create the service file that would be store in /lib/systems/system/

Code: Select all

sudo nano /lib/systemd/system/irServer.service
copy into the following lines, check the right path and the right IP Address of your irTrans device

Code: Select all

[Unit]
Description=irTrans irServer Daemon
After=multi-user.target

[Service]
User=root
ExecStart=/home/pi/irserver/irserver -logfile /home/pi/irserver/irserver.log <Ip of Device>

[Install]
WantedBy=multi-user.target
save with Ctrl-X and confirm with Y
(note that the service should be NOT called with the -daemon option, otherwise it will fail)

now make it executable with:

Code: Select all

sudo chmod +x /lib/systemd/system/irserver.service
refresh the systemctl service, enable the service and start it

Code: Select all

sudo systemctl daemon-reload
sudo systemctl enable irserver.service
sudo systemctl start irserver.service
check the status with

Code: Select all

systemctl status irserver
it should be running, if not check the log file (mine is in /home/pi/irserver/irserver.log )
it is already up and running but if you want you can reboot the PI
ciao
M
That's one small step for a programmer, one giant leap for me!
- - - - -
Raspberry Pi3 + AeonStick G5 + RFXCOMM433 + iRTrans Server + NodeJS
There's no stress in the mess!!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest