pbogut / openhab-ewpesmart-binding

OpenHAB binding for EWPE Smart powered devices (Gree, Sinclair, etc)
8 stars 1 forks source link

Invalid tempSensor value #1

Closed RobbeR closed 3 years ago

RobbeR commented 3 years ago

Dear @pbogut ,

First of all, thank you for your work, it helps me to connect my Sinclair air conditioner to my OpenHAB system and I am sure your repo helps a lot to other fellows as well.

However, I have a problem, could you please check what I'm missing here: Air conditioner: Sinclair ASH-12BIV OpenHAB version: 2.5.9 My goal: I would like to control my air conditioner with my Apple HomeKit (Siri and stuff). I nearly achieve this goal with your package, but the tempSensor keeps returning invalid values. I installed and configured the HomeKit binding for OpenHAB, it works well with my other air conditioners.

My items file for the Sinclair (anonimized with "****" strings):

Switch SinclairACUnitLR_Power                "Power"                                                 { channel="ewpesmart:EWPEAirCon:********:power" }
Number SinclairACUnitLR_Mode                 "Mode"                 <ac_mode>                          { channel="ewpesmart:EWPEAirCon:********:mode" }
Number SinclairACUnitLR_SetPoint             "temp"                                    { channel="ewpesmart:EWPEAirCon:********:temp" }
Number SinclairACUnitLR_IndoorTemperatureF   "tempSensor"                                         { channel="ewpesmart:EWPEAirCon:********:tempSensor" }
String SinclairACUnitLR_Fan                  "Fan"              <fan>                              { channel="ewpesmart:EWPEAirCon:********:windSpeed" }

Group gLivingRoomSinclairThermostat "Sinclair LR Thermostat" [ "Thermostat" ]
Number ThermostatSinclairCurrentTempLR "Current temp" (gLivingRoomSinclairThermostat) [ "CurrentTemperature" ]
Number ThermostatSinclairTargetTemperatureLR "Target temp" (gLivingRoomSinclairThermostat) [ "homekit:TargetTemperature" ]
String ThermostatSinclairHeatingCoolingModeLR (gLivingRoomSinclairThermostat) [ "homekit:TargetHeatingCoolingMode" ]
String ThermostatSinclairHeatingCoolingCurModeLR (gLivingRoomSinclairThermostat) [ "homekit:CurrentHeatingCoolingMode" ]

Here's some records from openhab.log:

2020-12-28 16:16:47.311 [WARN ] [istics.impl.base.FloatCharacteristic] - Detected value out of range 66.0. Returning max value instead. Characteristic io.github.hapjava.characteristics.impl.thermostat.CurrentTemperatureCharacteristic@4a88f39f
2020-12-28 16:16:47.316 [WARN ] [istics.impl.base.FloatCharacteristic] - Detected value out of range 66.0. Returning max value instead. Characteristic io.github.hapjava.characteristics.impl.thermostat.CurrentTemperatureCharacteristic@168a255c
2020-12-28 16:16:47.316 [WARN ] [istics.impl.base.FloatCharacteristic] - Detected value out of range 66.0. Returning max value instead. Characteristic io.github.hapjava.characteristics.impl.thermostat.CurrentTemperatureCharacteristic@168a255c
2020-12-28 16:16:47.317 [WARN ] [istics.impl.base.FloatCharacteristic] - Detected value out of range 66.0. Returning max value instead. Characteristic io.github.hapjava.characteristics.impl.thermostat.CurrentTemperatureCharacteristic@168a255c
2020-12-28 16:16:47.318 [WARN ] [istics.impl.base.FloatCharacteristic] - Detected value out of range 66.0. Returning max value instead. Characteristic io.github.hapjava.characteristics.impl.thermostat.CurrentTemperatureCharacteristic@168a255c

So, as I wrote, everything (on/off state, modes, target temperature, etc.) works well, but the tempSensor value is always between 60 and 66. My first thought was it is maybe in Fahrenheit (instead of Celsius), but if I convert it to celsius, it doesn't match as well. I don't know what is this value and where it came from.

Could you help me with that, or its a problem with my air conditioner's sensor?

Thank you in advance, RobbeR

pbogut commented 3 years ago

Yeah, well, I found that the there is this TemSen property in some AC's and it can be used so I added it, but it looked like it didn't work correctly (similar values) so I assumed its not working with my unit. Didn't bother to investigate and forgot about it.

Thank you for bringing that out now because I did some google serach so I can refer you where I found this information but instead I found this:

Getting the current temperature reading from the internal sensor If the device is equipped with a temperature sensor, you can read it via the TemSen key. The value is in celsius and has an offset of +40 to avoid using negative values. For example if you get 65 from the device it means the current temperature is 65 - 40 = 25.

I will amend this module to take this 40 degree offset in to consideration and will also add C/F conversion.

As a side note, this module is kind of obsolete, as there is (or will be in next version or so) build in module into OpenHAB (gree something). I do use this one however, because I have some networking issues with my unit (or my wifi router, or combination of both) and some commands where lost from time to time, and then state was off. This module is trying to send message like 10 times if it is failing to deliver, to make sure that if there is connection error AC will still receive command.

RobbeR commented 3 years ago

Well, thank you for the research, it make sense now! I just needed to change my .rules file and now it works perfectly. BTW I don't have any problem with the network or else, I've been testing my config in the last few days (with Apple Homekit & Siri) and - except the current temperature part - I didn't have any issue. Now the current temp issue is solved as well. Again, thank you for your cooperation.

However, I spent a few hours to write the .rules file to synchronize the Apple HomeKit, Openhab and the unit with each other, so I paste my rules file here to help others in the future (you can see the subtraction with value 40 in there). The .items files posted above, which contains the Item names. Sorry about the lots of logging, it helped me with the debugging.

rule "ThermostatLRSinclair-Power"
when
    Item SinclairACUnitLR_Power changed or
    Item SinclairACUnitLR_Mode changed
then
    logInfo("Thermostat Sinclair", "openHAB Power. Info. Status: " + SinclairACUnitLR_Power.state.toString);
    logInfo("Thermostat Sinclair", "openHAB Power. Info. Mode openHAB: " + SinclairACUnitLR_Mode.state.toString);
    logInfo("Thermostat Sinclair", "openHAB Power. Info. Mode HomeKit: " + ThermostatSinclairHeatingCoolingModeLR.state.toString);

  if (SinclairACUnitLR_Power.state.toString == "ON") {
      if (SinclairACUnitLR_Mode.state.toString == "0") { // auto
          if (ThermostatSinclairHeatingCoolingModeLR.state.toString != "Auto") {
              ThermostatSinclairHeatingCoolingModeLR.sendCommand("Auto");
              logInfo("Thermostat Sinclair", "openHAB Power. Set mode HomeKit: Auto");
          }
      }

      if (SinclairACUnitLR_Mode.state.toString == "1") { // cool
          if (ThermostatSinclairHeatingCoolingModeLR.state.toString != "CoolOn") {
              ThermostatSinclairHeatingCoolingModeLR.sendCommand("CoolOn");
              logInfo("Thermostat Sinclair", "openHAB Power. Set mode HomeKit: CoolOn");
          }
      }

      if (SinclairACUnitLR_Mode.state.toString == "2") { // dry
          logInfo("Thermostat Sinclair", "openHAB Power. Dry mode is not supported...");  
      }

      if (SinclairACUnitLR_Mode.state.toString == "3") { // fan
          logInfo("Thermostat Sinclair", "openHAB Power. Fan mode is not supported...");  
      }

      if (SinclairACUnitLR_Mode.state.toString == "4") { // heating
          ThermostatSinclairHeatingCoolingModeLR.sendCommand("HeatOn");
          logInfo("Thermostat Sinclair", "openHAB Power. Set mode HomeKit: HeatOn");
      }
  }

end

rule "ThermostatLRSinclair-AppleMode"
when
  Item ThermostatSinclairHeatingCoolingModeLR changed 
then
  logInfo("Thermostat Sinclair", "Apple change mode. Info. Status: " + ThermostatSinclairHeatingCoolingModeLR.state.toString);
  logInfo("Thermostat Sinclair", "Apple change mode. Info. Mode power openHAB: " + SinclairACUnitLR_Power.state.toString);
  logInfo("Thermostat Sinclair", "Apple change mode. Info. Mode openHAB: " + SinclairACUnitLR_Mode.state.toString);

  if (ThermostatSinclairHeatingCoolingModeLR.state.toString == "Off") {
    ThermostatSinclairHeatingCoolingCurModeLR.sendCommand("Off");
    if (SinclairACUnitLR_Power.state.toString != "OFF") {
      SinclairACUnitLR_Power.sendCommand("OFF");
      logInfo("Thermostat Sinclair", "Apple change mode. Set power openHAB: OFF");
    }
  }

  if (ThermostatSinclairHeatingCoolingModeLR.state.toString == "Auto") { // AUTO
    ThermostatSinclairHeatingCoolingCurModeLR.sendCommand("Auto");
    if (SinclairACUnitLR_Power.state.toString != "ON") {
      SinclairACUnitLR_Power.sendCommand("ON");
      logInfo("Thermostat Sinclair", "Apple change mode. Set power openHAB: ON");
    }

    if (SinclairACUnitLR_Mode.state.toString != "0") {
      SinclairACUnitLR_Mode.sendCommand("0");
      logInfo("Thermostat Sinclair", "Apple change mode. Set mode openHAB: AUTO");
    }
  }

  if (ThermostatSinclairHeatingCoolingModeLR.state.toString == "HeatOn") { // AUTO
    ThermostatSinclairHeatingCoolingCurModeLR.sendCommand("HeatOn");
    if (SinclairACUnitLR_Power.state.toString != "ON") {
      SinclairACUnitLR_Power.sendCommand("ON");
      logInfo("Thermostat Sinclair", "Apple change mode. Set power openHAB: ON");
    }

    if (SinclairACUnitLR_Mode.state.toString != "4") {
      SinclairACUnitLR_Mode.sendCommand("4");
      logInfo("Thermostat Sinclair", "Apple change mode. Set mode openHAB: HeatOn");
    }
  }

  if (ThermostatSinclairHeatingCoolingModeLR.state.toString == "CoolOn") { // Cool
    ThermostatSinclairHeatingCoolingCurModeLR.sendCommand("CoolOn");
    if (SinclairACUnitLR_Power.state.toString != "ON") {
      SinclairACUnitLR_Power.sendCommand("ON");
      logInfo("Thermostat Sinclair", "Apple change mode. Set power openHAB: ON");
    }

    if (SinclairACUnitLR_Mode.state.toString != "1") {
      SinclairACUnitLR_Mode.sendCommand("1");
      logInfo("Thermostat Sinclair", "Apple change mode. Set mode openHAB: CoolOn");
    }
  }
end

rule "ThermostatLRSinclair-InTemp" // current temp
when
    Item SinclairACUnitLR_IndoorTemperatureF changed 
then
  logInfo("Thermostat Sinclair", "openHAB current temp in room. Info. Temp: " + SinclairACUnitLR_IndoorTemperatureF.state.toString);
  logInfo("Thermostat Sinclair DEBUG", "openHAB current temp in room. Info. Temp: " + ((SinclairACUnitLR_IndoorTemperatureF.state as Number) - 40));
  ThermostatSinclairCurrentTempLR.sendCommand((SinclairACUnitLR_IndoorTemperatureF.state as Number) - 40);
end

rule "ThermostatLRSinclair-Temp" // target temp
when
  Item SinclairACUnitLR_SetPoint changed 
then
  logInfo("Thermostat Sinclair", "openHAB set temp. Info. Temp: " + SinclairACUnitLR_SetPoint.state.toString);
  logInfo("Thermostat Sinclair", "openHAB set temp. Info. Apple Temp: " + ThermostatSinclairTargetTemperatureLR.state.toString);

  if (SinclairACUnitLR_SetPoint.state != ThermostatSinclairTargetTemperatureLR.state) {
    ThermostatSinclairTargetTemperatureLR.sendCommand(SinclairACUnitLR_SetPoint.state.toString);
    logInfo("Thermostat Sinclair", "openHAB set temp. New Apple Temp: " + SinclairACUnitLR_SetPoint.state.toString);
  }
end

rule "ThermostatLRSinclair-AppleTemp"
when
  Item ThermostatSinclairTargetTemperatureLR changed 
then
  logInfo("Thermostat Sinclair", "Apple set temp. Info. Temp: " + ThermostatSinclairTargetTemperatureLR.state.toString);
  logInfo("Thermostat Sinclair", "Apple set temp. Info. openHAB Temp: " + SinclairACUnitLR_SetPoint.state.toString);

  if (ThermostatSinclairTargetTemperatureLR.state != SinclairACUnitLR_SetPoint.state) {
    SinclairACUnitLR_SetPoint.sendCommand(ThermostatSinclairTargetTemperatureLR.state.toString);
    logInfo("Thermostat Sinclair", "Apple set temp. New openHAB Temp: " + ThermostatSinclairTargetTemperatureLR.state.toString);
  }
end

rule "ThermostatLRSinclair-Start"
when
  System started
then
  logInfo("Thermostat Sinclair", "Boot set params. Info. Status openHAB: " + SinclairACUnitLR_Power.state.toString);
  logInfo("Thermostat Sinclair", "Boot set params. Info. Mode openHAB: " + SinclairACUnitLR_Mode.state.toString);
  logInfo("Thermostat Sinclair", "Boot set params. Info. Set Temp openHAB: " + SinclairACUnitLR_SetPoint.state.toString);
  logInfo("Thermostat Sinclair", "Boot set params. Info. Inroom Temp openHAB: " + ((SinclairACUnitLR_IndoorTemperatureF.state as Number) - 40));

  if (SinclairACUnitLR_Power.state.toString == "ON") {
    if (SinclairACUnitLR_Mode.state.toString == "0") {
      if (ThermostatSinclairHeatingCoolingModeLR.state.toString != "Auto") {
        ThermostatSinclairHeatingCoolingModeLR.sendCommand("Auto");
        logInfo("Thermostat Sinclair", "Boot set params. Set mode HomeKit: Auto");
      }
    }

    if (SinclairACUnitLR_Mode.state.toString == "1") {
      if (ThermostatSinclairHeatingCoolingModeLR.state.toString != "CoolOn") {
        ThermostatSinclairHeatingCoolingModeLR.sendCommand("CoolOn");
        logInfo("Thermostat Sinclair", "Boot set params. Set mode HomeKit: CoolOn");
      }
    }

    if (SinclairACUnitLR_Mode.state.toString == "4") {
      if (ThermostatSinclairHeatingCoolingModeLR.state.toString != "HeatOn") {
        ThermostatSinclairHeatingCoolingModeLR.sendCommand("HeatOn");
        logInfo("Thermostat Sinclair", "Boot set params. Set mode HomeKit: HeatOn");
      }
    }
  }

  if (SinclairACUnitLR_Power.state.toString == "OFF") {
    if (ThermostatSinclairHeatingCoolingModeLR.state.toString != "OFF") { 
      ThermostatSinclairHeatingCoolingModeLR.sendCommand("Off");
      logInfo("Thermostat Sinclair", "Boot set params. Set mode HomeKit: Off");
    }
  }

  ThermostatSinclairCurrentTempLR.sendCommand(((SinclairACUnitLR_IndoorTemperatureF.state as Number) - 40));

  if (SinclairACUnitLR_SetPoint.state != ThermostatSinclairTargetTemperatureLR.state) {
    ThermostatSinclairTargetTemperatureLR.sendCommand(SinclairACUnitLR_SetPoint.state.toString);
    logInfo("Thermostat Sinclair", "Boot set params. New Apple Temp: " + SinclairACUnitLR_SetPoint.state.toString);
  }
end