Daikin integration

All kinds of 'OS' scripts
peterpijpelink
Posts: 8
Joined: Sunday 22 February 2015 20:09
Target OS: OS X
Domoticz version:
Contact:

Daikin integration

Post by peterpijpelink » Sunday 22 February 2015 20:16

On the OpenHab https://github.com/openhab/openhab/wiki/Daikin-Binding functions I see a solution to integrate a Daikin airco/heatpump into their product. They use the wifi module which is connected to this unit. Could this also work with Domoticz ? Can Domoticz ' listen' to a website using GET and PUT commands? I have this Daikin unit and would like to see this working in Domoticz. Anyone has an idea how to make this work?

Philos31
Posts: 48
Joined: Friday 15 August 2014 22:37
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Daikin integration

Post by Philos31 » Wednesday 04 March 2015 23:09

Here is a bash script with 2 lua scripts to intergrade the Daikin Heat Pumps/Airconditioners with the Wi-Fi Online Controller Daikin BRP069Axx

Only heating is supported as of now, if I have some more time I will also make cooling functions, but I am waiting for an heat/cool/off button.
Before it is 30C in the Netherlands cooling will be supported :lol:

This script will not work on Windows, but should be working on all linux systems. I use it on raspberry pi.
Installation instructions are for Raspberry Pi:

For this script to run, you need to install Curl and JQ.

SSH into your pi and:
first we install curl:

Code: Select all

sudo apt-get install curl
Then we need JQ, as there is no binary for the pi, we need to build it ourselfs, no worry, thanks to the wiki we know how to:

(Taken from the Mindergas.nl wikipage)

Install the tools so you can build yourself:

Code: Select all

sudo apt-get install flex -y
sudo apt-get install bison -y
sudo apt-get install gcc -y
sudo apt-get install make -y
sudo apt-get install autotools -y
Now we are going to build JQ

Code: Select all

curl -O http://stedolan.github.io/jq/download/source/jq-1.4.tar.gz
tar xfvz jq-1.4.tar.gz
cd jq-1.4
./configure
make
sudo make install
this will make jq and take some time, on my raspberry pi 2 it took only a few minutes, but on a pi 1 it could take (much) longer. Be patient.

Copy jq to /usr/bin

Code: Select all

cp jq /usr/bin
Now download the zip file and extract the 3 scripts.
Put daikin.sh in /home/pi/domoticz/scipts
then make it executable

Code: Select all

sudo chmod +x /home/pi/domoticz/scipts/daikin.sh
put the lua scripts in /home/pi/domoticz/scipts/lua

No open domoticz in your webbrowser, go to setup and then hardware.
We are going to make a new Dummy device, make sure enabled is on.
Name: Daikin
Type: Dummy (Does nothing, use for virtual switches only)

press Add

You will have the new hardware called Daikin in your list. Now click create virtual sensors behind your newly created hardware.
From the dropdownlist choose Thermostat Setpoint and click add.
Create another virtual sensor and select switch.

Now go to setup-> devices sort the list descending on IDX, you will see the newly created sensors in the top of the list. Note down the IDX number of both, you will need them later on.
On the right side of the new sensors you will see a blue green arrow, click them so the become blue, the devices will now be visible on the tabs in Domoticz.
Find the temperature device in "utility" and give it the name "DaikinTemp" (if you want another name, you need to also change the Lua script)
Find the on off device in switches and name it "DaikinHeat"

Now in your ssh session type

Code: Select all

sudo nano /home/pi/domoticz/scipts/daikin.sh
and change the settings:

Code: Select all

# Daikin IP Adress
	DIP=192.168.1.xx                                         #Put the ip adress of your Daikin wifi controller here

# Domoticz port
	DomPort=8080                                               #If domoticz is running on a different port then change it here

# On/Off button idx
	OoIdx=xx                                                      # The IDX of your DaikinHeat on of switch

# Temp idx
	TempIdx=xx                                                  # The IDX of your DaikinTemp Virtual Thermostat
save the file (ctrl x and then yes)

Now we need to make domoticz check the daikin to see if it has been operated with the remote or daikin app and mirror these changes in domoticz.

Code: Select all

sudo crontab -e
scroll to the bottom and add this line:

Code: Select all

*/1 * * * * /home/pi/domoticz/scripts/daikin.sh check &
This will check the state of the daikin every minute, if you want it less frequent you can change the 1 (after */) in the number of minutes you want to check.

Thats it, now you can have fun, schedule, make blockly thingies etc...

Let me know if it helped you, or if you have other great ideas.
Attachments
DaikinControll.zip
(1.95 KiB) Downloaded 259 times
Last edited by Philos31 on Friday 27 March 2015 19:12, edited 3 times in total.
RasPi2/KaKu/MiLight/HomeEasy/Impuls/Byron/Daikin 3,5kw Ururu Sarara all working together with domoticz

pcc9
Posts: 12
Joined: Tuesday 17 March 2015 16:00
Target OS: Raspberry Pi
Domoticz version:
Contact:

Daikin integration

Post by pcc9 » Tuesday 17 March 2015 16:06

I would also be very interested, as I have Daikin pump heater and newbee in programmation...

robhuls
Posts: 32
Joined: Monday 23 March 2015 20:20
Target OS: Raspberry Pi
Domoticz version: beta
Location: Zwolle
Contact:

Re: Daikin integration

Post by robhuls » Friday 27 March 2015 14:13

My Wifi module is currently on its way, I hope to use this to link the Daikin to Domoticz to create some really fancy automation!

pcc9
Posts: 12
Joined: Tuesday 17 March 2015 16:00
Target OS: Raspberry Pi
Domoticz version:
Contact:

Daikin integration

Post by pcc9 » Monday 30 March 2015 18:11

Hi Philos,
thanks a lot for these scripts. It seems there are some issues in the shell code as it returns errors when I try to execute it. line 82, line 86 then line 93.
it also seems that the Domoticz adress in you case is 127.0.0.1 but should be a parameter.

I am not expert enough to make some good changes.

It doesn't seems to communicate with my daikin.

Philos31
Posts: 48
Joined: Friday 15 August 2014 22:37
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Daikin integration

Post by Philos31 » Monday 30 March 2015 19:52

pcc9 wrote:Hi Philos,
thanks a lot for these scripts. It seems there are some issues in the shell code as it returns errors when I try to execute it. line 82, line 86 then line 93.
it also seems that the Domoticz adress in you case is 127.0.0.1 but should be a parameter.

I am not expert enough to make some good changes.

It doesn't seems to communicate with my daikin.

thanks for your help,
regards,
Hi pcc9, 127.0.0.1 is the backloop adress, so the machine you are running the script on, this should be allright.
Can you run the script from the command line and see what errors you get?
RasPi2/KaKu/MiLight/HomeEasy/Impuls/Byron/Daikin 3,5kw Ururu Sarara all working together with domoticz

User avatar
ThinkPad
Posts: 1754
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Daikin integration

Post by ThinkPad » Monday 30 March 2015 21:31

Philos31 created a nice wiki page for the script he created, it can be found here: http://www.domoticz.com/wiki/Daikin_wifi

Good work this script!
ThinkTheme - theme for Domoticz
My (Dutch) blog: http://thinkpad.tweakblogs.net - My Domoticz scripts: Bitbucket
I'm not (very) active anymore on this forum as i don't use Domoticz anymore.

pcc9
Posts: 12
Joined: Tuesday 17 March 2015 16:00
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Daikin integration

Post by pcc9 » Wednesday 01 April 2015 15:53

Hi,
here is the result of the execution of the script:

sudo ./daikin.sh
./daikin.sh: eval: line 57: unexpected EOF while looking for matching `]'
./daikin.sh: eval: line 58: syntax error: unexpected end of file
./daikin.sh: eval: line 70: unexpected EOF while looking for matching `]'
./daikin.sh: eval: line 71: syntax error: unexpected end of file
./daikin.sh: line 76: [: =: unary operator expected
./daikin.sh: line 82: [: =: unary operator expected
./daikin.sh: line 88: [: =: unary operator expected
curl: (7) couldn't connect to host

I followed exactly your tuto but communication with the Daikin pump seems to fail each time. I directly paste the command /aircon/get_control_with the appropriate Daikin pump adress info in internet explorer and it retreive valid informations for my pump.

any idea?

thanks a lot

Philos31
Posts: 48
Joined: Friday 15 August 2014 22:37
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Daikin integration

Post by Philos31 » Wednesday 01 April 2015 20:29

Send me your daikin.sh in a pm, just a copy paste, it should not do that. Very strange...
In the meantime, copy and paste the script from the wiki as described there (sudo nano ............/daikin.sh) delete the complete old script (ctrl x deletes a line per press I think)
then paste the script from the wiki and put your ip/ports and idx's in...
RasPi2/KaKu/MiLight/HomeEasy/Impuls/Byron/Daikin 3,5kw Ururu Sarara all working together with domoticz

eppie03
Posts: 4
Joined: Tuesday 14 April 2015 9:41
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Daikin integration

Post by eppie03 » Tuesday 14 April 2015 9:46

Hi,

How can I find the used IP address of the Daikin Wi-Fi controller?

Thanks,

Philos31
Posts: 48
Joined: Friday 15 August 2014 22:37
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Daikin integration

Post by Philos31 » Tuesday 14 April 2015 18:17

Look for the IP in your router , Normally you can find the ip adresses that are assigned to the mac adresses. The mac adress of your Daikin wifi is on the sticker on the side of the controller.
if you cant find it try the ip adresses in your DHCP range and try the following: http://192.168.x.y/aircon/get_control_info untill you get something back.

PS: Use the wiki and not the zip.
Let me know if it works, as pcc9 has problems with the script.
RasPi2/KaKu/MiLight/HomeEasy/Impuls/Byron/Daikin 3,5kw Ururu Sarara all working together with domoticz

User avatar
ThinkPad
Posts: 1754
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Daikin integration

Post by ThinkPad » Tuesday 14 April 2015 18:45

And if you found the IP, it is advisable to set up a 'Static DHCP lease' so the Daikin always gets the same IP-address, based on his MAC-address.
Most routers can do so.

Same idea as a static IP, but you don't have to change anything on the device itself.
ThinkTheme - theme for Domoticz
My (Dutch) blog: http://thinkpad.tweakblogs.net - My Domoticz scripts: Bitbucket
I'm not (very) active anymore on this forum as i don't use Domoticz anymore.

eppie03
Posts: 4
Joined: Tuesday 14 April 2015 9:41
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Daikin integration

Post by eppie03 » Thursday 16 April 2015 16:26

Okay, thanks guys.

With your help I got my Daikin unit running with Domoticz.

I hope their will be an script-update soon because the summer is coming and it would be very 'cool' to also control the daikin unit in cooling mode.

Philos31
Posts: 48
Joined: Friday 15 August 2014 22:37
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Daikin integration

Post by Philos31 » Thursday 30 April 2015 13:06

I am still waiting for the new heat/cool/off button to be implemented in Domotcz. If it will be summer and the button is still not there it must be done with a 2nd on off button.
I am not in favor of doing so, but I could implement it if it takes too long
RasPi2/KaKu/MiLight/HomeEasy/Impuls/Byron/Daikin 3,5kw Ururu Sarara all working together with domoticz

robhuls
Posts: 32
Joined: Monday 23 March 2015 20:20
Target OS: Raspberry Pi
Domoticz version: beta
Location: Zwolle
Contact:

Re: Daikin integration

Post by robhuls » Monday 04 May 2015 11:33

I just integrated my Daikin with my Domoticz server, thanks for figuring out how this can work! The 127.0.0.1 does not work here, so I replaced it with the fixed ip of my Domoticz server.

I replaced the shell script with some python code, so I don't have to install the dependencies, just python (do not forget to adept the lua scripts). I could compress this further to only 9 lines of code (2 imports, 4 params and 3 commands), but this is how it is now:

Code: Select all

import json
import urllib2

TempIdx = 62            # ID of the temperature sensor
OoIdx = 63              # ID of the on/off switch in Domoticz
DIP = '192.168.178.25'  # IP address of the Daikin
DomIP= '192.168.178.24' # IP address of Domoticz

# Retrieve the temperature that is set in Domoticz
data = urllib2.urlopen("http://{0}:8080/json.htm?type=devices&rid={1}".format(DomIP, TempIdx)).read()
data_struct = json.loads(data)  # Convert json string to python structure
DomSetPoint = data_struct['result'][0]['SetPoint']
# Retrieve the on/off state that is set in Domoticz
data = urllib2.urlopen("http://192.168.178.24:8080/json.htm?type=devices&rid={0}".format(OoIdx)).read()
data_struct = json.loads(data)  # Convert json string to python structure
DomOo = data_struct['result'][0]['Data']
DomPow = 0 if 'Off' in DomOo else 1
# Provide the setings to the Daikin
urllib2.urlopen("http://{0}/aircon/set_control_info?pow={1}&mode=4&stemp={2}&shum=0&f_rate=A&f_dir=0".format(DIP, DomPow, DomSetPoint))
print('Set Daikin to {0} and temperature {1}'.format(DomPow, DomSetPoint))

eppie03
Posts: 4
Joined: Tuesday 14 April 2015 9:41
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Daikin integration

Post by eppie03 » Saturday 23 May 2015 17:18

Hi philos31

Maybe it isn't such a bad idea to create a second on/off button.

When I put my daikin in cooling mode with my remote controller the domoticz software overrides its after one minute and puts the daikin in heating mode.

So in order to keep the daikin in cooling mode I have to remove your scripts from my pi/domoticz system.

I hope you find the time soon ; -)

Philos31
Posts: 48
Joined: Friday 15 August 2014 22:37
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Daikin integration

Post by Philos31 » Saturday 23 May 2015 23:11

eppie03 wrote:Hi philos31

Maybe it isn't such a bad idea to create a second on/off button.

When I put my daikin in cooling mode with my remote controller the domoticz software overrides its after one minute and puts the daikin in heating mode.

So in order to keep the daikin in cooling mode I have to remove your scripts from my pi/domoticz system.

I hope you find the time soon ; -)
Will try to look at the code this weekend, see if I can do something about it.
Bash is not a real language and I am not a real programmer :-) It's more of a demo script in the hope someone with programming skills will pick it up.
RasPi2/KaKu/MiLight/HomeEasy/Impuls/Byron/Daikin 3,5kw Ururu Sarara all working together with domoticz

Philos31
Posts: 48
Joined: Friday 15 August 2014 22:37
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Daikin integration

Post by Philos31 » Thursday 04 June 2015 22:10

Hello all, made a little change to the script so now you can use cooling too.
How it works: Just the same as the old script, but the script now checks: If room temp is lower then the programmed temperature then heat, if room temp is higher then programmed temperature then cool.

Works with the 2 buttons you allready have.

Code: Select all

#!/bin/bash
argument="$1"
#
# Domoticz control for Daikin airconditioner/Heatpump systems with 
# online wifi controller.
# For this script to work you need to have installed curl and jq
# Read the post or wiki for installation instructions
#
# This script comes with no warranty ...use at own risk 
# Copyright (C) 2015  Peter H. Roubos, you can use this script or parts of this scripts to
# your own liking, but please share your edits and or comments with the community.
# 
# This program is free software; you can redistribute it and/or modify 
# it under the terms of the GNU General Public License as published by 
# the Free Software Foundation; version 2 of the License. 
# 
# This program is distributed in the hope that it will be useful, 
# but WITHOUT ANY WARRANTY; without even the implied warranty of 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
# GNU General Public License for more details. 
# 
# I use it in Domoticz but should work on every linux system
# Version 1.0 03/27/2015
#
# Change variables to your liking here

# Settings:
# Daikin IP Adress
	DIP=192.168.x.x

# Domoticz port
	DomPort=8080

# On/Off button idx
	OoIdx=xxx

# Temp idx
	TempIdx=xxx

############################################################
# NO CHANGES AFTER THIS LINE ## NO CHANGES AFTER THIS LINE #
############################################################


control="/aircon/get_control_info"
sensors="/aircon/get_sensor_info"
DomOo=`curl -s "http://127.0.0.1:$DomPort/json.htm?type=devices&rid=$OoIdx" | jq '.result[0].Data'  | tr -d '"' `
DomTemp=`curl -s "http://127.0.0.1:$DomPort/json.htm?type=devices&rid=$TempIdx" | jq '.result[0].Data'  | tr -d '"' `
ControlInfoPath=http://$DIP$control
SensorsInfoPath=http://$DIP$sensors
ControlInfo=$(curl -s $ControlInfoPath)
SensorsInfo=$(curl -s $SensorsInfoPath)

# Get relevant control information from Daikin
ControlInfo=${ControlInfo//,/ [}
ControlInfo='['${ControlInfo//=/]=}
eval declare -A pump=($ControlInfo)

pow=( ${pump[pow]} )
mode=( ${pump[mode]} )
stemp=( ${pump[stemp]} )
shum=( ${pump[shum]} )
f_rate=( ${pump[f_rate]} )
f_dir=( ${pump[f_dir]} )



# Get Sensor information
SensorsInfo=${SensorsInfo//,/ [}
SensorsInfo='['${SensorsInfo//=/]=}
eval declare -A DaiSens=($SensorsInfo)

htemp=( ${DaiSens[htemp]} )
otemp=( ${DaiSens[otemp]} )
hhum=( ${DaiSens[hhum]} )

if [ $htemp < $stemp ]; then
Daimode=4
else
Daimode=3
            fi
if [ $pow = "1" ]; then
Daipow=On
else
Daipow=Off
            fi
			
if [ $DomOo = "On" ]; then
Dompow=1
else
Dompow=0
            fi

if [ $argument = "check" ]; then

	if [ $Dompow != $pow ]; then
		curl  "http://127.0.0.1:$DomPort/json.htm?type=command&param=switchlight&idx=$OoIdx&switchcmd=$Daipow"
		fi
	
	if [ $stemp != $DomTemp ]; then
		curl  "http://127.0.0.1:$DomPort/json.htm?type=command&param=udevice&idx=$TempIdx&nvalue=0&svalue=$stemp"
		fi
	
else
curl --data "pow=$Dompow&mode=$Daimode&stemp=$DomTemp&shum=0&f_rate=A&f_dir=0" http://$DIP/aircon/set_control_info
	fi
	
RasPi2/KaKu/MiLight/HomeEasy/Impuls/Byron/Daikin 3,5kw Ururu Sarara all working together with domoticz

User avatar
tcviper
Posts: 167
Joined: Monday 30 June 2014 13:34
Target OS: Raspberry Pi
Domoticz version:
Location: Netherlands
Contact:

Re: Daikin integration

Post by tcviper » Wednesday 08 July 2015 17:54

Would be awesome if this could be integrated into Domoticz by default :) (let's hope the devs see this :P)

I followed all your installation instructions but got this when manually running daikin.sh:

./daikin.sh
./daikin.sh: line 77: 21.0: No such file or directory
./daikin.sh: line 88: [: =: unary operator expected
./daikin.sh: line 94: [: =: unary operator expected

Any idea? :)

Philos31
Posts: 48
Joined: Friday 15 August 2014 22:37
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Daikin integration

Post by Philos31 » Wednesday 08 July 2015 20:24

Yep, you probably copy and pasted from windows into putty?
Download notepad++ paste the sripts into that and then ftp the scripts over to the pi.
That will work.

It's the same thing ppc9 had.
RasPi2/KaKu/MiLight/HomeEasy/Impuls/Byron/Daikin 3,5kw Ururu Sarara all working together with domoticz

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest