Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add TemSen to get CurrentTemperature from internal sensor #129

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions custom_components/gree/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def __init__(self, hass, name, ip_addr, port, mac_addr, timeout, target_temp_ste
else:
self._uid = 0

self._acOptions = { 'Pow': None, 'Mod': None, 'SetTem': None, 'WdSpd': None, 'Air': None, 'Blo': None, 'Health': None, 'SwhSlp': None, 'Lig': None, 'SwingLfRig': None, 'SwUpDn': None, 'Quiet': None, 'Tur': None, 'StHt': None, 'TemUn': None, 'HeatCoolType': None, 'TemRec': None, 'SvSt': None, 'SlpMod': None }
self._acOptions = { 'Pow': None, 'Mod': None, 'SetTem': None, 'WdSpd': None, 'Air': None, 'Blo': None, 'Health': None, 'SwhSlp': None, 'Lig': None, 'SwingLfRig': None, 'SwUpDn': None, 'Quiet': None, 'Tur': None, 'StHt': None, 'TemUn': None, 'TemSen': None, 'HeatCoolType': None, 'TemRec': None, 'SvSt': None, 'SlpMod': None }

self._firstTimeRun = True

Expand Down Expand Up @@ -267,7 +267,7 @@ def SetAcOptions(self, acOptions, newOptionsToOverride, optionValuesToOverride =

def SendStateToAc(self, timeout):
_LOGGER.info('Start sending state to HVAC')
statePackJson = '{' + '"opt":["Pow","Mod","SetTem","WdSpd","Air","Blo","Health","SwhSlp","Lig","SwingLfRig","SwUpDn","Quiet","Tur","StHt","TemUn","HeatCoolType","TemRec","SvSt","SlpMod"],"p":[{Pow},{Mod},{SetTem},{WdSpd},{Air},{Blo},{Health},{SwhSlp},{Lig},{SwingLfRig},{SwUpDn},{Quiet},{Tur},{StHt},{TemUn},{HeatCoolType},{TemRec},{SvSt},{SlpMod}],"t":"cmd"'.format(**self._acOptions) + '}'
statePackJson = '{' + '"opt":["Pow","Mod","SetTem","WdSpd","Air","Blo","Health","SwhSlp","Lig","SwingLfRig","SwUpDn","Quiet","Tur","StHt","TemUn","TemSen","HeatCoolType","TemRec","SvSt","SlpMod"],"p":[{Pow},{Mod},{SetTem},{WdSpd},{Air},{Blo},{Health},{SwhSlp},{Lig},{SwingLfRig},{SwUpDn},{Quiet},{Tur},{StHt},{TemUn},{TemSen},{HeatCoolType},{TemRec},{SvSt},{SlpMod}],"t":"cmd"'.format(**self._acOptions) + '}'
sentJsonPayload = '{"cid":"app","i":0,"pack":"' + base64.b64encode(self.CIPHER.encrypt(self.Pad(statePackJson).encode("utf8"))).decode('utf-8') + '","t":"pack","tcid":"' + str(self._mac_addr) + '","uid":{}'.format(self._uid) + '}'
# Setup UDP Client & start transfering
clientSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
Expand All @@ -291,7 +291,11 @@ def UpdateHATargetTemperature(self):
_LOGGER.info('HA target temp set according to HVAC state to 8℃ since 8℃ heating mode is active')
else:
self._target_temperature = self._acOptions['SetTem']
_LOGGER.info('HA target temp set according to HVAC state to: ' + str(self._acOptions['SetTem']))
_LOGGER.info('HA target temp set according to HVAC state to: ' + str(self._acOptions['TemSen']))

def UpdateHACurrentTemperature(self):
self._current_temperature = self._acOptions['TemSen']
_LOGGER.info('HA target temp set according to HVAC state to: ' + str(self._acOptions['TemSen']))

def UpdateHAOptions(self):
# Sync HA with retreived HVAC options
Expand Down Expand Up @@ -421,6 +425,7 @@ def UpdateHAFanMode(self):

def UpdateHAStateToCurrentACState(self):
self.UpdateHATargetTemperature()
self.UpdateHACurrentTemperature()
self.UpdateHAOptions()
self.UpdateHAHvacMode()
self.UpdateHACurrentSwingMode()
Expand All @@ -430,7 +435,7 @@ def SyncState(self, acOptions = {}):
#Fetch current settings from HVAC
_LOGGER.info('Starting SyncState')

optionsToFetch = ["Pow","Mod","SetTem","WdSpd","Air","Blo","Health","SwhSlp","Lig","SwingLfRig","SwUpDn","Quiet","Tur","StHt","TemUn","HeatCoolType","TemRec","SvSt","SlpMod"]
optionsToFetch = ["Pow","Mod","SetTem","WdSpd","Air","Blo","Health","SwhSlp","Lig","SwingLfRig","SwUpDn","Quiet","Tur","StHt","TemUn","TemSen","HeatCoolType","TemRec","SvSt","SlpMod"]
currentValues = self.GreeGetValues(optionsToFetch)

# Set latest status from device
Expand Down