Heatpump controller
-
I have my heatpump mysensor working, and hooked up to Openhab.
Arduino code here:
#include <MySensor.h> #include <SPI.h> #include <Arduino.h> #include <PanasonicCKPHeatpumpIR.h> #include <PanasonicHeatpumpIR.h> #define POWER_ID 0 #define MODE_ID 1 #define FAN_ID 2 #define TEMP_ID 3 #define VDIR_ID 4 #define HDIR_ID 5 MySensor gw; MyMessage powerMsg(POWER_ID, V_STATUS); MyMessage modeMsg(MODE_ID, V_HVAC_FLOW_STATE); MyMessage fanMsg(FAN_ID, V_PERCENTAGE); MyMessage tempMsg(TEMP_ID, V_TEMP); MyMessage vdirMsg(VDIR_ID, V_VAR1); MyMessage hdirMsg(HDIR_ID, V_VAR2); IRSenderPWM irSender(3); // IR led on Arduino digital pin 3, using Arduino PWM HeatpumpIR *heatpumpIR = new PanasonicNKEHeatpumpIR(); //Some global variables to hold the states int POWER_STATE; int TEMP_STATE; int FAN_STATE; int MODE_STATE; void setup() { gw.begin(incomingMessage, AUTO, false); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Heatpump", "1.0"); // Register all sensors to gw (they will be created as child devices) gw.present(POWER_ID, S_BINARY); gw.present(MODE_ID, S_HVAC); gw.present(FAN_ID, S_HVAC); gw.present(TEMP_ID, S_HVAC); gw.present(VDIR_ID, S_CUSTOM); gw.present(HDIR_ID, S_CUSTOM); // Load our values on start POWER_STATE = gw.loadState(POWER_ID); TEMP_STATE = gw.loadState(TEMP_ID); FAN_STATE = gw.loadState(FAN_ID); MODE_STATE = gw.loadState(MODE_ID); sendHeatpumpCommand(); } void loop() { gw.process(); } void handlePowerMessage(bool newState) { if (newState) { POWER_STATE = POWER_ON; } else { POWER_STATE = POWER_OFF; } gw.saveState(POWER_ID, newState); } void handleModeMessge(int newMode) { switch(newMode) { case 0: MODE_STATE = MODE_HEAT; break; case 1: MODE_STATE = MODE_COOL; break; case 2: MODE_STATE = MODE_AUTO; break; case 3: MODE_STATE = MODE_FAN; break; case 4: MODE_STATE = MODE_DRY; break; } MODE_STATE = newMode; gw.saveState(MODE_ID, newMode); } void handleFanMessage(int newFan) { if (newFan > 5) newFan=5; switch(newFan) { case 0: FAN_STATE = FAN_AUTO; break; case 1: FAN_STATE = FAN_1; break; case 2: FAN_STATE = FAN_2; break; case 3: FAN_STATE = FAN_3; break; case 4: FAN_STATE = FAN_4; break; case 5: FAN_STATE = FAN_5; break; default: FAN_STATE = FAN_AUTO; break; } FAN_STATE = newFan; gw.saveState(FAN_ID, newFan); } void handleTempMessage(int newTemp) { TEMP_STATE = newTemp; gw.saveState(TEMP_ID, newTemp); } void sendHeatpumpCommand() { Serial.println("Power = " + (String)POWER_STATE); Serial.println("Mode = " + (String)MODE_STATE); Serial.println("Fan = " + (String)FAN_STATE); Serial.println("Temp = " + (String)TEMP_STATE); heatpumpIR->send(irSender, POWER_STATE, MODE_STATE, FAN_STATE, TEMP_STATE, VDIR_AUTO, HDIR_AUTO); } void incomingMessage(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.isAck()) { Serial.println("This is an ack from gateway"); } Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); switch(message.sensor) { case POWER_ID: { bool newState = message.getBool(); handlePowerMessage(newState); break; } case MODE_ID: { int newMode = message.getInt(); handleModeMessge(newMode); break; } case FAN_ID: { int newFan = message.getInt(); handleFanMessage(newFan); break; } case TEMP_ID: { int newTemp = message.getInt(); handleTempMessage(newTemp); break; } } sendHeatpumpCommand(); }Openhab items
Switch Power_HeatPump "Heatpump on/off" <aircon> Number Mode_HeatPump "Heatpump mode" Number Fan_HeatPump "Heatpump fan" <airing> Number Temp_HeatPump "Heatpump temperature [%d C]" <temperature> String VDir_HeatPump "vertical" String HDir_HeatPump "horizontal"Openhab sitemap
sitemap heatpump label="Heatpump" { Frame { Switch item=Power_HeatPump Selection item=Mode_HeatPump mappings=[0="heat", 1="cool", 2="auto", 3="fan", 4="dry"] Selection item=Fan_HeatPump mappings=[0="auto", 1="Level 1", 2="Level 2", 3="Level 3", 4="Level 4", 5="Level 5"] Setpoint item=Temp_HeatPump minValue=10 maxValue=30 step=1 Text item=VDir_HeatPump Text item=HDir_HeatPump } }Openhab rules
val org.eclipse.xtext.xbase.lib.Functions$Function4 numberOperation = [ org.openhab.core.library.items.NumberItem numberItem, org.openhab.core.library.items.StringItem arduinoItem, String arduinoDevMap, Integer subType| logInfo("number", "Sending number message to mysensors node") var Integer state = numberItem.state logInfo("mysensors", "Function: numberOperation >> "+arduinoDevMap + "1;1;" + subType + ";" + state ) arduinoItem.sendCommand(arduinoDevMap + "1;0;" + subType + ";" + state + "\n") ] //switch function val org.eclipse.xtext.xbase.lib.Functions$Function4 switchOperation = [ org.openhab.core.library.items.SwitchItem relayItem, org.openhab.core.library.items.StringItem arduinoItem, String arduinoDevMap, Integer subType| logInfo("switch", "Sending switch message to mysensors node") var Integer state = 0 if (relayItem.state == OFF) { state = 0 } else { state = 1 } logInfo("mysensors", "Function: switchOperation >> "+arduinoDevMap + "1;1;" + subType + ";" + state ) arduinoItem.sendCommand(arduinoDevMap + "1;0;" + subType + ";" + state + "\n") ] rule "Heatpump on" when Item Power_HeatPump received command then switchOperation.apply(Power_HeatPump, MySensors_Gateway, sensorToItemsMap.get("Power_HeatPump"), V_STATUS) end rule "Heatpump mode" when Item Mode_HeatPump received update then numberOperation.apply(Mode_HeatPump, MySensors_Gateway, sensorToItemsMap.get("Mode_HeatPump"), V_VAR1) end rule "Heatpump temp" when Item Temp_HeatPump received command then numberOperation.apply(Temp_HeatPump, MySensors_Gateway, sensorToItemsMap.get("Temp_HeatPump"), V_TEMP) end rule "heatpump fan" when Item Fan_HeatPump received command then numberOperation.apply(Fan_HeatPump, MySensors_Gateway, sensorToItemsMap.get("Fan_HeatPump"), V_PERCENTAGE) end -
In live in Finland...
I now have the HeatpumpIR working together with Domoticz, so that I can also define which commands to send from Domoticz. And yes, 24 bits is plenty enough :)
https://github.com/ToniA/arduino-heatpumpir/tree/master/examples/MySensorsNode
@johnr, do you happen to have an infrared receiver module? If you do, I could assist you in decoding the protocol. This is how I for example got the Mitsubishi protocol decoded, I've never had a Mitsubishi remote controller myself...
-
Take a look at this topic on the Domoticz forum: http://www.domoticz.com/forum/viewtopic.php?f=34&t=8751
-
@ToniA Hi, do you have a guide on how to set up Domoticz with this example? I understand enough about mysensors and domoticz to be dangerous but i dont get how Domoticz can send the right command....
@SGi
Hi,
I have created the wiki:
https://www.domoticz.com/wiki/AC_/_heatpumpIREverything is based in Toni's great effort :-)
I also first used the mysensors Arduino, but since I am still using "old" mysensors ver 1.5.4 (And currently I don't have time to upgrade to latest and greatest, which support text based commands)
Then I have taken same approach as Toni and use Wemos D1 Mini Pro that uses HTTP or MQTT wifi -
Take a look at this topic on the Domoticz forum: http://www.domoticz.com/forum/viewtopic.php?f=34&t=8751
Thanks for the library it's great. I can also confirm that it works with Fujitsu remote AR-REB1E out of the box.
Trying to integrate this into HomeAssistant and just do not know where to start. Is there any example how to post a whole string of commands for the air cond via mysensors-MQTT?
-
So nobody is using it this with MQTT gateway?
-
@SGi
Hi,
I have created the wiki:
https://www.domoticz.com/wiki/AC_/_heatpumpIREverything is based in Toni's great effort :-)
I also first used the mysensors Arduino, but since I am still using "old" mysensors ver 1.5.4 (And currently I don't have time to upgrade to latest and greatest, which support text based commands)
Then I have taken same approach as Toni and use Wemos D1 Mini Pro that uses HTTP or MQTT wifi -
So nobody is using it this with MQTT gateway?
@moskovskiy82
hi, I'm not using the MQTT with mysensors
I think you should direct your questions to a HomeAssistant forum.
My setup uses Wemos D1 Mini Pro and Domoticz -
@bjacobse if I have a new Daikin heat pump with a newer remote that is not in the library, I guess I'm out of luck, right?
-
@moskovskiy82
hi, I'm not using the MQTT with mysensors
I think you should direct your questions to a HomeAssistant forum.
My setup uses Wemos D1 Mini Pro and Domoticz@bjacobse Can you elaborate a little more on how you wired things up?
Also how you combined the libs and compiled everything for easyESP?
Have a sonoff with easyESP and docs are not that clear how to that stuff -
@bjacobse Can you elaborate a little more on how you wired things up?
Also how you combined the libs and compiled everything for easyESP?
Have a sonoff with easyESP and docs are not that clear how to that stuff@moskovskiy82
I took 5v from the heatpump, mine is an IVT, I took it from the Ir receive, soldered 2wires, one GND and on for 5V and drilled a hole on the plastic casing, and then I had power for the Wemos D1 Mini Pro module.
Then 100 Ohm resister in series with the Irda LED 940nm Ir LED, connected to GPio16/D0 on the Wemos module.Downlaod the ESPEASYT files + download Tonis heatpump /P115 lib and put it in same Arduino IDE, compile it all together
-
I want to make heatpumpIR, but after trying to send the signal using simple.ino sketch to my Sharp A/C nothing happened. Confused where to start ....
@Ispandy
did you look at the previous comment?
to make it easy for you, then don't use mysensors with Arduino for this, it's too difficult to setup, but instead use the Wemos and ESPEASY using your WIFI -
@Ispandy
did you look at the previous comment?
to make it easy for you, then don't use mysensors with Arduino for this, it's too difficult to setup, but instead use the Wemos and ESPEASY using your WIFI@bjacobse There is nothing difficult in setting it up. Just connect the irda to the 3rd PWM leg
-
@bjacobse There is nothing difficult in setting it up. Just connect the irda to the 3rd PWM leg
@moskovskiy82
I certainly agree, I assume your comment actually was meant to Ispandy ;-)