RobHofmann / HomeAssistant-GreeClimateComponent

Custom Gree climate component written in Python3 for Home Assistant. Controls AC's supporting the Gree protocol.
GNU General Public License v3.0
310 stars 104 forks source link

Unable to change the State of my GREE A/C #40

Closed savvasha closed 4 years ago

savvasha commented 4 years ago

Describe the bug I am retrieving the states of my GREE airconditioning unit, but I am unable to change those states. For example I cannot change the Temperature, the Operation etc. If I change those states from GREE remote control, then the HA card is refreshed showing the correct states.

Configuration

- platform: gree
  name: "Test AC"
  host: 192.168.10.xxx
  port: 7000
  mac: xx-xx-xx-xx-xx-xx
  target_temp_step: 1
  encryption_key: "xxxxxxxxxxxxx"

Expected behavior Expecting to be able to control the states of my AC through HA

Platform:

Additional context I have enabled the debug logger and I am receiving the following:

2019-11-11 12:30:15 INFO (SyncWorker_6) [custom_components.gree.climate] Start sending state to HVAC
2019-11-11 12:30:19 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1261, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    self._platforms.values(), func, call, service_name, required_features
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 348, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 370, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 415, in async_set_hvac_mode
    await self.hass.async_add_executor_job(self.set_hvac_mode, hvac_mode)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/gree/climate.py", line 703, in set_hvac_mode
    self.SyncState({'Mod': self._hvac_modes.index(hvac_mode), 'Pow': 1})
  File "/config/custom_components/gree/climate.py", line 398, in SyncState
    self.SendStateToAc(self._timeout)
  File "/config/custom_components/gree/climate.py", line 256, in SendStateToAc
    data, addr = clientSock.recvfrom(64000)
socket.timeout: timed out
wacher74 commented 4 years ago

What the modell you have? I use Amber AC, Gree+ app and wifi are set up months ago. Home Assistant integration is done today. I didn't have to use encryption_key.

savvasha commented 4 years ago

Hi there wacher74. I have a model called BORA AC. You can see more info here http://www.bestcoolcyprus.com/images/pdfs/Bora_technical.pdf I didn't try to use it without encryption key to be honest 😁 Gree+ app is working just fine. I will try to test without an encryption key and come back.

savvasha commented 4 years ago

Unfortunately without an encryption_key HA doesnt see the AC unit at all.

RobHofmann commented 4 years ago

You are receiving a timeout. This generally means the endpoint you are trying to talk to isn't listening or isnt responding in time.

How do you know for sure you are getting information FROM the AC? By default Home Assistant sets some values in this component.

savvasha commented 4 years ago

When I am changing the status and the temperature of the AC using the remote control then these changes are reflected back to HA.

RobHofmann commented 4 years ago

Interesting. Can you enable debug logging and post the output of the homeassistant.log?

savvasha commented 4 years ago

Ok. Before starting Grafeio A/C: https://snipboard.io/sZuOfK.jpg After starting Grafeio A/C with remote control and setting temp at 25C: https://snipboard.io/r8Niav.jpg

Below are the whole logging output: https://pastebin.com/m6cgjtAr

At the end I tried to change the state of Grafeio A/C through HA.

Thanks, Savvas

RobHofmann commented 4 years ago

It seems to be fetching fine, but the updating goes wrong indeed. It receives a timeout, but I can't see why.

I'm not sure how to proceed on this. I doubt this issue can be fixed in code. This might be an issue with the protocol implementation on the device.

Do you have a specific app for this AC? or is it a generic gree app?

savvasha commented 4 years ago

First of all thank you for the time you are spending for this issue. I am using GREE+ app https://play.google.com/store/apps/details?id=com.gree.greeplus

RobHofmann commented 4 years ago

Hmm, this would suggest a generic GREE protocol. What kind of AC do you have? and does it come with a manual?

savvasha commented 4 years ago

It is called as GREE BORA-DV Inverter EcoDesign. This is the manual: https://drive.google.com/file/d/1Dr1UKCraDlbWtZRiownptImF2e5Tmq63/view

RobHofmann commented 4 years ago

Can't find any info on the protocol implementation. Im kind of lost here. I dont know how to proceed. The logging shows it works up until you try to change something, giving you a timeout. This does not make sense at all.

RobHofmann commented 4 years ago

Did you manage to get this to work?

savvasha commented 4 years ago

Unfortunately no...

asev commented 4 years ago

Hello. I have identical issue with C&H SUPREME Inverter CH-S09FTXAM2S. From EWPE Smart app AC control works fine. On Home Assistant I can see AC values, but can't change them.

Error message is also the same

2020-01-26 10:23:44 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1251, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 201, in handle_service
    self._platforms.values(), func, call, service_name, required_features
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 335, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 357, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 422, in async_set_hvac_mode
    await self.hass.async_add_executor_job(self.set_hvac_mode, hvac_mode)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/gree/climate.py", line 754, in set_hvac_mode
    self.SyncState({'Mod': self._hvac_modes.index(hvac_mode), 'Pow': 1})
  File "/config/custom_components/gree/climate.py", line 426, in SyncState
    self.SendStateToAc(self._timeout)
  File "/config/custom_components/gree/climate.py", line 266, in SendStateToAc
    data, addr = clientSock.recvfrom(64000)
socket.timeout: timed out
Hagakurje commented 4 years ago

Same problem. I have Gree Smart GWH09QB-K3DNB6G, and Gree+ android app works. But when I try:

telnet 192.168.4.22 7000
telnet: Unable to connect to remote host: Connection timed out

Maybe wrong port? Or some changes in gree protocol?

climate.yaml

- platform: gree
  name: Gree9
  host: 192.168.4.22
  port: 7000
  mac: 'f4:91:1e:8e:5e:80'
  target_temp_step: 1

log

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 179, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/asyncio/coroutines.py", line 120, in coro
    res = func(*args, **kw)
  File "/config/custom_components/gree/climate.py", line 115, in async_setup_platform
    GreeClimate(hass, name, ip_addr, port, mac_addr, timeout, target_temp_step, temp_sensor_entity_id, lights_entity_id, xfan_entity_id, health_entity_id, powersave_entity_id, sleep_entity_id, eightdegheat_entity_id, hvac_modes, fan_modes, swing_modes, encryption_key, uid)
  File "/config/custom_components/gree/climate.py", line 160, in __init__
    self._encryption_key = self.GetDeviceKey().encode("utf8")
  File "/config/custom_components/gree/climate.py", line 237, in GetDeviceKey
    return self.FetchResult(cipher, self._ip_addr, self._port, self._timeout, jsonPayloadToSend)['key']
  File "/config/custom_components/gree/climate.py", line 220, in FetchResult
    data, addr = clientSock.recvfrom(64000)
socket.timeout: timed out
wacher74 commented 4 years ago

192.168.4.x is not a usual IP range, where did you found it?

Hagakurje commented 4 years ago

192.168.4.x is not a usual IP range, where did you found it?

It must be only usual ip? I have more then one network 11

wacher74 commented 4 years ago

No, I don't think that it must be usual ip :) But the error lines of telnet and HA both point to some/same network related error. You have 2 AC, both of them are inaccesible? Did you try a portscan against them?

Hagakurje commented 4 years ago

Did you try a portscan against them? I works! I dont know why, a lot of remove, add, reboot...

asev commented 4 years ago

Finally I fixed it! ❄️ My solution was to change MAC address format from 12-34-56-78-AB-CD to 12:34:56:78:ab:cd.

savvasha commented 4 years ago

Hi Asev. So the correct format is "-" or ":"??

asev commented 4 years ago

For me it started to work with 12:34:56:78:ab:cd

savvasha commented 4 years ago

Thanks for sharing @asev ! I will try it as soon as possible and come back ;)

UPDATE: It is actually WORKING!!!! THANKS :)

m-alzahrani commented 4 years ago

Its working but I still have the same error keep happening

`Logger: homeassistant.helpers.entity Source: custom_components/gree/climate.py:220 First occurred: 3:14:39 PM (11 occurrences) Last logged: 5:50:12 PM

Update for climate.malak_ac fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 472, in async_device_update await self.hass.async_add_executor_job(self.update) File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/gree/climate.py", line 627, in update self.SyncState() File "/config/custom_components/gree/climate.py", line 410, in SyncState currentValues = self.GreeGetValues(optionsToFetch) File "/config/custom_components/gree/climate.py", line 241, in GreeGetValues return self.FetchResult(self.CIPHER, self._ip_addr, self._port, self._timeout, jsonPayloadToSend)['dat'] File "/config/custom_components/gree/climate.py", line 220, in FetchResult data, addr = clientSock.recvfrom(64000) socket.timeout: timed out ` I didnt include encryption in config

cej0t4 commented 4 years ago

Some problem... On Home Assistant I can see AC values, but can't change them.

climate.yaml

- platform: gree
  name: Gree9
  host: 192.168.1.11
  port: 7000
  mac: 'XX:XX:XX:XX:XX:XX'
  target_temp_step: 1

log

2020-07-27 20:22:44 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall climate.set_fan_mode (c:e4dfd9b5499546979d2424df913a62ba): entity_id=['climate.gree_hvac'], fan_mode=medium>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1281, in catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1300, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 208, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 454, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 595, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 485, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 422, in async_set_fan_mode
    await self.hass.async_add_executor_job(self.set_fan_mode, fan_mode)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/gree/climate.py", line 745, in set_fan_mode
    self.SyncState({'WdSpd': str(self._fan_modes.index(fan)), 'Tur': 0, 'Quiet': 0})
  File "/config/custom_components/gree/climate.py", line 426, in SyncState
    self.SendStateToAc(self._timeout)
  File "/config/custom_components/gree/climate.py", line 266, in SendStateToAc
    data, addr = clientSock.recvfrom(64000)
socket.timeout: timed out

Mi WIFI GREE is ME31-00/C4 The APP Gree+ works perfectly

jodewee commented 2 years ago

Hi, may i ask how you fixed it? Do you want to share your yaml,code?