Skip to content
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Heatpump Sketch Help
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store

Heatpump Sketch Help

Scheduled Pinned Locked Moved Development
7 Posts 3 Posters 2.3k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGiS Offline
    SGiS Offline
    SGi
    wrote on last edited by
    #1

    Hi,

    I need some help converting the Heatpump sketch example to 2.0 and also isolating to just the Mitsubishi model as i have no need or memory for all the models.... i guess my biggest issue is where in the sketch is the model actually defined?

    Link to sketch that i need converting below:

    https://www.mysensors.org/build/heatpump

    Cheers
    Scott

    sundberg84S 1 Reply Last reply
    0
    • SGiS SGi

      Hi,

      I need some help converting the Heatpump sketch example to 2.0 and also isolating to just the Mitsubishi model as i have no need or memory for all the models.... i guess my biggest issue is where in the sketch is the model actually defined?

      Link to sketch that i need converting below:

      https://www.mysensors.org/build/heatpump

      Cheers
      Scott

      sundberg84S Offline
      sundberg84S Offline
      sundberg84
      Hardware Contributor
      wrote on last edited by sundberg84
      #2

      @SGi - check this out: https://forum.mysensors.org/topic/4276/converting-a-sketch-from-1-5-x-to-2-0-x

      In the sketch it looks like you just define which you want to use:
      Just remove/erase the ones you dont want.

      #include <FujitsuHeatpumpIR.h>
      #include <PanasonicCKPHeatpumpIR.h>
      #include <PanasonicHeatpumpIR.h>
      #include <CarrierHeatpumpIR.h>
      #include <MideaHeatpumpIR.h>
      #include <MitsubishiHeatpumpIR.h>
      #include <SamsungHeatpumpIR.h>
      #include <SharpHeatpumpIR.h>
      #include <DaikinHeatpumpIR.h>```

      Controller: Proxmox VM - Home Assistant
      MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
      MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
      RFLink GW - Arduino Mega + RFLink Shield, 433mhz

      1 Reply Last reply
      0
      • SGiS Offline
        SGiS Offline
        SGi
        wrote on last edited by
        #3

        Ok, i have managed to get a heatpump IR sketch working somewhat. I can see the node in 'hardware' and even the children but they do not appear in 'devices'... is there something fundamentally wrong in my sketch?

        I am using Domoticz and a RPI controller.

        0_1485842430447_upload-0a99d4c1-0ede-4128-a926-481cb0270315

        // Enable debug prints to serial monitor
        #define MY_DEBUG
        
        // Enable and select radio type attached
        #define MY_RADIO_NRF24
        
        #include <SPI.h>
        #include <MySensors.h>
        
        #include <MitsubishiHeatpumpIR.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
        
        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 MitsubishiFDHeatpumpIR();
        
        //Some global variables to hold the states
        int POWER_STATE;
        int TEMP_STATE;
        int FAN_STATE;
        int MODE_STATE;
        
        void setup()  
        {  
          // begin(incomingMessage, AUTO, false);
        }
          
        void presentation()  
        {     
          // Send the sketch version information to the gateway and Controller
          sendSketchInfo("Heatpump", "1.0");
        
          // Register all sensors to gw (they will be created as child devices)
          present(POWER_ID, S_BINARY);
          present(MODE_ID, S_HVAC);
          present(FAN_ID, S_HVAC);
          present(TEMP_ID, S_HVAC);
          present(VDIR_ID, S_CUSTOM);
          present(HDIR_ID, S_CUSTOM);
             
          // Load our values on start
          POWER_STATE = loadState(POWER_ID);
          TEMP_STATE = loadState(TEMP_ID);
          FAN_STATE = loadState(FAN_ID);
          MODE_STATE = loadState(MODE_ID);
          
          sendHeatpumpCommand();
        }
        
        void loop() {
        
        } 
        
        void handlePowerMessage(bool newState) {
          if (newState) {
            POWER_STATE = POWER_ON;
          }
          else {
            POWER_STATE = POWER_OFF;
          }
          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;
          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;
          saveState(FAN_ID, newFan);
        }
        
        void handleTempMessage(int newTemp) {
          TEMP_STATE = newTemp;
          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();
        }
        
        sundberg84S 1 Reply Last reply
        0
        • SGiS SGi

          Ok, i have managed to get a heatpump IR sketch working somewhat. I can see the node in 'hardware' and even the children but they do not appear in 'devices'... is there something fundamentally wrong in my sketch?

          I am using Domoticz and a RPI controller.

          0_1485842430447_upload-0a99d4c1-0ede-4128-a926-481cb0270315

          // Enable debug prints to serial monitor
          #define MY_DEBUG
          
          // Enable and select radio type attached
          #define MY_RADIO_NRF24
          
          #include <SPI.h>
          #include <MySensors.h>
          
          #include <MitsubishiHeatpumpIR.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
          
          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 MitsubishiFDHeatpumpIR();
          
          //Some global variables to hold the states
          int POWER_STATE;
          int TEMP_STATE;
          int FAN_STATE;
          int MODE_STATE;
          
          void setup()  
          {  
            // begin(incomingMessage, AUTO, false);
          }
            
          void presentation()  
          {     
            // Send the sketch version information to the gateway and Controller
            sendSketchInfo("Heatpump", "1.0");
          
            // Register all sensors to gw (they will be created as child devices)
            present(POWER_ID, S_BINARY);
            present(MODE_ID, S_HVAC);
            present(FAN_ID, S_HVAC);
            present(TEMP_ID, S_HVAC);
            present(VDIR_ID, S_CUSTOM);
            present(HDIR_ID, S_CUSTOM);
               
            // Load our values on start
            POWER_STATE = loadState(POWER_ID);
            TEMP_STATE = loadState(TEMP_ID);
            FAN_STATE = loadState(FAN_ID);
            MODE_STATE = loadState(MODE_ID);
            
            sendHeatpumpCommand();
          }
          
          void loop() {
          
          } 
          
          void handlePowerMessage(bool newState) {
            if (newState) {
              POWER_STATE = POWER_ON;
            }
            else {
              POWER_STATE = POWER_OFF;
            }
            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;
            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;
            saveState(FAN_ID, newFan);
          }
          
          void handleTempMessage(int newTemp) {
            TEMP_STATE = newTemp;
            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();
          }
          
          sundberg84S Offline
          sundberg84S Offline
          sundberg84
          Hardware Contributor
          wrote on last edited by
          #4

          @SGi - you will not see any device before first value is sent. Make sure you send status or something on startup.

          Controller: Proxmox VM - Home Assistant
          MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
          MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
          RFLink GW - Arduino Mega + RFLink Shield, 433mhz

          SGiS 1 Reply Last reply
          0
          • sundberg84S sundberg84

            @SGi - you will not see any device before first value is sent. Make sure you send status or something on startup.

            SGiS Offline
            SGiS Offline
            SGi
            wrote on last edited by
            #5

            @sundberg84 Ok thanks, i thought the following part of the code in Presentation() was doing that?

            // Load our values on start
              POWER_STATE = loadState(POWER_ID);
              TEMP_STATE = loadState(TEMP_ID);
              FAN_STATE = loadState(FAN_ID);
              MODE_STATE = loadState(MODE_ID);
              
              sendHeatpumpCommand();```
            sundberg84S 1 Reply Last reply
            0
            • SGiS SGi

              @sundberg84 Ok thanks, i thought the following part of the code in Presentation() was doing that?

              // Load our values on start
                POWER_STATE = loadState(POWER_ID);
                TEMP_STATE = loadState(TEMP_ID);
                FAN_STATE = loadState(FAN_ID);
                MODE_STATE = loadState(MODE_ID);
                
                sendHeatpumpCommand();```
              sundberg84S Offline
              sundberg84S Offline
              sundberg84
              Hardware Contributor
              wrote on last edited by
              #6

              @SGi - not sure, but I think that is load the saved state from EEPROM.
              You should have some sort of send(value);

              Controller: Proxmox VM - Home Assistant
              MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
              MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
              RFLink GW - Arduino Mega + RFLink Shield, 433mhz

              1 Reply Last reply
              0
              • M Offline
                M Offline
                moskovskiy82
                wrote on last edited by
                #7

                I can see the topic is quite old but myabe a complete sensor 2.1 example?
                I can see that this code for openhab is quite popular. But i'm facing an issue constructing the proper MQTT topic
                As on my set up all my control messages look like

                      topic: "mys-in/41/2/1/0/2"
                      payload: "0"
                

                So wonder which ones to use with this sketch?

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                14

                Online

                11.7k

                Users

                11.2k

                Topics

                113.0k

                Posts


                Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • OpenHardware.io
                • Categories
                • Recent
                • Tags
                • Popular