Setup Daikin Airoconditioning

For heating/cooling related questions in Domoticz

Moderator: leecollings

Post Reply
CronoS
Posts: 135
Joined: Wednesday 15 July 2015 23:40
Target OS: -
Domoticz version:
Contact:

Setup Daikin Airoconditioning

Post by CronoS »

Hi,

I just recently bought an Daikin Airconditioning with Wifi module. Ofcourse the most importing thing to do is to add it to Domoticz :) Now I see the option to add the Daikin Hardware to domoticz, but I don't get it basically. I see succesfully the temperature nodes and they work, but I also get dummy switches that are created automatically . If I follow the Daikin Wifi wiki (and the link in the Wiki), It should have created selector switches I think, but I get normal On/Off switches by default. If I add the Lua script, I can create Heat/Cooling/Fan etc option and it work.. But, I don't know why the buttons are predefined, if there is nothing behind it basically. I also get a button "Wind".. When I look at the example pictures, this should also be a selection box with Stopped/Vert/Horz and Both, but I don't know the commands to use it basically? Also I don't know yet what Led indicator should do :)

Can anyone help? Awesome!

Thanks!
Last edited by CronoS on Friday 29 March 2019 9:36, edited 1 time in total.
Prutsium
Posts: 92
Joined: Monday 18 June 2018 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany / Netherlands
Contact:

Re: Setup Daikin Airoconditioning

Post by Prutsium »

Are you using the original Daikin plugin or this one: https://www.domoticz.com/forum/viewtopi ... 65&t=19120

I use the last and does all although the script had some errors and i made some modifications tho that script to get all working as supposed.

This is my modified version (all fan levels working and the Fan direction default active)

Code: Select all

# Basic Python Plugin Example
#
# Author: GizMoCuz
#
"""
<plugin key="BRP069A42" name="Daikin Airconditioning (BRP069A42)" author="leejoow" version="1.1.0" externallink="https://www.daikin.nl/nl_nl/products/BRP069A42.html">
    <params>
        <param field="Address" label="IP Address" width="200px" required="true" default=""/>
        <param field="Port" label="Port" width="30px" required="true" default="80"/>
        <param field="Mode1" label="Update every x seconds" width="75px">
            <options>
                <option label="30" value="3" />
                <option label="60" value="6" default="true" />
                <option label="90" value="9" />
                <option label="120" value="12" />
                <option label="150" value="15" />
                <option label="180" value="18" />
                <option label="210" value="21" />
                <option label="240" value="24" />
            </options>
        </param>
        <param field="Mode2" label="Debug" width="75px">
            <options>
                <option label="True" value="Debug"/>
                <option label="False" value="Normal"  default="true" />
            </options>
        </param>
        
    </params>
</plugin>
"""
import Domoticz
from datetime import datetime 

class BasePlugin:
    enabled = True
    powerOn = 0
    runCounter = 0
    httpConnSensorInfo = None
    httpConnControlInfo = None
    httpConnSetControl = None

    def __init__(self):
        #self.var = 123
        return

    def onStart(self):
        Domoticz.Log("onStart called")

        if Parameters["Mode2"] == "Debug":
            Domoticz.Debugging(1)
            
        if (len(Devices) == 0):
            Domoticz.Device(Name="Power", Unit=1, Image=16, TypeName="Switch", Used=1).Create()
            Domoticz.Device(Name="Temp IN", Unit=2, TypeName="Temperature", Used=1).Create()
            Domoticz.Device(Name="Temp OUT", Unit=3, TypeName="Temperature",Used=1).Create()

            Options = {"LevelActions" : "|||||",
                       "LevelNames" : "|Auto|Cool|Heat|Fan|Dry",
                       "LevelOffHidden" : "true",
                       "SelectorStyle" : "1"}
            
            Domoticz.Device(Name="Mode", Unit=4, TypeName="Selector Switch", Image=16, Options=Options, Used=1).Create()
            
            Options = {"LevelActions" : "|||||||",
                       "LevelNames" : "|Auto|Silent|L1|L2|L3|L4|L5",
                       "LevelOffHidden" : "true",
                       "SelectorStyle" : "1"}
            
            Domoticz.Device(Name="Fan Rate", Unit=5, TypeName="Selector Switch", Image=7, Options=Options, Used=1).Create()
            Domoticz.Device(Name="Temp TARGET", Unit=6, Type=242, Subtype=1, Image=16, Used=1).Create()
            
            Domoticz.Log("Device created.")
        
        DumpConfigToLog()
        
        Domoticz.Heartbeat(10)
        
        self.httpConnSensorInfo = Domoticz.Connection(Name="Sensor Info", Transport="TCP/IP", Protocol="HTTP", Address=Parameters["Address"], Port=Parameters["Port"])
        self.httpConnSensorInfo.Connect()    

        self.httpConnControlInfo = Domoticz.Connection(Name="Control Info", Transport="TCP/IP", Protocol="HTTP", Address=Parameters["Address"], Port=Parameters["Port"])
        self.httpConnControlInfo.Connect() 
        
        self.httpConnSetControl = Domoticz.Connection(Name="Set Control", Transport="TCP/IP", Protocol="HTTP", Address=Parameters["Address"], Port=Parameters["Port"])

        self.runCounter = int(Parameters["Mode1"])
    def onStop(self):
        Domoticz.Log("onStop called")

    def onConnect(self, Connection, Status, Description):
        if (Status == 0):
            Domoticz.Debug("Connection successful")
            
            data = ''
            headers = { 'Content-Type': 'text/xml; charset=utf-8', \
                        'Connection': 'keep-alive', \
                        'Accept': 'Content-Type: text/html; charset=UTF-8', \
                        'Host': Parameters["Address"]+":"+Parameters["Port"], \
                        'User-Agent':'Domoticz/1.0', \
                        'Content-Length' : "%d"%(len(data)) }

            if (Connection == self.httpConnSensorInfo):
                Domoticz.Debug("Sensor connection created")
                requestUrl = "/aircon/get_sensor_info"
            elif (Connection == self.httpConnControlInfo):
                Domoticz.Debug("Control connection created")
                requestUrl = "/aircon/get_control_info"
            elif (Connection == self.httpConnSetControl):
                Domoticz.Debug("Set connection created")
                requestUrl = self.buildCommandString()
                
            Connection.Send({"Verb":"GET", "URL":requestUrl, "Headers": headers})
        else:
            Domoticz.Debug("Connection failed")

    def onMessage(self, Connection, Data):
        Domoticz.Log("onMessage called")
        
        dataDecoded = Data["Data"].decode("utf-8", "ignore")
            
        Domoticz.Debug("Received data from connection " + Connection.Name + ": " + dataDecoded)
        
        if (Connection == self.httpConnControlInfo):       
            position = dataDecoded.find("pow=")
            power = dataDecoded[position + 4 : position + 5]
            
            position = dataDecoded.find("mode=")
            mode = dataDecoded[position + 5 : position + 6]
            
            position = dataDecoded.find("f_rate=")
            f_rate = dataDecoded[position + 7 : position + 8]
            
            position = dataDecoded.find("stemp=")
            stemp = dataDecoded[position + 6 : position + 8]
            
            Domoticz.Debug("Power: " + power + "; Mode: " + mode + "; FanRate: " + f_rate + "; Target temperature: " + stemp)
            
            self.powerOn = int(power)     
            
            # Power
            if (power == "0"):
                if (Devices[1].nValue != 0):
                    Devices[1].Update(nValue = 0, sValue ="0") 
            else: 
                if (Devices[1].nValue != 1):
                    Devices[1].Update(nValue = 1, sValue ="100") 
             
            # Mode
            if (mode == "0"):
                sValueNew = "10" #Auto
            elif (mode == "2"):
                sValueNew = "50" #Dry
            elif (mode == "3"):
                sValueNew = "20" #Cool
            elif (mode == "4"):
                sValueNew = "30" #Warm
            elif (mode == "6"):
                sValueNew = "40" #Fan
         
            if (Devices[4].nValue != self.powerOn or Devices[4].sValue != sValueNew):
                Devices[4].Update(nValue = self.powerOn, sValue = sValueNew)
         
            # Fan rate
            if (f_rate == "A"):
                sValueNew = "10" # Auto
            elif (f_rate == "B"):
                sValueNew = "20" # Silent
#Manual f_rate
            elif (f_rate == "3"):
                sValueNew = "30" # L1
            elif (f_rate == "4"):
                sValueNew = "40" # L2
            elif (f_rate == "5"):
                sValueNew = "50" # L3
            elif (f_rate == "6"):
                sValueNew = "60" # L4
            elif (f_rate == "7"):
                sValueNew = "70" # L4

#            else:
#                sValueNew = str(int(f_rate) * 10)
                           
            if (Devices[5].nValue != self.powerOn or Devices[5].sValue != sValueNew):
                Devices[5].Update(nValue = self.powerOn, sValue = sValueNew)

            #lastUpdate = datetime.strptime(Devices[6].LastUpdate, "%Y-%m-%d %H:%M:%S")
            #delta = datetime.now() - lastUpdate
                
            # Setpoint temperature, update once per 30 minutes if no changes
            #if (Devices[6].nValue != self.powerOn or Devices[6].sValue != stemp or delta.total_seconds() > 1800):
            #    Devices[6].Update(nValue = self.powerOn, sValue = stemp)
        
        elif (Connection == self.httpConnSensorInfo):        
            position = dataDecoded.find("htemp=")
            htemp = dataDecoded[position + 6 : position + 10]
                        
            position = dataDecoded.find("otemp=")
            otemp = dataDecoded[position + 6 : position + 10]
            
            Domoticz.Debug("Internal temperature: " + htemp + "; Outside temperature: " + otemp)
            
            Devices[2].Update(nValue = 0, sValue = htemp)
            Devices[3].Update(nValue = 0, sValue = otemp)
        
        #Force disconnect, in case the Daikin unit doesn't disconnect
        if (Connection.Connected()):
            Domoticz.Debug("Close connection")
            Connection.Disconnect()

    def onCommand(self, Unit, Command, Level, Hue):
        Domoticz.Debug("Command received U="+str(Unit)+" C="+str(Command)+" L= "+str(Level)+" H= "+str(Hue))
        
        if (Unit == 1):
            if(Command == "On"):
                self.powerOn = 1
                Devices[1].Update(nValue = 1, sValue ="100") 
            else:
                self.powerOn = 0
                Devices[1].Update(nValue = 0, sValue ="0") 
            
            #Update state of all other devices
            Devices[4].Update(nValue = self.powerOn, sValue = Devices[4].sValue)
            Devices[5].Update(nValue = self.powerOn, sValue = Devices[5].sValue)
            Devices[6].Update(nValue = self.powerOn, sValue = Devices[6].sValue)
        
        if (Unit == 4):
            Devices[4].Update(nValue = self.powerOn, sValue = str(Level))
            
        if (Unit == 5):
            Devices[5].Update(nValue = self.powerOn, sValue = str(Level))
        
        if (Unit == 6):
            Devices[6].Update(nValue = self.powerOn, sValue = str(Level))
            
        self.httpConnSetControl.Connect()
        
    def onNotification(self, Name, Subject, Text, Status, Priority, Sound, ImageFile):
        Domoticz.Log("Notification: " + Name + "," + Subject + "," + Text + "," + Status + "," + str(Priority) + "," + Sound + "," + ImageFile)

    def onDisconnect(self, Connection):
        Domoticz.Debug("Connection " + Connection.Name + " closed.")

    def onHeartbeat(self):
        self.runCounter = self.runCounter - 1
        if self.runCounter <= 0:
            Domoticz.Debug("Poll unit")
            self.runCounter = int(Parameters["Mode1"])
            
            if (self.httpConnSensorInfo.Connected() == False):
                self.httpConnSensorInfo.Connect()
            
            if (self.httpConnControlInfo.Connected() == False):
                self.httpConnControlInfo.Connect()
            
        else:
            Domoticz.Debug("Polling unit in " + str(self.runCounter) + " heartbeats.")

    def buildCommandString(self):
        #Minimal string: pow=1&mode=1&stemp=26&shum=0&f_rate=B&f_dir=3
        
        requestUrl = "/aircon/set_control_info?shum=0&f_dir=3&pow="
    
        if (self.powerOn):
            requestUrl = requestUrl + "1"
        else:
            requestUrl = requestUrl + "0"
        
        requestUrl = requestUrl + "&mode="
        
        if (Devices[4].sValue == "10"):
            requestUrl = requestUrl + "0"
        elif (Devices[4].sValue == "20"):
            requestUrl = requestUrl + "3"
        elif (Devices[4].sValue == "30"):
            requestUrl = requestUrl + "4"
        elif (Devices[4].sValue == "40"):
            requestUrl = requestUrl + "6"
        elif (Devices[4].sValue == "50"):
            requestUrl = requestUrl + "2"
                
        requestUrl = requestUrl + "&f_rate="
        
        if (Devices[5].sValue == "10"):
            requestUrl = requestUrl + "A"
        elif (Devices[5].sValue == "20"):
            requestUrl = requestUrl + "B"
        elif (Devices[5].sValue == "30"):
            requestUrl = requestUrl + "3"
        elif (Devices[5].sValue == "40"):
            requestUrl = requestUrl + "4"
        elif (Devices[5].sValue == "50"):
            requestUrl = requestUrl + "5"
        elif (Devices[5].sValue == "60"):
            requestUrl = requestUrl + "6"
        elif (Devices[5].sValue == "70"):
            requestUrl = requestUrl + "7"
		
			#        else:
#            requestUrl = requestUrl + str(int(int(Devices[5].sValue) / 10))
    
        requestUrl = requestUrl + "&stemp=" + Devices[6].sValue
    
        return requestUrl
            
global _plugin
_plugin = BasePlugin()

def onStart():
    global _plugin
    _plugin.onStart()

def onStop():
    global _plugin
    _plugin.onStop()

def onConnect(Connection, Status, Description):
    global _plugin
    _plugin.onConnect(Connection, Status, Description)

def onMessage(Connection, Data):
    global _plugin
    _plugin.onMessage(Connection, Data)

def onCommand(Unit, Command, Level, Hue):
    global _plugin
    _plugin.onCommand(Unit, Command, Level, Hue)

def onNotification(Name, Subject, Text, Status, Priority, Sound, ImageFile):
    global _plugin
    _plugin.onNotification(Name, Subject, Text, Status, Priority, Sound, ImageFile)

def onDisconnect(Connection):
    global _plugin
    _plugin.onDisconnect(Connection)

def onHeartbeat():
    global _plugin
    _plugin.onHeartbeat()

    # Generic helper functions
def DumpConfigToLog():
    for x in Parameters:
        if Parameters[x] != "":
            Domoticz.Debug( "'" + x + "':'" + str(Parameters[x]) + "'")
    Domoticz.Debug("Device count: " + str(len(Devices)))
    for x in Devices:
        Domoticz.Debug("Device:           " + str(x) + " - " + str(Devices[x]))
        Domoticz.Debug("Device ID:       '" + str(Devices[x].ID) + "'")
        Domoticz.Debug("Device Name:     '" + Devices[x].Name + "'")
        Domoticz.Debug("Device nValue:    " + str(Devices[x].nValue))
        Domoticz.Debug("Device sValue:   '" + Devices[x].sValue + "'")
        Domoticz.Debug("Device LastLevel: " + str(Devices[x].LastLevel))
    return
In regards of the LED this was to turn the LED off from the Wifi adapter but seems not to be implemented.
CronoS
Posts: 135
Joined: Wednesday 15 July 2015 23:40
Target OS: -
Domoticz version:
Contact:

Re: Setup Daikin Airoconditioning

Post by CronoS »

Thanks for you're reply. But still don't get it? Do I need the python script? The wiki says that the python script is legacy? I use Domoticz 4.9700 and I can default add the Daikin hardware to Domoticz?

I would expect natively to see natively the buttons as described in the picture in this threat. This with all the right commands when you press a button: https://www.domoticz.com/forum/viewtopi ... 61c84a2908

If this is not the case when I setup the hardware, but then the wiki does not describe how to setup the buttons or ofcourse I am doing it wrong :)

Also another question; when I change something in the Daikin App or on the Airco itself; will this setting also be reflected back in Domoticz? For example I change the temperature on the Airco itself or turn it off using the remote? I don't see anything changing then in Domoticz then?
Prutsium
Posts: 92
Joined: Monday 18 June 2018 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany / Netherlands
Contact:

Re: Setup Daikin Airoconditioning

Post by Prutsium »

The script i posted here is especially for the Wifi Adapter versions of Daikin and i had better results with it then the original Domoticz script / plugin.

When i change something on the app (what i actually dont use) it takes some time to reflect in Domoticz but yes it will follow. The same counts for when controlled by IR this will reflect also in Domoticz.
CronoS
Posts: 135
Joined: Wednesday 15 July 2015 23:40
Target OS: -
Domoticz version:
Contact:

Re: Setup Daikin Airoconditioning

Post by CronoS »

Awesome .. Thanks for you're reply. I am running Domoticz on Synology; so hopefully I can add this python script with no problems, haven't tried it before :) Just to be sure how it works; when I add this script; I get a new hardware option in Domoticz then, is that correct? Where new devices will be created afterwards? Or must I use it differently? First time I use Python scripts :)
Prutsium
Posts: 92
Joined: Monday 18 June 2018 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany / Netherlands
Contact:

Re: Setup Daikin Airoconditioning

Post by Prutsium »

Correct add script to plugin directory and will appear after restart domoticz.
Then setup and all additional hardware will be created.

I have 3 airco / heating units running and till now plugin worked flawless (after the modifications i made to the original)
CronoS
Posts: 135
Joined: Wednesday 15 July 2015 23:40
Target OS: -
Domoticz version:
Contact:

Re: Setup Daikin Airoconditioning

Post by CronoS »

Thanks.. I was able to start the Python module on the Synology for Domoticz, in the logging I see this: "EventSystem: Queue thread started..." I see some other items in the log where the plugin module is started. But then it stops; I expect some sort of new hardware device (I still have the old one listed), but nothing different on this part Is there a way to see the plugin is loaded? Or to troubleshoot it?
Alain
Posts: 164
Joined: Sunday 26 April 2020 5:27
Target OS: Linux
Domoticz version: 2022.1
Location: Netherlands
Contact:

Re: Setup Daikin Airoconditioning

Post by Alain »

Does this only work with the add-on controllers? The newer versions with built-in wifi controllers using the Daikin Residential App don't seem to work. When I enter the commands such as "IP-address/get_sensor_info", I get a "Page not found" error.
Hue | Zigbee2Mqtt | MQTT | P1 | Xiaomi | RFXCom | Modbus | Qlima | Solaredge
TP-Link | Plugwise | Thermosmart | Node-Red | Grafana | Master and 5 remote servers
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests