Page 2 of 3

Re: Domoticz - air conditioning control

Posted: Wednesday 20 January 2016 12:46
by pluggin
Toni wrote:Here's a teaser of what I have done with the air conditioning control so far. A bit clumsy, but this actually works now, together with a Lua event script which calculates the right IR command to be sent to the MySensors device. Now, if we just could combine those three dummy devices into one...
May be a stupid question... But how do you do the bottons on the inside the "device"?

Re: Domoticz - air conditioning control

Posted: Saturday 23 January 2016 12:43
by alfred_j_kwak

Re: Domoticz - air conditioning control

Posted: Saturday 23 January 2016 21:50
by Sateetje
Toni wrote:Now, if we just could combine those three dummy devices into one...
That would be a nice Domoticz feature! One of the reasons why I've started with home automation is to control my air conditioners.

Re: Domoticz - air conditioning control

Posted: Saturday 30 January 2016 14:44
by Toni
I have now tested the HeatpumpIR library also on Sensebender, so this makes it possible to build really small IR senders. Like placing the MySensors HeatpumpIR Controller inside the split-unit A/C indoor unit, next to its IR eye. Most IR eye's should have constant feed of +5V DC, so the Sensebender could be powered from that, through a 3.3V low-dropout regulator.

Now, if we would just have a UI like the one for the Panasonic TV: http://www.domoticz.com/wiki/Panasonic_TV

Re: Domoticz - air conditioning control

Posted: Thursday 11 February 2016 19:19
by Toni
As of the latest beta (V2.4547, published today), there's a new Lua table called 'otherdevices_idx'. This makes the background script way more beautiful, I don't need to hardcode device idx values any more. This is my current backend script to turn the dummy device widgets into a single command. Also both the MySensors Serial Gateway and Heatpump Controller can run on the Sensebender (+ nRF24).

Code: Select all

-- These are the configuration variables, set them according to your system
modelCmd = '0'        -- Panasonic CKP, see https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/examples/HeatpumpIRController/HeatpumpIRController.ino#L68
textDev = 'IR data'   -- Name of the 'IR data' MySensors device
irSendDev = 'IR send' -- Name of the 'IR send' MySensors device


commandArray = {}


for key, value in pairs(devicechanged) do
  if (key == 'Heatpump Mode' or key == 'Heatpump Fan Speed' or key == 'Heatpump Temperature') then

    mode = otherdevices['Heatpump Mode']
    fanSpeed = otherdevices['Heatpump Fan Speed']
    temperature = math.floor(otherdevices_svalues['Heatpump Temperature'])

    if     (mode == 'Off')   then powerModeCmd = '00'
    elseif (mode == 'Auto')  then powerModeCmd = '11'
    elseif (mode == 'Heat')  then powerModeCmd = '12'
    elseif (mode == 'Cool')  then powerModeCmd = '13'
    elseif (mode == 'Dry')   then powerModeCmd = '14'
    elseif (mode == 'Fan')   then powerModeCmd = '15'
    elseif (mode == 'Maint') then powerModeCmd = '16'
    end

    if     (fanSpeed == 'Auto')  then fanSpeedCmd = '0'
    elseif (fanSpeed == 'Fan 1') then fanSpeedCmd = '1'
    elseif (fanSpeed == 'Fan 2') then fanSpeedCmd = '2'
    elseif (fanSpeed == 'Fan 3') then fanSpeedCmd = '3'
    elseif (fanSpeed == 'Fan 4') then fanSpeedCmd = '4'
    elseif (fanSpeed == 'Fan 5') then fanSpeedCmd = '5'
    end

    temperatureCmd = string.format("%02x", temperature)

    modeCmd = '00' .. modelCmd .. powerModeCmd .. fanSpeedCmd .. temperatureCmd

    print(string.format('Mode: %s, fan: %s, temp: %s, modeCmd: %s', mode, fanSpeed, temperature, modeCmd))

    commandArray['UpdateDevice'] = otherdevices_idx[textDev] .. '|0|' .. modeCmd
    commandArray['IR send'] = 'On'

  end
end

return commandArray

Re: Domoticz - air conditioning control

Posted: Thursday 19 May 2016 13:38
by PettH
Hey. That's a good question. My contractor to install air conditioners http://myairmatics.com advised me to use a GSM SMS Controlled. This handy thing, I advise you to try. How to install it, I do not know. You can find it at my contractor. Good luck to you.

Re: Domoticz - air conditioning control

Posted: Sunday 26 June 2016 8:57
by keldy
Toni wrote:As of the latest beta (V2.4547, published today), there's a new Lua table called 'otherdevices_idx'. This makes the background script way more beautiful, I don't need to hardcode device idx values any more. This is my current backend script to turn the dummy device widgets into a single command. Also both the MySensors Serial Gateway and Heatpump Controller can run on the Sensebender (+ nRF24).
Hi Toni, great work. I am going to do the same setup for my heatpump. Do you mind to share the Arduino code for this? Thanks

Re: Domoticz - air conditioning control

Posted: Sunday 26 June 2016 11:02
by Toni
Just run the HeatpumpIR example sketch on your MySensors node: https://github.com/mysensors/Arduino/tr ... Controller

Re: Domoticz - air conditioning control

Posted: Sunday 10 July 2016 14:24
by ksga
Okay.. I'm probably a complete imbecile, but I can't get this AC control working...
I'm running Domoticz 3.4834, installed the MySensors beta library and HeatpumpIR library.

Changing Mysensor.H to Mysensors.H in the HeatpumpIRController.ino sketch, and editing IRSender.h, changing Protected to Public, I'm able to compile and upload to my Arduino + Nrf24l01+
Shortly after powering on, these lines show up under Devices:

Code: Select all

Idx   Hardware           ID            Unit     Name    Type    SubType    Data     [RF Signal Level]     [Battery Level]     Last Seen
[Turn Off] 	5	MySensorsGW	0000003	4	Light	Lighting 2	AC	On	-	-	[Add Light/Switch Device] [Rename Device]   [Log] 	2016-07-10 14:08:48
[Turn On] 	7	MySensorsGW	0000003	6	Light	Lighting 2	AC	Off	-	-	[Add Light/Switch Device] [Rename Device]   [Log] 	2016-07-10 14:08:47
[Turn On] 	6	MySensorsGW	0000003	5	Light	Lighting 2	AC	Off	-	-	[Add Light/Switch Device] [Rename Device]   [Log] 	2016-07-10 14:07:45
[Turn On] 	4	MySensorsGW	0000003	3	Light	Lighting 2	AC	Off	-	-	[Add Light/Switch Device] [Rename Device]   [Log] 	2016-07-10 14:06:01
[Turn On] 	3	MySensorsGW	0000003	2	Light	Lighting 2	AC	Off	-	-	[Add Light/Switch Device] [Rename Device]   [Log] 	2016-07-10 14:06:00
So to sum up, 5 light switches, unit numbers 2-6.

I have copy/pasted the Lua script via "Setup - More Options - Events" calling it Heatpump, and made it active.

The output from the log is:
2016-07-10 14:06:00.665 (MySensorsGW) Lighting 2 (Light)
2016-07-10 14:06:01.166 (MySensorsGW) Lighting 2 (Light)
2016-07-10 14:06:01.667 (MySensorsGW) Lighting 2 (Light)
2016-07-10 14:06:02.167 (MySensorsGW) Lighting 2 (Light)
2016-07-10 14:06:06.177 (MySensorsGW) Lighting 2 (Light)
2016-07-10 14:06:09.688 MySensors: Node: 3, Sketch Name: AC
2016-07-10 14:06:10.189 MySensors: Node: 3, Sketch Version: 1.0
2016-07-10 14:07:00.027 Error: EventSystem: in Heatpump: [string "modelCmd = '0'..."]:9: bad argument #1 to 'pairs' (table expected, got nil)
The error is repeated every minute...

Do I need to add some Dummy devices manually, or user variables? And if so - what are the needed parameters??

Hope somebody can give me some pointers...

Re: Domoticz - air conditioning control

Posted: Tuesday 12 July 2016 6:52
by ulf_slask
Hi i have a Remotec ZXT-120.

I can set the value:
textDevIdx = 243
modeCmd = '22'
commandArray['OpenURL'] = 'http://127.0.0.1:8080/json.htm?type=com ... evice&idx=' .. textDevIdx .. '&nvalue=0&svalue=' .. modeCmd


My problem is that i dont know how to get the actual set value from Remotec ZXT-120.
I can read the value on the screen but i cant get the value i LUA.
Screenshot from 2016-07-12.jpg
Screenshot from 2016-07-12.jpg (8.66 KiB) Viewed 8001 times
Can someone help me.

Thanks

Re: Domoticz - air conditioning control

Posted: Wednesday 28 September 2016 21:57
by madrian
Here is my solution, based on Toni's code.

Mine case is different, because I am using Esp Easy firmware on my Wemos D1 with Heatpump plugin + an Ir transmitter.
Screen-Shot-2016-09-28-21-52-28.jpg
Screen-Shot-2016-09-28-21-52-28.jpg (132.51 KiB) Viewed 7724 times

Code: Select all

-- These are the configuration variables, set them according to your system
modelCmd = 'fuego'

commandArray = {}

for key, value in pairs(devicechanged) do
  if (key == 'AC Mode' or key == 'AC Fan Speed' or key == 'AC Temperature' or key == 'Fan Mode') then

    mode = otherdevices['AC Mode']
    fanSpeed = otherdevices['AC Fan Speed']
    fanMode = otherdevices['Fan Mode']
    temperature = math.floor(otherdevices_svalues['AC Temperature'])

    if     (mode == 'Off')   then powerModeCmd = '0' heatModeCmd = '1'
    elseif (mode == 'Auto')  then powerModeCmd = '1' heatModeCmd = '1'
    elseif (mode == 'Heat')  then powerModeCmd = '1' heatModeCmd = '2'
    elseif (mode == 'Cool')  then powerModeCmd = '1' heatModeCmd = '3'
    elseif (mode == 'Dry')   then powerModeCmd = '1' heatModeCmd = '4'
    elseif (mode == 'Fan')   then powerModeCmd = '1' heatModeCmd = '5'
    end

    if     (fanSpeed == 'Auto')  then fanSpeedCmd = '0'
    elseif (fanSpeed == 'Fan 1') then fanSpeedCmd = '1'
    elseif (fanSpeed == 'Fan 2') then fanSpeedCmd = '2'
    elseif (fanSpeed == 'Fan 3') then fanSpeedCmd = '3'
    end

    if     (fanMode == 'Off')  then fanModeCmd = '1'
    elseif (fanMode == 'UP') then fanModeCmd = '2'
    elseif (fanMode == 'Middle UP') then fanModeCmd = '3'
    elseif (fanMode == 'Middle') then fanModeCmd = '4'
    elseif (fanMode == 'Middle Down') then fanModeCmd = '5'
    elseif (fanMode == 'Down') then fanModeCmd = '6'
    end

    temperatureCmd = temperature

    modeCmd = modelCmd .. ',' .. powerModeCmd .. ',' .. heatModeCmd .. ',' .. fanSpeedCmd .. ',' .. temperatureCmd .. ',' .. fanModeCmd

    print(string.format('Mode: %s, fan: %s, temp: %s, modeCmd: %s', mode, fanSpeed, temperature, modeCmd))

    commandArray['OpenURL'] = 'http://192.168.1.7/control?cmd=heatpumpir,' .. modeCmd

  end
end

return commandArray

Re: Domoticz - air conditioning control

Posted: Wednesday 12 October 2016 0:01
by connectix
I am trying to compile the examle sketch https://github.com/mysensors/MySensorsA ... roller.ino

and added the toshiba library from the ToniA example but i get an error when compiling the code. Can someone help me with this?

sketch_oct11a:83: error: within this context

IRSender irSender(3);

^

Re: Domoticz - air conditioning control

Posted: Wednesday 12 October 2016 17:53
by madrian
For me it is compiled fine, copy here the full error log.

Here you have a binary compiled by me.

Re: Domoticz - air conditioning control

Posted: Wednesday 12 October 2016 23:53
by connectix
@hpapagaj: Thanx. I got the mysensor node working and domoticz is showing the IR send and the IR data switches. Now I'm stuck with the lua script and creating the dummy switches. Can you give a step by step guide for creating all the heatpump combined switches in domoticz?

Re: Domoticz - air conditioning control

Posted: Monday 31 October 2016 13:59
by ksga
Okay, so I decided to give this another go - and got a bit further :)

The sensor node showed up with two devices:
#, Name, Type, SubType
1: IR send Lighting 2 AC
2: IR data General Text

I created a Dummy hardware device "Heatpump", and 3 virtual sensors on it:
#, Name, Type, Subtype
1: Heatpump Mode, Light/Switch, Selector Switch
2: Heatpump Fan Speed, Light/Switch, Selector Switch
3: Heatpump Temperature, Thermostat, SetPoint

For device 1 and 2 I added the needed "Selector levels" (matching them with the LUA script).

Lastly I created an "Events" called "heatpumpir" and copy/pasted the script

Code: Select all

-- These are the configuration variables, set them according to your system
modelCmd = '0'        -- Panasonic CKP, see https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/examples/HeatpumpIRController/HeatpumpIRController.ino#L68
textDev = 'IR data'   -- Name of the 'IR data' MySensors device
irSendDev = 'IR send' -- Name of the 'IR send' MySensors device


commandArray = {}


for key, value in pairs(devicechanged) do
  if (key == 'Heatpump Mode' or key == 'Heatpump Fan Speed' or key == 'Heatpump Temperature') then

    mode = otherdevices['Heatpump Mode']
    fanSpeed = otherdevices['Heatpump Fan Speed']
    temperature = math.floor(otherdevices_svalues['Heatpump Temperature'])

    if     (mode == 'Off')   then powerModeCmd = '00'
    elseif (mode == 'Auto')  then powerModeCmd = '11'
    elseif (mode == 'Heat')  then powerModeCmd = '12'
    elseif (mode == 'Cool')  then powerModeCmd = '13'
    elseif (mode == 'Dry')   then powerModeCmd = '14'
    elseif (mode == 'Fan')   then powerModeCmd = '15'
    elseif (mode == 'Maint') then powerModeCmd = '16'
    end

    if     (fanSpeed == 'Auto')  then fanSpeedCmd = '0'
    elseif (fanSpeed == 'Fan 1') then fanSpeedCmd = '1'
    elseif (fanSpeed == 'Fan 2') then fanSpeedCmd = '2'
    elseif (fanSpeed == 'Fan 3') then fanSpeedCmd = '3'
    elseif (fanSpeed == 'Fan 4') then fanSpeedCmd = '4'
    elseif (fanSpeed == 'Fan 5') then fanSpeedCmd = '5'
    end

    temperatureCmd = string.format("%02x", temperature)

    modeCmd = '00' .. modelCmd .. powerModeCmd .. fanSpeedCmd .. temperatureCmd

    print(string.format('Mode: %s, fan: %s, temp: %s, modeCmd: %s', mode, fanSpeed, temperature, modeCmd))

    commandArray['UpdateDevice'] = otherdevices_idx[textDev] .. '|0|' .. modeCmd
    commandArray['IR send'] = 'On'

  end
end

return commandArray
Now, when I change one of the selectors or the temperature setpoint the log shows:

Code: Select all

2016-10-31 12:56:44.055 LUA: Mode: Cool, fan: Fan 4, temp: 18, modeCmd: 00013412
2016-10-31 12:56:44.055 Error: EventSystem: in heatpumpir: [string "-- These are the configuration variables, set..."]:40: attempt to concatenate field '?' (a nil value)
2016-10-31 12:56:44.042 (Heatpump) Thermostat (Heatpump Temperature) 


and every minute I get this error:

Code: Select all

2016-10-31 12:57:00.114 Error: EventSystem: in heatpumpir: [string "-- These are the configuration variables, set..."]:10: bad argument #1 to 'pairs' (table expected, got nil)
So - my question is - what should I do to fix the "table expected, got nil" error?
And - will that also fix the "attempt to concatenate field '?' (a nil value)" error?

|| UPDATE || .. a reboot fixed the concatenate error...
new log looks like this (and the node receives and sends commands...)

Code: Select all

 2016-10-31 14:39:07.605 User: Admin initiated a switch command (5/Heatpump Mode/Set Level)
2016-10-31 14:39:07.633 LUA: Mode: Auto, fan: Fan 5, temp: 22, modeCmd: 00111516
2016-10-31 14:39:07.641 EventSystem: Script event triggered: heatpumpir
2016-10-31 14:39:07.607 (Heatpump) Light/Switch (Heatpump Mode)
2016-10-31 14:39:07.768 (MySensors) Lighting 2 (IR send)
2016-10-31 14:39:08.373 (MySensors) Lighting 2 (IR send)
2016-10-31 14:40:00.683 Error: EventSystem: in heatpumpir: [string "-- These are the configuration variables, set..."]:10: bad argument #1 to 'pairs' (table expected, got nil)

Re: Domoticz - air conditioning control

Posted: Saturday 12 November 2016 17:20
by logger02
Maybe you have found the solution, but could be useful for other user:

In the line: commandArray['UpdateDevice'] = otherdevices_idx[textDev] .. '|0|' .. modeCmd
change for: commandArray[otherdevices_idx[textDev]] = {['UpdateDevice'] = otherdevices_idx[textDev] .. '|0|' .. modeCmd }

Re: Domoticz - air conditioning control

Posted: Monday 14 November 2016 9:33
by ksga
logger02 wrote:Maybe you have found the solution, but could be useful for other user:

In the line: commandArray['UpdateDevice'] = otherdevices_idx[textDev] .. '|0|' .. modeCmd
change for: commandArray[otherdevices_idx[textDev]] = {['UpdateDevice'] = otherdevices_idx[textDev] .. '|0|' .. modeCmd }
Thank you for the the pointer... unfortunately it still produces the same error:

Code: Select all

 2016-11-14 09:28:58.853 User: Admin initiated a switch command (5/Heatpump Mode/Set Level)
2016-11-14 09:28:58.875 LUA: Mode: Cool, fan: Fan 3, temp: 18, modeCmd: 00013312
2016-11-14 09:28:58.882 EventSystem: Script event triggered: heatpumpir
2016-11-14 09:28:58.855 (Heatpump) Light/Switch (Heatpump Mode)
2016-11-14 09:29:00.484 Error: EventSystem: in heatpumpir: [string "-- These are the configuration variables, set..."]:10: bad argument #1 to 'pairs' (table expected, got nil) 
2016-11-14 09:30:00.018 Error: EventSystem: in heatpumpir: [string "-- These are the configuration variables, set..."]:10: bad argument #1 to 'pairs' (table expected, got nil)
The script seems to be doing what it should, but do I have to create a table manually somewhere to get rid of the error messages that appears every minute?

BTW, the script is copy/pasted from Toni's post: viewtopic.php?f=34&t=7179&p=104083#p74624 , now with the change proposed by logger02

Re: Domoticz - air conditioning control

Posted: Monday 14 November 2016 22:22
by logger02
Try my script. I use your script with a little modification:

Code: Select all

-- These are the configuration variables, set them according to your system
-- Mode command
modelCmd = '13' --fuego

-- Name of the devices from MySensor
textDev = 'acIRcmd'
irSendDev = 'acIRset'

-- Name of the dummy Devices
AC_Model = 'AC Model'
AC_Mode = 'AC Mode'
AC_Fan_Speed = 'AC Fan Speed'
AC_Temperature = 'AC Temperature'
AC_Fan_Mode = 'AC Fan Mode'

commandArray = {}

for key, value in pairs(devicechanged) do
  if (key == AC_Mode or key == AC_Fan_Speed or key == AC_Temperature or key == AC_Fan_Mode or key == AC_Model) then

    model = otherdevices[AC_Model]
    mode = otherdevices[AC_Mode]
    fanSpeed = otherdevices[AC_Fan_Speed]
    fanMode = otherdevices[AC_Fan_Mode]
    temperature = math.floor(otherdevices_svalues[AC_Temperature])
    
    if     (model == 'Panasonic CKP')       then modelCmd = '00'
	elseif (model == 'Panasonic DKE')       then modelCmd = '01'
    elseif (model == 'Panasonic JKE')       then modelCmd = '02'
	elseif (model == 'Panasonic NKE')       then modelCmd = '03'
	elseif (model == 'Carrier NQV')         then modelCmd = '04'
	elseif (model == 'Carrier MCA')         then modelCmd = '05'
	elseif (model == 'Midea')               then modelCmd = '06'
	elseif (model == 'Fujitsu')             then modelCmd = '07'
	elseif (model == 'Mitsubishi FD')       then modelCmd = '08'
	elseif (model == 'Mitsubishi FE')       then modelCmd = '09'
	elseif (model == 'Mitsubishi MSY')      then modelCmd = '0A'
	elseif (model == 'Samsung')             then modelCmd = '0B'
	elseif (model == 'Sharp')               then modelCmd = '0C'
	elseif (model == 'Daikin')              then modelCmd = '0D'
	elseif (model == 'Mitsubishi Heavy ZJ') then modelCmd = '0E'
	elseif (model == 'Mitsubishi Heavy ZM') then modelCmd = '0F'
	elseif (model == 'Hyundai')             then modelCmd = '10'
	elseif (model == 'Hisense')             then modelCmd = '11'
	elseif (model == 'Gree')                then modelCmd = '12'
	elseif (model == 'Fuego')               then modelCmd = '13'
	elseif (model == 'Toshiba')             then modelCmd = '14'
    end

    if     (mode == 'Off')   then powerModeCmd = '0' heatModeCmd = '1'
    elseif (mode == 'Auto')  then powerModeCmd = '1' heatModeCmd = '1'
    elseif (mode == 'Heat')  then powerModeCmd = '1' heatModeCmd = '2'
    elseif (mode == 'Cool')  then powerModeCmd = '1' heatModeCmd = '3'
    elseif (mode == 'Dry')   then powerModeCmd = '1' heatModeCmd = '4'
    elseif (mode == 'Fan')   then powerModeCmd = '1' heatModeCmd = '5'
    elseif (mode == 'Maint') then powerModeCmd = '1' heatModeCmd = '6'
    end

    if     (fanSpeed == 'Auto')  then fanSpeedCmd = '0'
    elseif (fanSpeed == 'Fan 1') then fanSpeedCmd = '1'
    elseif (fanSpeed == 'Fan 2') then fanSpeedCmd = '2'
    elseif (fanSpeed == 'Fan 3') then fanSpeedCmd = '3'
    elseif (fanSpeed == 'Fan 4') then fanSpeedCmd = '4'
    elseif (fanSpeed == 'Fan 5') then fanSpeedCmd = '5'
    end

    if     (fanMode == 'Auto')  then fanModeCmd = '0'
    elseif (fanMode == 'Manual')  then fanModeCmd = '0'
    elseif (fanMode == 'Swing')  then fanModeCmd = '1'
    elseif (fanMode == 'UP') then fanModeCmd = '2'
    elseif (fanMode == 'Middle UP') then fanModeCmd = '3'
    elseif (fanMode == 'Middle') then fanModeCmd = '4'
    elseif (fanMode == 'Middle Down') then fanModeCmd = '5'
    elseif (fanMode == 'Down') then fanModeCmd = '6'
    end

    temperatureCmd = temperature

    modeCmd = modelCmd .. powerModeCmd .. heatModeCmd .. fanSpeedCmd .. fanModeCmd .. temperatureCmd 

    print(string.format('Mode: %s, fan: %s, temp: %s, modeCmd: %s', mode, fanSpeed, temperature, modeCmd))
    
    commandArray[otherdevices_idx[textDev]] = {['UpdateDevice'] =  otherdevices_idx[textDev] .. '|0|'.. modeCmd}
    commandArray[irSendDev] = 'On'
 
--commandArray['OpenURL'] = 'http://127.0.0.2/control?cmd=heatpumpir,' .. modeCmd

  end
end

return commandArray
or maybe, send me your script

Re: Domoticz - air conditioning control

Posted: Tuesday 15 November 2016 9:02
by ksga
logger02 wrote:Try my script. I use your script with a little modification:

Code: Select all

-- These are the configuration variables, set them according to your system
-- Mode command
modelCmd = '13' --fuego

-- Name of the devices from MySensor
textDev = 'acIRcmd'
irSendDev = 'acIRset'

-- Name of the dummy Devices
AC_Model = 'AC Model'
AC_Mode = 'AC Mode'
AC_Fan_Speed = 'AC Fan Speed'
AC_Temperature = 'AC Temperature'
AC_Fan_Mode = 'AC Fan Mode'

commandArray = {}

for key, value in pairs(devicechanged) do
  if (key == AC_Mode or key == AC_Fan_Speed or key == AC_Temperature or key == AC_Fan_Mode or key == AC_Model) then

    model = otherdevices[AC_Model]
    mode = otherdevices[AC_Mode]
    fanSpeed = otherdevices[AC_Fan_Speed]
    fanMode = otherdevices[AC_Fan_Mode]
    temperature = math.floor(otherdevices_svalues[AC_Temperature])
    
    if     (model == 'Panasonic CKP')       then modelCmd = '00'
	elseif (model == 'Panasonic DKE')       then modelCmd = '01'
    elseif (model == 'Panasonic JKE')       then modelCmd = '02'
	elseif (model == 'Panasonic NKE')       then modelCmd = '03'
	elseif (model == 'Carrier NQV')         then modelCmd = '04'
	elseif (model == 'Carrier MCA')         then modelCmd = '05'
	elseif (model == 'Midea')               then modelCmd = '06'
	elseif (model == 'Fujitsu')             then modelCmd = '07'
	elseif (model == 'Mitsubishi FD')       then modelCmd = '08'
	elseif (model == 'Mitsubishi FE')       then modelCmd = '09'
	elseif (model == 'Mitsubishi MSY')      then modelCmd = '0A'
	elseif (model == 'Samsung')             then modelCmd = '0B'
	elseif (model == 'Sharp')               then modelCmd = '0C'
	elseif (model == 'Daikin')              then modelCmd = '0D'
	elseif (model == 'Mitsubishi Heavy ZJ') then modelCmd = '0E'
	elseif (model == 'Mitsubishi Heavy ZM') then modelCmd = '0F'
	elseif (model == 'Hyundai')             then modelCmd = '10'
	elseif (model == 'Hisense')             then modelCmd = '11'
	elseif (model == 'Gree')                then modelCmd = '12'
	elseif (model == 'Fuego')               then modelCmd = '13'
	elseif (model == 'Toshiba')             then modelCmd = '14'
    end

    if     (mode == 'Off')   then powerModeCmd = '0' heatModeCmd = '1'
    elseif (mode == 'Auto')  then powerModeCmd = '1' heatModeCmd = '1'
    elseif (mode == 'Heat')  then powerModeCmd = '1' heatModeCmd = '2'
    elseif (mode == 'Cool')  then powerModeCmd = '1' heatModeCmd = '3'
    elseif (mode == 'Dry')   then powerModeCmd = '1' heatModeCmd = '4'
    elseif (mode == 'Fan')   then powerModeCmd = '1' heatModeCmd = '5'
    elseif (mode == 'Maint') then powerModeCmd = '1' heatModeCmd = '6'
    end

    if     (fanSpeed == 'Auto')  then fanSpeedCmd = '0'
    elseif (fanSpeed == 'Fan 1') then fanSpeedCmd = '1'
    elseif (fanSpeed == 'Fan 2') then fanSpeedCmd = '2'
    elseif (fanSpeed == 'Fan 3') then fanSpeedCmd = '3'
    elseif (fanSpeed == 'Fan 4') then fanSpeedCmd = '4'
    elseif (fanSpeed == 'Fan 5') then fanSpeedCmd = '5'
    end

    if     (fanMode == 'Auto')  then fanModeCmd = '0'
    elseif (fanMode == 'Manual')  then fanModeCmd = '0'
    elseif (fanMode == 'Swing')  then fanModeCmd = '1'
    elseif (fanMode == 'UP') then fanModeCmd = '2'
    elseif (fanMode == 'Middle UP') then fanModeCmd = '3'
    elseif (fanMode == 'Middle') then fanModeCmd = '4'
    elseif (fanMode == 'Middle Down') then fanModeCmd = '5'
    elseif (fanMode == 'Down') then fanModeCmd = '6'
    end

    temperatureCmd = temperature

    modeCmd = modelCmd .. powerModeCmd .. heatModeCmd .. fanSpeedCmd .. fanModeCmd .. temperatureCmd 

    print(string.format('Mode: %s, fan: %s, temp: %s, modeCmd: %s', mode, fanSpeed, temperature, modeCmd))
    
    commandArray[otherdevices_idx[textDev]] = {['UpdateDevice'] =  otherdevices_idx[textDev] .. '|0|'.. modeCmd}
    commandArray[irSendDev] = 'On'
 
--commandArray['OpenURL'] = 'http://127.0.0.2/control?cmd=heatpumpir,' .. modeCmd

  end
end

return commandArray
or maybe, send me your script
Looks like I'm gonna have to create a couple more Dumme devs to use your script.
What's the purpose of "AC_Model"?

Anyway, my script looks like this:

Code: Select all

-- These are the configuration variables, set them according to your system
modelCmd = '0'        -- Panasonic CKP, see https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/examples/HeatpumpIRController/HeatpumpIRController.ino#L68
textDev = 'IR data'   -- Name of the 'IR data' MySensors device
irSendDev = 'IR send' -- Name of the 'IR send' MySensors device


commandArray = {}


for key, value in pairs(devicechanged) do
  if (key == 'Heatpump Mode' or key == 'Heatpump Fan Speed' or key == 'Heatpump Temperature') then

    mode = otherdevices['Heatpump Mode']
    fanSpeed = otherdevices['Heatpump Fan Speed']
    temperature = math.floor(otherdevices_svalues['Heatpump Temperature'])

    if     (mode == 'Off')   then powerModeCmd = '00'
    elseif (mode == 'Auto')  then powerModeCmd = '11'
    elseif (mode == 'Heat')  then powerModeCmd = '12'
    elseif (mode == 'Cool')  then powerModeCmd = '13'
    elseif (mode == 'Dry')   then powerModeCmd = '14'
    elseif (mode == 'Fan')   then powerModeCmd = '15'
    elseif (mode == 'Maint') then powerModeCmd = '16'
    end

    if     (fanSpeed == 'Auto')  then fanSpeedCmd = '0'
    elseif (fanSpeed == 'Fan 1') then fanSpeedCmd = '1'
    elseif (fanSpeed == 'Fan 2') then fanSpeedCmd = '2'
    elseif (fanSpeed == 'Fan 3') then fanSpeedCmd = '3'
    elseif (fanSpeed == 'Fan 4') then fanSpeedCmd = '4'
    elseif (fanSpeed == 'Fan 5') then fanSpeedCmd = '5'
    end

    temperatureCmd = string.format("%02x", temperature)

    modeCmd = '00' .. modelCmd .. powerModeCmd .. fanSpeedCmd .. temperatureCmd

    print(string.format('Mode: %s, fan: %s, temp: %s, modeCmd: %s', mode, fanSpeed, temperature, modeCmd))

    commandArray[otherdevices_idx[textDev]] = {['UpdateDevice'] = otherdevices_idx[textDev] .. '|0|' .. modeCmd }
    commandArray['IR send'] = 'On'

  end
end

return commandArray
--UPDATE--
Tried adding the fanmode dummy dev, and enabling your script - modding it to look for my devices.
Still get the error message though (new line line number, but same issue):

Code: Select all

2016-11-15 09:19:00.267 Error: EventSystem: in heatpumpalt: [string "-- These are the configuration variables, set..."]:18: bad argument #1 to 'pairs' (table expected, got nil)

Re: Domoticz - air conditioning control

Posted: Tuesday 15 November 2016 19:22
by logger02
"AC_model" is to select the model of the heatpump becuase in the arduino I can use all heatpump

What happen if you print "otherdevices_idx[textDev]"? it's null or it's the value of idx that you have in the devices window.

I have some problems because the text sensor wasn't connected to the gateway. Try to update the text sensor through JSON:
http://YOUR_IP:YOUR_PORT/json.htm?type=command&param=udevice&idx=IDX&nvalue=0&svalue=EXAMPLE_TEXT
you must to change YOUR_IP, YOUR_PORT, IDX and EXAMPLE_TEXT