Python plugin: Daikin BRP069A42 WiFi adapter

Python and python framework

Moderator: leecollings

leejoow
Posts: 11
Joined: Saturday 05 November 2016 17:30
Target OS: Linux
Domoticz version:
Contact:

Python plugin: Daikin BRP069A42 WiFi adapter

Post by leejoow »

Hi all,

I've created a plugin for the Daikin BRP069A42 WiFi adapter.
It can be found on GitHub: https://github.com/leejoow/domoticz_daikin_BRP069A42

Any comments, please let me know :)
videodrome
Posts: 64
Joined: Wednesday 11 May 2016 16:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Daikin BRP069A42 WiFi adapter

Post by videodrome »

With Python version '3.4.2' and script in scripts/python directory, i restarted domoticz but i can't see the plugin in the hardware page
leejoow
Posts: 11
Joined: Saturday 05 November 2016 17:30
Target OS: Linux
Domoticz version:
Contact:

Re: Python plugin: Daikin BRP069A42 WiFi adapter

Post by leejoow »

You have to place the script in the plugin directory as can be described in the wiki:

https://www.domoticz.com/wiki/Using_Pyt ... ns#Scripts
videodrome
Posts: 64
Joined: Wednesday 11 May 2016 16:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Daikin BRP069A42 WiFi adapter

Post by videodrome »

I'm trying the plugin on M series and it works fine (on/Off, F Rate, mode). The temperatures IN/OUT doesn't update when the unit is off (while they always update with the prevoius Daikin LAN interface).
It wouldn't be bad to have 2 switches for the fan direction and the advanced settings on M series like Powerfull, econo, flash streamer, but maybe I'm asking too much. :D
But most important, how can run the script every 60/120 seconds to avoid too many writings on the SD card (the script is running every 30 seconds)?
thanx
leejoow
Posts: 11
Joined: Saturday 05 November 2016 17:30
Target OS: Linux
Domoticz version:
Contact:

Re: Python plugin: Daikin BRP069A42 WiFi adapter

Post by leejoow »

The latest version contains an extra property which can be used to select the number of seconds which must be passed before polling the unit again. You have to restart Domoticz to make these settings visible and update the hardware settings.

The temperature should update even when the unit is off. Could you change the settings to debug mode and post the log? In the latest version I've added some extra connection handling, because in some cases the devices stopped updating. Maybe I've also solved your problem.

I would like to add the extra settings, however I don't have such a unit :) So if you could supply me with one, I would be very happy to implement ;) Another way to handle this would be you send me the requests which are done by the app when you are controlling it. If you could dump the HTTP traffic between your app and unit and send me it.
videodrome
Posts: 64
Joined: Wednesday 11 May 2016 16:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Daikin BRP069A42 WiFi adapter

Post by videodrome »

leejoow wrote: Tuesday 29 August 2017 8:34 The latest version contains an extra property which can be used to select the number of seconds which must be passed before polling the unit again. You have to restart Domoticz to make these settings visible and update the hardware settings.

The temperature should update even when the unit is off. Could you change the settings to debug mode and post the log? In the latest version I've added some extra connection handling, because in some cases the devices stopped updating. Maybe I've also solved your problem.

I would like to add the extra settings, however I don't have such a unit :) So if you could supply me with one, I would be very happy to implement ;) Another way to handle this would be you send me the requests which are done by the app when you are controlling it. If you could dump the HTTP traffic between your app and unit and send me it.
Yes, with the new version of plugin is possible to set x seconds of updates and it works fine, and the temp out works now too. :D
Some minor bug, when the unit is set up in comfort (by the remote - you can't see in domoticz - the fan rate is in Auto by default) It seems that in domoticz you can't change the fan rate, but it's normal because you can't change the fan if you don't disable the comfort mode first by the remote.
Which app for dump the http traffic from daikin control online?
leejoow
Posts: 11
Joined: Saturday 05 November 2016 17:30
Target OS: Linux
Domoticz version:
Contact:

Re: Python plugin: Daikin BRP069A42 WiFi adapter

Post by leejoow »

I'm using tcpdump on my access point to dump all HTTP traffic to the unit. What the plugin does, is emulating the mobile app (not the website).
User avatar
remb0
Posts: 499
Joined: Thursday 11 July 2013 22:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Python plugin: Daikin BRP069A42 WiFi adapter

Post by remb0 »

I have tested this plugin with an: BRP069A41
but I got:
17-09-23 13:23:35.512 (Daikin_airo) Calling message handler 'onHeartbeat'.
2017-09-23 13:23:35.512 (Daikin_airo) Poll unit
2017-09-23 13:23:35.512 (Daikin_airo) Transport set to: 'TCP/IP', 192.168.0.19:80.
2017-09-23 13:23:35.513 PluginSystem: Starting I/O service thread.
2017-09-23 13:23:35.513 (Daikin_airo) Connect directive received, action initiated successfully.
2017-09-23 13:23:35.513 (Daikin_airo) Transport set to: 'TCP/IP', 192.168.0.19:80.
2017-09-23 13:23:35.513 (Daikin_airo) Connect directive received, action initiated successfully.
2017-09-23 13:23:35.563 (Daikin_airo) Calling message handler 'onConnect'.
2017-09-23 13:23:35.563 (Daikin_airo) Connection successful
2017-09-23 13:23:35.563 (Daikin_airo) Sensor connection created
2017-09-23 13:23:35.564 Error: (Daikin_airo) failed to parse parameters, Message or Message, Delay expected.
2017-09-23 13:23:35.564 Error: (Daikin_airo) 'CConnection_send' failed 'TypeError':'function takes at most 2 arguments (4 given)'.
2017-09-23 13:23:36.566 (Daikin_airo) Calling message handler 'onConnect'.
2017-09-23 13:23:36.566 (Daikin_airo) Connection successful
2017-09-23 13:23:36.566 (Daikin_airo) Control connection created
2017-09-23 13:23:36.566 Error: (Daikin_airo) failed to parse parameters, Message or Message, Delay expected.
2017-09-23 13:23:36.566 Error: (Daikin_airo) 'CConnection_send' failed 'TypeError':'function takes at most 2 arguments (4 given)'.

is this because 41 is really differtent then the 42 ? or a change to the python connection method?
continent
Posts: 12
Joined: Monday 17 August 2015 22:15
Target OS: Linux
Domoticz version: 4.11605
Location: The Netherlands
Contact:

Re: Python plugin: Daikin BRP069A42 WiFi adapter

Post by continent »

It is working perfect on my Raspberry. Tnx for the tip!!
Gigabyte with Debian, 4 Shelly's 2.5 (rollerblinds), 3 Shelly's dimmers, 3 Shelly plugs,
8 x DB1820, ESPeasy with 8 relay's, RFXcom, Enocean USB300, 2 x Enocean STM 330.
continent
Posts: 12
Joined: Monday 17 August 2015 22:15
Target OS: Linux
Domoticz version: 4.11605
Location: The Netherlands
Contact:

Re: Python plugin: Daikin BRP069A42 WiFi adapter

Post by continent »

I was to fast, I have the same errors as Remb0.
And the in and out temperatures are zero.

And also I have the 42.
Gigabyte with Debian, 4 Shelly's 2.5 (rollerblinds), 3 Shelly's dimmers, 3 Shelly plugs,
8 x DB1820, ESPeasy with 8 relay's, RFXcom, Enocean USB300, 2 x Enocean STM 330.
User avatar
remb0
Posts: 499
Joined: Thursday 11 July 2013 22:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Python plugin: Daikin BRP069A42 WiFi adapter

Post by remb0 »

Code: Select all

2017-10-08 09:06:08.458 Error: (Daikin_airo) failed to parse parameters, Message or Message, Delay expected.
2017-10-08 09:06:08.458 Error: (Daikin_airo) 'CConnection_send' failed 'TypeError':'function takes at most 2 arguments (4 given)'.
2017-10-08 09:06:09.461 Error: (Daikin_airo) failed to parse parameters, Message or Message, Delay expected.
2017-10-08 09:06:09.461 Error: (Daikin_airo) 'CConnection_send' failed 'TypeError':'function takes at most 2 arguments (4 given)'.
2017-10-08 09:08:07.398 Error: (Daikin_airo) failed to parse parameters, Message or Message, Delay expected.
2017-10-08 09:08:07.398 Error: (Daikin_airo) 'CConnection_send' failed 'TypeError':'function takes at most 2 arguments (4 given)'.
2017-10-08 09:08:08.451 Error: (Daikin_airo) failed to parse parameters, Message or Message, Delay expected.
2017-10-08 09:08:08.451 Error: (Daikin_airo) 'CConnection_send' failed 'TypeError':'function takes at most 2 arguments (4 given)'.
2017-10-08 09:10:07.441 Error: (Daikin_airo) failed to parse parameters, Message or Message, Delay expected.
2017-10-08 09:10:07.441 Error: (Daikin_airo) 'CConnection_send' failed 'TypeError':'function takes at most 2 arguments (4 given)'.
2017-10-08 09:10:08.443 Error: (Daikin_airo) failed to parse parameters, Message or Message, Delay expected.
2017-10-08 09:10:08.443 Error: (Daikin_airo) 'CConnection_send' failed 'TypeError':'function takes at most 2 arguments (4 given)'.
2017-10-08 09:12:07.464 Error: (Daikin_airo) failed to parse parameters, Message or Message, Delay expected.
2017-10-08 09:12:07.464 Error: (Daikin_airo) 'CConnection_send' failed 'TypeError':'function takes at most 2 arguments (4 given)'.
2017-10-08 09:12:08.516 Error: (Daikin_airo) failed to parse parameters, Message or Message, Delay expected.
2017-10-08 09:12:08.516 Error: (Daikin_airo) 'CConnection_send' failed 'TypeError':'function takes at most 2 arguments (4 given)'.
maybe we can check if we could use the code and make it work for us?
User avatar
Dnpwwo
Posts: 819
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python plugin: Daikin BRP069A42 WiFi adapter

Post by Dnpwwo »

The Connection Send function was changed a while ago to make it more extensible but this plugin is using the old interface.

The old parameters need to move to a single parameter that is a dictionary:

Code: Select all

Connection.Send(data, 'GET', requestUrl, headers)
needs to be:

Code: Select all

Connection.Send({"Verb":"GET", "URL":requestUrl, "Headers": headers})
given that data is empty. If data needs to be passed it would be:

Code: Select all

Connection.Send({"Verb":"GET", "URL":requestUrl, "Headers": headers, "Data":data})
this documented here:http://www.domoticz.com/wiki/Developing ... onnections there is an example here https://github.com/domoticz/domoticz/bl ... es/HTTP.py
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
mattia81
Posts: 8
Joined: Friday 01 September 2017 11:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Daikin BRP069A42 WiFi adapter

Post by mattia81 »

I own BRP069A41 too...what's the best way to integrate Daikin and domoticz?
User avatar
remb0
Posts: 499
Joined: Thursday 11 July 2013 22:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Python plugin: Daikin BRP069A42 WiFi adapter

Post by remb0 »

I have tried to change the connection like Dnpwwo told.
that first error is gone but a new one is showing :P and I can't find why..

Code: Select all

2017-10-18 20:22:01.732 (Zwave_Battery) Calling message handler 'onHeartbeat'.
2017-10-18 20:22:01.736 (Daikin_airo) Debug log level set to: 'true'.
2017-10-18 20:22:01.736 (Daikin_airo) 'Name':'Daikin_airo'
2017-10-18 20:22:01.736 (Daikin_airo) 'HomeFolder':'/home/pi/domoticz/plugins/domoticz_daikin_BRP069A42/'
2017-10-18 20:22:01.736 (Daikin_airo) 'Mode1':'12'
2017-10-18 20:22:01.736 (Daikin_airo) 'Mode2':'Debug'
2017-10-18 20:22:01.736 (Daikin_airo) 'Key':'BRP069A42'
2017-10-18 20:22:01.736 (Daikin_airo) 'Port':'80'
2017-10-18 20:22:01.736 (Daikin_airo) 'Author':'leejoow'
2017-10-18 20:22:01.736 (Daikin_airo) 'Address':'192.168.0.19'
2017-10-18 20:22:01.736 (Daikin_airo) 'HardwareID':'44'
2017-10-18 20:22:01.736 (Daikin_airo) 'Version':'1.0.0'
2017-10-18 20:22:01.736 (Daikin_airo) Device count: 6
2017-10-18 20:22:01.736 (Daikin_airo) Device: 1 - ID: 1977, Name: 'Daikin_airo - Power', nValue: 0, sValue: ''
2017-10-18 20:22:01.736 (Daikin_airo) Device ID: '1977'
2017-10-18 20:22:01.736 (Daikin_airo) Device Name: 'Daikin_airo - Power'
2017-10-18 20:22:01.736 (Daikin_airo) Device nValue: 0
2017-10-18 20:22:01.736 (Daikin_airo) Device sValue: ''
2017-10-18 20:22:01.736 (Daikin_airo) Device LastLevel: 0
2017-10-18 20:22:01.736 (Daikin_airo) Device: 2 - ID: 1978, Name: 'Daikin_airo - Temp IN', nValue: 0, sValue: ''
2017-10-18 20:22:01.736 (Daikin_airo) Device ID: '1978'
2017-10-18 20:22:01.736 (Daikin_airo) Device Name: 'Daikin_airo - Temp IN'
2017-10-18 20:22:01.736 (Daikin_airo) Device nValue: 0
2017-10-18 20:22:01.737 (Daikin_airo) Device sValue: ''
2017-10-18 20:22:01.737 (Daikin_airo) Device LastLevel: 0
2017-10-18 20:22:01.737 (Daikin_airo) Device: 3 - ID: 1979, Name: 'Daikin_airo - Temp OUT', nValue: 0, sValue: ''
2017-10-18 20:22:01.737 (Daikin_airo) Device ID: '1979'
2017-10-18 20:22:01.737 (Daikin_airo) Device Name: 'Daikin_airo - Temp OUT'
2017-10-18 20:22:01.737 (Daikin_airo) Device nValue: 0
2017-10-18 20:22:01.737 (Daikin_airo) Device sValue: ''
2017-10-18 20:22:01.737 (Daikin_airo) Device LastLevel: 0
2017-10-18 20:22:01.737 (Daikin_airo) Device: 4 - ID: 1980, Name: 'Daikin_airo - Mode', nValue: 0, sValue: ''
2017-10-18 20:22:01.737 (Daikin_airo) Device ID: '1980'
2017-10-18 20:22:01.737 (Daikin_airo) Device Name: 'Daikin_airo - Mode'
2017-10-18 20:22:01.737 (Daikin_airo) Device nValue: 0
2017-10-18 20:22:01.737 (Daikin_airo) Device sValue: ''
2017-10-18 20:22:01.737 (Daikin_airo) Device LastLevel: 0
2017-10-18 20:22:01.737 (Daikin_airo) Device: 5 - ID: 1981, Name: 'Daikin_airo - Fan Rate', nValue: 0, sValue: ''
2017-10-18 20:22:01.737 (Daikin_airo) Device ID: '1981'
2017-10-18 20:22:01.737 (Daikin_airo) Device Name: 'Daikin_airo - Fan Rate'
2017-10-18 20:22:01.737 (Daikin_airo) Device nValue: 0
2017-10-18 20:22:01.737 (Daikin_airo) Device sValue: ''
2017-10-18 20:22:01.737 (Daikin_airo) Device LastLevel: 0
2017-10-18 20:22:01.737 (Daikin_airo) Device: 6 - ID: 1982, Name: 'Daikin_airo - Temp TARGET', nValue: 0, sValue: ''
2017-10-18 20:22:01.737 (Daikin_airo) Device ID: '1982'
2017-10-18 20:22:01.737 (Daikin_airo) Device Name: 'Daikin_airo - Temp TARGET'
2017-10-18 20:22:01.737 (Daikin_airo) Device nValue: 0
2017-10-18 20:22:01.737 (Daikin_airo) Device sValue: ''
2017-10-18 20:22:01.737 (Daikin_airo) Device LastLevel: 0
2017-10-18 20:22:01.737 (Daikin_airo) Heartbeat interval set to: 10.
2017-10-18 20:22:01.737 (Daikin_airo) Protocol set to: 'HTTP'.
2017-10-18 20:22:01.737 (Daikin_airo) Transport set to: 'TCP/IP', 192.168.0.19:80.
2017-10-18 20:22:01.738 PluginSystem: Starting I/O service thread.
2017-10-18 20:22:01.738 (Daikin_airo) Connect directive received, action initiated successfully.
2017-10-18 20:22:01.738 (Daikin_airo) Protocol set to: 'HTTP'.
2017-10-18 20:22:01.738 (Daikin_airo) Transport set to: 'TCP/IP', 192.168.0.19:80.
2017-10-18 20:22:01.738 (Daikin_airo) Connect directive received, action initiated successfully.
2017-10-18 20:22:01.738 (Daikin_airo) Protocol set to: 'HTTP'.
2017-10-18 20:22:01.788 (Daikin_airo) Calling message handler 'onConnect'.
2017-10-18 20:22:01.788 (Daikin_airo) Connection successful
2017-10-18 20:22:01.788 (Daikin_airo) Sensor connection created
2017-10-18 20:22:01.788 (Daikin_airo) Sending 219 bytes of data:
2017-10-18 20:22:01.788 (Daikin_airo) 47 45 54 20 2f 61 69 72 63 6f 6e 2f 67 65 74 5f 73 65 6e 73 GET./aircon/get_sens
2017-10-18 20:22:01.788 (Daikin_airo) 6f 72 5f 69 6e 66 6f 20 48 54 54 50 2f 31 2e 31 0d 0a 41 63 or_info.HTTP/1.1..Ac
2017-10-18 20:22:01.788 (Daikin_airo) 63 65 70 74 3a 20 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20 cept:.Content-Type:.
2017-10-18 20:22:01.788 (Daikin_airo) 74 65 78 74 2f 68 74 6d 6c 3b 20 63 68 61 72 73 65 74 3d 55 text/html;.charset=U
2017-10-18 20:22:01.789 (Daikin_airo) 54 46 2d 38 0d 0a 48 6f 73 74 3a 20 31 39 32 2e 31 36 38 2e TF-8..Host:.192.168.
2017-10-18 20:22:01.789 (Daikin_airo) 30 2e 31 39 3a 38 30 0d 0a 43 6f 6e 74 65 6e 74 2d 4c 65 6e 0.19:80..Content-Len
2017-10-18 20:22:01.789 (Daikin_airo) 67 74 68 3a 20 30 0d 0a 43 6f 6e 74 65 6e 74 2d 54 79 70 65 gth:.0..Content-Type
2017-10-18 20:22:01.789 (Daikin_airo) 3a 20 74 65 78 74 2f 78 6d 6c 3b 20 63 68 61 72 73 65 74 3d :.text/xml;.charset=
2017-10-18 20:22:01.789 (Daikin_airo) 75 74 66 2d 38 0d 0a 43 6f 6e 6e 65 63 74 69 6f 6e 3a 20 6b utf-8..Connection:.k
2017-10-18 20:22:01.789 (Daikin_airo) 65 65 70 2d 61 6c 69 76 65 0d 0a 55 73 65 72 2d 41 67 65 6e eep-alive..User-Agen
2017-10-18 20:22:01.789 (Daikin_airo) 74 3a 20 44 6f 6d 6f 74 69 63 7a 2f 31 2e 30 0d 0a 0d 0a .. t:.Domoticz/1.0....
2017-10-18 20:22:01.839 (Daikin_airo) Received 116 bytes of data:
2017-10-18 20:22:01.839 (Daikin_airo) 48 54 54 50 2f 31 2e 30 20 32 30 30 20 4f 4b 0d 0a 43 6f 6e HTTP/1.0.200.OK..Con
2017-10-18 20:22:01.839 (Daikin_airo) 74 65 6e 74 2d 4c 65 6e 67 74 68 3a 20 35 31 0d 0a 43 6f 6e tent-Length:.51..Con
2017-10-18 20:22:01.839 (Daikin_airo) 74 65 6e 74 2d 54 79 70 65 3a 20 74 65 78 74 2f 70 6c 61 69 tent-Type:.text/plai
2017-10-18 20:22:01.839 (Daikin_airo) 6e 0d 0a 0d 0a 72 65 74 3d 4f 4b 2c 68 74 65 6d 70 3d 32 32 n....ret=OK,htemp=22
2017-10-18 20:22:01.839 (Daikin_airo) 2e 30 2c 68 68 75 6d 3d 2d 2c 6f 74 65 6d 70 3d 31 34 2e 30 .0,hhum=-,otemp=14.0
2017-10-18 20:22:01.839 (Daikin_airo) 2c 65 72 72 3d 30 2c 63 6d 70 66 72 65 71 3d 30 .. .. .. .. ,err=0,cmpfreq=0
2017-10-18 20:22:01.839 (Daikin_airo) Calling message handler 'onMessage'.
2017-10-18 20:22:01.839 Error: (Daikin_airo) 'onMessage' failed 'TypeError':'onMessage() missing 2 required positional arguments: 'Status' and 'Extra''.
2017-10-18 20:22:01.839 (Daikin_airo) Calling message handler 'onDisconnect'.
2017-10-18 20:22:01.839 (Daikin_airo) Connection Sensor Info closed.
2017-10-18 20:22:02.841 (Daikin_airo) Calling message handler 'onConnect'.
2017-10-18 20:22:02.842 (Daikin_airo) Connection successful
2017-10-18 20:22:02.842 (Daikin_airo) Control connection created
2017-10-18 20:22:02.842 (Daikin_airo) Sending 220 bytes of data:
2017-10-18 20:22:02.842 (Daikin_airo) 47 45 54 20 2f 61 69 72 63 6f 6e 2f 67 65 74 5f 63 6f 6e 74 GET./aircon/get_cont
2017-10-18 20:22:02.842 (Daikin_airo) 72 6f 6c 5f 69 6e 66 6f 20 48 54 54 50 2f 31 2e 31 0d 0a 41 rol_info.HTTP/1.1..A
2017-10-18 20:22:02.842 (Daikin_airo) 63 63 65 70 74 3a 20 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a ccept:.Content-Type:
2017-10-18 20:22:02.842 (Daikin_airo) 20 74 65 78 74 2f 68 74 6d 6c 3b 20 63 68 61 72 73 65 74 3d .text/html;.charset=
2017-10-18 20:22:02.842 (Daikin_airo) 55 54 46 2d 38 0d 0a 48 6f 73 74 3a 20 31 39 32 2e 31 36 38 UTF-8..Host:.192.168
2017-10-18 20:22:02.842 (Daikin_airo) 2e 30 2e 31 39 3a 38 30 0d 0a 43 6f 6e 74 65 6e 74 2d 4c 65 .0.19:80..Content-Le
2017-10-18 20:22:02.843 (Daikin_airo) 6e 67 74 68 3a 20 30 0d 0a 43 6f 6e 74 65 6e 74 2d 54 79 70 ngth:.0..Content-Typ
2017-10-18 20:22:02.843 (Daikin_airo) 65 3a 20 74 65 78 74 2f 78 6d 6c 3b 20 63 68 61 72 73 65 74 e:.text/xml;.charset
2017-10-18 20:22:02.843 (Daikin_airo) 3d 75 74 66 2d 38 0d 0a 43 6f 6e 6e 65 63 74 69 6f 6e 3a 20 =utf-8..Connection:.
2017-10-18 20:22:02.843 (Daikin_airo) 6b 65 65 70 2d 61 6c 69 76 65 0d 0a 55 73 65 72 2d 41 67 65 keep-alive..User-Age
2017-10-18 20:22:02.843 (Daikin_airo) 6e 74 3a 20 44 6f 6d 6f 74 69 63 7a 2f 31 2e 30 0d 0a 0d 0a nt:.Domoticz/1.0....
2017-10-18 20:22:02.893 PluginSystem: Restarting I/O service thread.
2017-10-18 20:22:02.893 (Daikin_airo) Received 400 bytes of data:
2017-10-18 20:22:02.894 (Daikin_airo) 48 54 54 50 2f 31 2e 30 20 32 30 30 20 4f 4b 0d 0a 43 6f 6e HTTP/1.0.200.OK..Con
2017-10-18 20:22:02.894 (Daikin_airo) 74 65 6e 74 2d 4c 65 6e 67 74 68 3a 20 33 33 34 0d 0a 43 6f tent-Length:.334..Co
2017-10-18 20:22:02.894 (Daikin_airo) 6e 74 65 6e 74 2d 54 79 70 65 3a 20 74 65 78 74 2f 70 6c 61 ntent-Type:.text/pla
2017-10-18 20:22:02.894 (Daikin_airo) 69 6e 0d 0a 0d 0a 72 65 74 3d 4f 4b 2c 70 6f 77 3d 30 2c 6d in....ret=OK,pow=0,m
2017-10-18 20:22:02.894 (Daikin_airo) 6f 64 65 3d 33 2c 61 64 76 3d 2c 73 74 65 6d 70 3d 31 38 2e ode=3,adv=,stemp=18.
2017-10-18 20:22:02.894 (Daikin_airo) 30 2c 73 68 75 6d 3d 30 2c 64 74 31 3d 32 35 2e 30 2c 64 74 0,shum=0,dt1=25.0,dt
2017-10-18 20:22:02.894 (Daikin_airo) 32 3d 4d 2c 64 74 33 3d 31 38 2e 30 2c 64 74 34 3d 32 35 2e 2=M,dt3=18.0,dt4=25.
2017-10-18 20:22:02.894 (Daikin_airo) 30 2c 64 74 35 3d 32 35 2e 30 2c 64 74 37 3d 32 35 2e 30 2c 0,dt5=25.0,dt7=25.0,
2017-10-18 20:22:02.894 (Daikin_airo) 64 68 31 3d 41 55 54 4f 2c 64 68 32 3d 35 30 2c 64 68 33 3d dh1=AUTO,dh2=50,dh3=
2017-10-18 20:22:02.894 (Daikin_airo) 30 2c 64 68 34 3d 30 2c 64 68 35 3d 30 2c 64 68 37 3d 41 55 0,dh4=0,dh5=0,dh7=AU
2017-10-18 20:22:02.894 (Daikin_airo) 54 4f 2c 64 68 68 3d 35 30 2c 62 5f 6d 6f 64 65 3d 33 2c 62 TO,dhh=50,b_mode=3,b
2017-10-18 20:22:02.894 (Daikin_airo) 5f 73 74 65 6d 70 3d 31 38 2e 30 2c 62 5f 73 68 75 6d 3d 30 _stemp=18.0,b_shum=0
2017-10-18 20:22:02.894 (Daikin_airo) 2c 61 6c 65 72 74 3d 32 35 35 2c 66 5f 72 61 74 65 3d 42 2c ,alert=255,f_rate=B,
2017-10-18 20:22:02.895 (Daikin_airo) 66 5f 64 69 72 3d 30 2c 62 5f 66 5f 72 61 74 65 3d 42 2c 62 f_dir=0,b_f_rate=B,b
2017-10-18 20:22:02.895 (Daikin_airo) 5f 66 5f 64 69 72 3d 30 2c 64 66 72 31 3d 35 2c 64 66 72 32 _f_dir=0,dfr1=5,dfr2
2017-10-18 20:22:02.895 (Daikin_airo) 3d 35 2c 64 66 72 33 3d 42 2c 64 66 72 34 3d 35 2c 64 66 72 =5,dfr3=B,dfr4=5,dfr
2017-10-18 20:22:02.895 (Daikin_airo) 35 3d 35 2c 64 66 72 36 3d 35 2c 64 66 72 37 3d 35 2c 64 66 5=5,dfr6=5,dfr7=5,df
2017-10-18 20:22:02.895 (Daikin_airo) 72 68 3d 35 2c 64 66 64 31 3d 30 2c 64 66 64 32 3d 30 2c 64 rh=5,dfd1=0,dfd2=0,d
2017-10-18 20:22:02.895 (Daikin_airo) 66 64 33 3d 30 2c 64 66 64 34 3d 30 2c 64 66 64 35 3d 30 2c fd3=0,dfd4=0,dfd5=0,
2017-10-18 20:22:02.895 (Daikin_airo) 64 66 64 36 3d 30 2c 64 66 64 37 3d 30 2c 64 66 64 68 3d 30 dfd6=0,dfd7=0,dfdh=0
2017-10-18 20:22:02.895 (Daikin_airo) Calling message handler 'onMessage'.
2017-10-18 20:22:02.895 Error: (Daikin_airo) 'onMessage' failed 'TypeError':'onMessage() missing 2 required positional arguments: 'Status' and 'Extra''.
2017-10-18 20:22:02.895 (Daikin_airo) Calling message handler 'onDisconnect'.
2017-10-18 20:22:02.895 (Daikin_airo) Connection Control Info closed.
would be nice to get it work because the alternative sh/lua scripts are too complicated and unstable and the official hardware isn't complete (set temperature wont work)
User avatar
Dnpwwo
Posts: 819
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python plugin: Daikin BRP069A42 WiFi adapter

Post by Dnpwwo »

@remb0,

There are a couple of other things.

You need to remove ", Status, Extra" from all references to onMessage (there are 3). So, for example,:

Code: Select all

def onMessage(self, Connection, Data, Status, Extra):
should be

Code: Select all

def onMessage(self, Connection, Data):
also, inside onMessage you will need to change:

Code: Select all

dataDecoded = Data.decode("utf-8")
to be

Code: Select all

dataDecoded = Data["Data"].decode("utf-8", "ignore")
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
continent
Posts: 12
Joined: Monday 17 August 2015 22:15
Target OS: Linux
Domoticz version: 4.11605
Location: The Netherlands
Contact:

Re: Python plugin: Daikin BRP069A42 WiFi adapter

Post by continent »

remb0 wrote: Wednesday 18 October 2017 20:27

...2017-10-18 20:22:01.732 (Zwave_Battery) Calling message handler 'onHeartbeat'.
2017-10-18 20:22:01.736 (Daikin_airo) Debug log level set to: 'true'.
2017-10-18 20:22:01.736 (Daikin_airo) 'Name':'Daikin_airo'
2017-10-18 20:22:01.736 (Daikin_airo) 'HomeFolder':'/home/pi/domoticz/plugins/domoticz_daikin_BRP069A42/'
2017-10-18 20:22:01.736 (Daikin_airo) 'Mode1':'12'
2017-10-18 20:22:01
2017-10-18 20:22:01.736 (Daikin_airo) 'Name':'Daikin_airo'...

"airo" is it not airco?
Gigabyte with Debian, 4 Shelly's 2.5 (rollerblinds), 3 Shelly's dimmers, 3 Shelly plugs,
8 x DB1820, ESPeasy with 8 relay's, RFXcom, Enocean USB300, 2 x Enocean STM 330.
User avatar
remb0
Posts: 499
Joined: Thursday 11 July 2013 22:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Python plugin: Daikin BRP069A42 WiFi adapter

Post by remb0 »

thanks for your help Dnpwwo.
but when I change what you said My domoticz crash. no log and I can't restart unless I move the plugin outside of the directory and restart.

this is how the plugin look right now, can you tell me what's wrong?

Code: Select all

"""
<plugin key="BRP069A42" name="Daikin Airconditioning (BRP069A42)" author="leejoow" version="1.0.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
import hmac
import hashlib
import time
import re
import base64
import http.client
from datetime import datetime 

class BasePlugin:
    powerOn = 0
    runCounter = 0
    httpConnSensorInfo = None
    httpConnControlInfo = None    
    httpConnSetControl = None  
    
    def __init__(self):
        return

    def onStart(self):
        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("Plugin is stopping.")

    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, "Data":data})
        else:
            Domoticz.Debug("Connection failed")
     
    def onMessage(self, Connection, Data):
        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
         
            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
            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 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=0&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 == "50"):
            requestUrl = requestUrl + "2"
                
        requestUrl = requestUrl + "&f_rate="
        
        if (Devices[5].sValue == "10"):
            requestUrl = requestUrl + "A"
        elif (Devices[5].sValue == "20"):
            requestUrl = requestUrl + "B"
        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 stringToBase64(s):
    global _plugin
    _plugin.stringToBase64(s)

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

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

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

User avatar
Dnpwwo
Posts: 819
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python plugin: Daikin BRP069A42 WiFi adapter

Post by Dnpwwo »

@remb0,

I will have a look but would it be possible to run it from the command line to capture a log and post it?

You will get some output from Domoticz.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
User avatar
Dnpwwo
Posts: 819
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python plugin: Daikin BRP069A42 WiFi adapter

Post by Dnpwwo »

@remb0,

It runs for me on Windows (although doesn't connect obviously because I don't have one of these) which is a shame.

One observation is that there seem to be a number of imports which are not used. Can you try removing:

Code: Select all

import hmac
import hashlib
import time
import re
import base64
import http.client
to simplify things a little. Those will be loaded during the plugin startup by Python and could cause an issue.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
videodrome
Posts: 64
Joined: Wednesday 11 May 2016 16:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Daikin BRP069A42 WiFi adapter

Post by videodrome »

This plugin give me the following error:

Code: Select all

017-12-06 22:50:17.317 Error: (Daikin Papà) 'onMessage' failed 'TypeError':'attribute of type 'NoneType' is not callable'. 
2017-12-06 22:50:17.317 Error: (Daikin Papà) ----> Line 295 in /home/pi/domoticz/plugins/Daikin/plugin.py, function onMessage 
2017-12-06 22:50:17.317 Error: (Daikin Papà) ----> Line 170 in /home/pi/domoticz/plugins/Daikin/plugin.py, function onMessage  

Code: Select all

2017-12-06 19:39:27.171 (Daikin Fabio) Plugin is stopping. 
2017-12-06 19:39:27.304 (Daikin Fabio) Exiting work loop... 
2017-12-06 19:39:27.339 (Daikin Fabio) Stopped. 
The lines (170/295) in the scripts are:

Code: Select all

      lastUpdate = datetime.strptime(Devices[6].LastUpdate, "%Y-%m-%d %H:%M:%S")
     _plugin.onMessage(Connection, Data, Status, Extra)
In debug mode

Code: Select all

017-12-06 23:28:04.484 (Daikin Papà) Calling message handler 'onMessage'. 
2017-12-06 23:28:04.484 (Daikin Papà) Received data from connection Control Info: ret=OK,pow=0,mode=4,adv=,stemp=21.5,shum=0,dt1=25.0,dt2=M,dt3=25.0,dt4=21.5,dt5=21.5,dt7=25.0,dh1=AUTO,dh2=50,dh3=0,dh4=0,dh5=0,dh7=AUTO,dhh=50,b_mode=4,b_stemp=21.5,b_shum=0,alert=255,f_rate=4,f_dir=0,b_f_rate=4,b_f_dir=0,dfr1=5,dfr2=5,dfr3=5,dfr4=4,dfr5=4,dfr6=5,dfr7=5,dfrh=5,dfd1=0,dfd2=0,dfd3=0,dfd4=0,dfd5=0,dfd6=0,dfd7=0,dfdh=0,dmnd_run=0,en_demand=1 
2017-12-06 23:28:04.484 (Daikin Papà) Power: 0; Mode: 4; FanRate: 4; Target temperature: 21 
2017-12-06 23:28:04.485 Error: (Daikin Papà) 'onMessage' failed 'TypeError':'attribute of type 'NoneType' is not callable'. 
2017-12-06 23:28:04.485 Error: (Daikin Papà) ----> Line 295 in /home/pi/domoticz/plugins/Daikin/plugin.py, function onMessage 
2017-12-06 23:28:04.485 Error: (Daikin Papà) ----> Line 170 in /home/pi/domoticz/plugins/Daikin/plugin.py, function onMessage 
2017-12-06 23:28:04.485 (Daikin Papà) Calling message handler 'onDisconnect'. 
the plugin makes unstable domoticz that often crashes
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest