Announcement

Collapse
No announcement yet.

Changing a variable from HS?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Changing a variable from HS?

    Hi, is it possible in some way to change a variable in the arduino from HS?

    I'm creating a thermostat, and would like to be able to change the setpoint temperature from HS in addition to using the thermostat physical buttons.

    #2
    Originally posted by actibus View Post
    Hi, is it possible in some way to change a variable in the arduino from HS?

    I'm creating a thermostat, and would like to be able to change the setpoint temperature from HS in addition to using the thermostat physical buttons.
    What are you going to control with the Arduino? There are no variable outputs other than PWM.

    Are you going to read the temperature with a OneWire device and use an Arduino output to control the heating or cooling device? If that is the case I would setup a virtual device as the setpoint then compare the OneWire device to this setpoint with an Easy Trigger device comparison or with scripting.
    HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

    Comment


      #3
      Can you explain your system a little more. If you use the API then yes you can send a variable to the board and act on that but as Randy said you can do it in Homeseer depending on the devices you are using.

      Greig.
      Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
      X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
      Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
      Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
      Scripts =
      Various

      Comment


        #4
        I do not want the thermostat to rely on HS to work, so it will control everything itself, but I would like to be able to control it using HS.

        The arduino (or actually NodeMCU/ESP8266) will measure room temperature using DHT11 and floor temperature using DS18B20 (floor heating).
        Using an relay it will turn on/off an Aeotec z-wave module using the switch input.
        I will connect the z-wave module to HS to be able to get power consumption readings and heating status.

        At the moment HS shows current room/floor and setpoint temperature using JSON commands to update devices in HS.

        I need some help on how to send values to it from HS

        I'm using the plugin with a few Arduino boards, but have not yet tried adapting the code to work on the NodeMcu/ESP.

        Comment


          #5
          Originally posted by actibus View Post
          I do not want the thermostat to rely on HS to work, so it will control everything itself, but I would like to be able to control it using HS.

          The arduino (or actually NodeMCU/ESP8266) will measure room temperature using DHT11 and floor temperature using DS18B20 (floor heating).
          Using an relay it will turn on/off an Aeotec z-wave module using the switch input.
          I will connect the z-wave module to HS to be able to get power consumption readings and heating status.

          At the moment HS shows current room/floor and setpoint temperature using JSON commands to update devices in HS.

          I need some help on how to send values to it from HS

          I'm using the plugin with a few Arduino boards, but have not yet tried adapting the code to work on the NodeMcu/ESP.
          For this you would need to use the API code.
          As per the notes in the sketch:

          /* To Send Data to Homeseer use SendToHS(Device,Value)
          Eg.. SendToHS(1,200); where 1 is the API device in homeseer and 200 is the value to send
          To Recieve data from Homeseer look up the FromHS array that is updated when the device value changes.

          Eg.. FromHS[5] would be the data from API Output device 5
          All code that is located just below this block will execute regardless of connection status!

          You can include SendToHS() calls, however when there isn't an active connection, it will just return and continue.
          If you only want code to execute when HomeSeer is connected, put it inside the if statement below.
          */

          So if you add a API output device in Homeseer this will send the Value to the array FromHS on the board. you can then use this for what you want.

          Greig.
          Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
          X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
          Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
          Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
          Scripts =
          Various

          Comment


            #6
            Thanks, I will be looking into the ESP8266 proof of concept sketches and see if I can make it work using the FromHS code.
            Apreciate the fast replies!

            Comment


              #7
              I have it running now on the NodeMCU.
              But when I send a value from NodeMCU to HS it will only update the first time the SendToHS is run, then it seems to loose connection..
              The code itself keeps running, and my serial.print comments tells me its sending values, but in HS it will say that the board has an connection error.
              This only happens if SendToHS has run, it does not disconnect when only receiving FromHS values..

              I guess it's caused by some fault in the code rewriting from Arduino to ESP8266.
              I did changes based on the API example in the Proof of concept thread, and since that was based on an old plugin version, I did some more modifications based on the .181 version I use..

              Here is the HSSetup code I'm using, maybe you can spot something?


              Code:
              void HSSetup() {
              
              #ifdef ESP8266
                EEPROM.begin(256);
              #endif
                EEpromVersion = EEPROM.read(250);
                ServerIP = IPAddress(EEPROM.read(2), EEPROM.read(3), EEPROM.read(4), EEPROM.read(5));
              #if ISIP == 1
                if (EEpromVersion != 22) {
                  ServerIP = HomeseerIP;
                  EEPROM.write(2, ServerIP[0]);
                  EEPROM.write(3, ServerIP[1]);
                  EEPROM.write(4, ServerIP[2]);
                  EEPROM.write(5, ServerIP[3]);
                  EEPROM.write(250, 22); //Store the version where the eeprom data layout was last changed
                  //EEPROM.commit();
                  EEpromVersion = 22;
                }
              #ifdef ESP8266
              
                Serial.begin(115200);
              
                // We start by connecting to a WiFi network
                WiFi.begin(ssid, pass);
                WiFi.config(ip, gateway, subnet);
              
                while (WiFi.status() != WL_CONNECTED) {
                  delay(500);
                }
              #else
                Ethernet.begin(mac, ip);
              #endif
              
                Udp.begin(localPort);
                Udp.setTimeout(0);
                delay(1000);
                SendConnect();
              #else
                Serial.begin(115200);
                Serial.flush();
                Serial.setTimeout(0);
                delay(1000);
                Serial.print("Connect ");
                Serial.println(BoardAdd);
              #endif
              
                IsConnected = false;
              
              }
              
              void SendConnect()
              {
              #if ISIP == 0
                Serial.print("Connect ");
                Serial.println(BoardAdd);
              #else
                Udp.beginPacket(ServerIP, ServerPort); //First send a connect packet to the dynamic IP stored in eeprom
                Udp.print("Connect ");
                Udp.print(BoardAdd);
                Udp.endPacket();
                if (ServerIP != HomeseerIP) {
                  Udp.beginPacket(HomeseerIP, ServerPort); //Then if the stored value doesn't match the pre-specified one, send a connect packet there also
                  Udp.print("Connect ");
                  Udp.print(BoardAdd);
                  Udp.endPacket();
                }
              
              #endif
              }
              
              
              #if ISIP == 1
              void IsUDP() {
                int packetSize = Udp.parsePacket();
                if (packetSize)
                {
                  //LastRcvIP = Udp.remoteIP();
                  IPAddress remote = Udp.remoteIP();
                  Byte1 = Udp.parseInt();
                  Udp.read();
                  Byte2 = Udp.read();
                  Byte3 = Udp.parseInt();
                  Byte4 = Udp.parseInt();
                  Byte5 = Udp.parseInt();
                  DataEvent();
                }
              }
              
              #else
              void serialEvent() {
                while (Serial.available() > 0) {
                  delay(17);
              
              
                  Byte1 = Serial.parseInt();
                  Serial.read();
                  Byte2 = Serial.read();
                  Byte3 = Serial.parseInt();
                  Byte4 = Serial.parseInt();
                  Byte5 = Serial.parseInt();
                  DataEvent();
                }
              }
              #endif
              
              
              /*
              
                Used Data Input Cases
                D Disconnect
                r reset
                K Keepalive
                O PinMode Output Set
                d Input debounce time set
                C Connect request
                c Connection established - report current status
              */
              void DataEvent() {
              
              
              
                if (Byte1 == BoardAdd) {
                  switch (Byte2) {
              
                    case 'c':
                      IsConnected = true;
              #if ISIP == 1
                      //if (LastRcvIP != ServerIP) {
                      if (Udp.remoteIP() != ServerIP) {
                        //ServerIP=LastRcvIP;
                        ServerIP = Udp.remoteIP();
                        EEPROM.write(2, ServerIP[0]);
                        EEPROM.write(3, ServerIP[1]);
                        EEPROM.write(4, ServerIP[2]);
                        EEPROM.write(5, ServerIP[3]);
              #ifdef ESP8266
                        EEPROM.commit();
              #endif
                      }
              #endif
              
                      break;
              
                    case 'C':
              #if ISIP == 1
                      //Udp.beginPacket(LastRcvIP, ServerPort);
                      Udp.beginPacket(Udp.remoteIP(), ServerPort);
                      Udp.print("Version ");
                      Udp.print(BoardAdd);
                      Udp.print(" ");
                      Udp.print(Version);
                      Udp.println(" HS3");
                      Udp.endPacket();
              
                      //Udp.beginPacket(LastRcvIP, ServerPort);
                      Udp.beginPacket(Udp.remoteIP(), ServerPort);
                      delay(100);
                      Udp.print("Connected ");
                      Udp.println(BoardAdd);
                      Udp.endPacket();
              #else
                      Serial.print("Version ");
                      Serial.print(BoardAdd);
                      Serial.print(" ");
                      Serial.print(Version);
                      Serial.println(" HS3");
                      delay(100);
                      Serial.print("Connected ");
                      Serial.println(BoardAdd);
              #endif
                      delay(100);
                      IsConnected = false;
                      break;
              
                    case 'K':
                      delay(200);
              #if ISIP == 1
                      //Udp.beginPacket(LastRcvIP, ServerPort);
                      Udp.beginPacket(Udp.remoteIP(), ServerPort);
                      Udp.print("Alive ");
                      Udp.println(BoardAdd);
                      Udp.endPacket();
                      if (Udp.remoteIP() != ServerIP) {
                        ServerIP = Udp.remoteIP();
                        EEPROM.write(2, ServerIP[0]);
                        EEPROM.write(3, ServerIP[1]);
                        EEPROM.write(4, ServerIP[2]);
                        EEPROM.write(5, ServerIP[3]);
              #ifdef ESP8266
                        EEPROM.commit();
              #endif
                      }
              #else
                      Serial.print("Alive ");
                      Serial.println(BoardAdd);
              #endif
                      break;
              
                    case 'r':
                      delay(200);
                      resetFunc();  //call reset
                      break;
              
                    case 'O':
                      FromHS[Byte3] = Byte4;
                      break;
              
                    case 'D':
                      IsConnected = false;
                      break;
                  }
                }
              }
              
              void SendToHS(byte Device, long Data) {
                if (IsConnected == true) {
              #if ISIP == 1
                  //Udp.beginPacket(LastRcvIP, ServerPort);
                  Udp.beginPacket(Udp.remoteIP(), ServerPort);
                  Udp.print(BoardAdd);
                  Udp.print(" API ");
                  Udp.print(Device);
                  Udp.print(" ");
                  Udp.print(Data);
                  Udp.endPacket();
              #else
                  Serial.print(BoardAdd);
                  Serial.print(" API ");
                  Serial.print(Device);
                  Serial.print(" ");
                  Serial.println(Data);
              #endif
                }
              }
              
              void SendToHS(byte Device, int Data) {
                if (IsConnected == true) {
              #if ISIP == 1
                  //Udp.beginPacket(LastRcvIP, ServerPort);
                  Udp.beginPacket(Udp.remoteIP(), ServerPort);
                  Udp.print(BoardAdd);
                  Udp.print(" API ");
                  Udp.print(Device);
                  Udp.print(" ");
                  Udp.print(Data);
                  Udp.endPacket();
              #else
                  Serial.print(BoardAdd);
                  Serial.print(" API ");
                  Serial.print(Device);
                  Serial.print(" ");
                  Serial.println(Data);
              #endif
                }
              }
              
              void SendToHS(byte Device, float Data) {
                if (IsConnected == true) {
              #if ISIP == 1
                  //Udp.beginPacket(LastRcvIP, ServerPort);
                  Udp.beginPacket(Udp.remoteIP(), ServerPort);
                  Udp.print(BoardAdd);
                  Udp.print(" API ");
                  Udp.print(Device);
                  Udp.print(" ");
                  Udp.print(Data);
                  Udp.endPacket();
              #else
                  Serial.print(BoardAdd);
                  Serial.print(" API ");
                  Serial.print(Device);
                  Serial.print(" ");
                  Serial.println(Data);
              #endif
                }
              }

              Comment


                #8
                Done some more error research, it seems the problem is with Udp.remoteIP.
                At first run it is 192.168.1.61 as it should be, but on the next run, and all after it is 0.0.0.0
                Why is that?

                I changed the SendToHS line from:
                Udp.beginPacket(Udp.remoteIP(), ServerPort);

                To hardcoded
                Udp.beginPacket(HomeseerIP, ServerPort);

                Then it works great..

                Comment


                  #9
                  Originally posted by actibus View Post
                  Done some more error research, it seems the problem is with Udp.remoteIP.
                  At first run it is 192.168.1.61 as it should be, but on the next run, and all after it is 0.0.0.0
                  Why is that?

                  I changed the SendToHS line from:
                  Udp.beginPacket(Udp.remoteIP(), ServerPort);

                  To hardcoded
                  Udp.beginPacket(HomeseerIP, ServerPort);

                  Then it works great..
                  I can not tell you why but I will do more testing on your thoughts as I have been looking in to this for a while and have not been getting anywhere.

                  Greig.
                  Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
                  X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
                  Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
                  Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
                  Scripts =
                  Various

                  Comment

                  Working...
                  X