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
302 stars 103 forks source link

AttributeError: 'NoneType' object has no attribute 'state' #191

Closed RobHofmann closed 1 month ago

RobHofmann commented 1 month ago

Describe the bug Bug with auto_light & auto_xfan input booleans

To Reproduce Steps to reproduce the behavior:

  1. Add config
  2. Restart home assistant
  3. See that AC's (i have 3 configurations) are Unavailable.
  4. Check logs

Configuration

  - platform: gree
    name: Zolderkamer AC
    host: <redacted>
    port: 7000
    mac: '<redacted>'
    timeout: 60
    target_temp_step: 1
    #lights: input_boolean.zolderkamer_ac_lights
    xfan: input_boolean.zolderkamer_ac_xfan
    health: input_boolean.zolderkamer_ac_health
    sleep: input_boolean.zolderkamer_ac_sleep
    powersave: input_boolean.zolderkamer_ac_powersave
    auto_xfan: input_boolean.zolderkamer_ac_auto_xfan
    auto_light: input_boolean.zolderkamer_ac_auto_lights
    #max_online_attempts: 15
    disable_available_check: true

  - platform: gree
    name: Slaapkamer AC
    host: <redacted>
    port: 7000
    mac: '<redacted>'
    timeout: 60
    target_temp_step: 1
    #lights: input_boolean.slaapkamer_ac_lights
    xfan: input_boolean.slaapkamer_ac_xfan
    health: input_boolean.slaapkamer_ac_health
    sleep: input_boolean.slaapkamer_ac_sleep
    powersave: input_boolean.slaapkamer_ac_powersave
    auto_xfan: input_boolean.slaapkamer_ac_auto_xfan
    #max_online_attempts: 15
    disable_available_check: true

  - platform: gree
    name: Slaapkamer <redacted> AC
    host: <redacted>
    port: 7000
    mac: '<redacted>'
    timeout: 60
    target_temp_step: 1
    #lights: input_boolean.slaapkamer_<redacted>_ac_lights
    xfan: input_boolean.slaapkamer_<redacted>_ac_xfan
    health: input_boolean.slaapkamer_<redacted>_ac_health
    sleep: input_boolean.slaapkamer_<redacted>_ac_sleep
    powersave: input_boolean.slaapkamer_<redacted>_ac_powersave
    auto_xfan: input_boolean.slaapkamer_<redacted>_ac_auto_xfan
    #max_online_attempts: 15
    disable_available_check: true

Expected behavior HVAC will get added as normally.

Platform:

Logs

2024-07-13 23:06:11.004 INFO (MainThread) [custom_components.gree.climate] Setting up Gree climate platform
2024-07-13 23:06:11.004 INFO (MainThread) [custom_components.gree.climate] Adding Gree climate device to hass
2024-07-13 23:06:11.004 INFO (MainThread) [custom_components.gree.climate] Initialize the GREE climate device
2024-07-13 23:06:11.004 INFO (MainThread) [custom_components.gree.climate] Setting up xfan entity: input_boolean.zolderkamer_ac_xfan
2024-07-13 23:06:11.004 INFO (MainThread) [custom_components.gree.climate] Setting up health entity: input_boolean.zolderkamer_ac_health
2024-07-13 23:06:11.004 INFO (MainThread) [custom_components.gree.climate] Setting up powersave entity: input_boolean.zolderkamer_ac_powersave
2024-07-13 23:06:11.004 INFO (MainThread) [custom_components.gree.climate] Setting up sleep entity: input_boolean.zolderkamer_ac_sleep
2024-07-13 23:06:11.004 INFO (MainThread) [custom_components.gree.climate] Setting up auto light entity: input_boolean.zolderkamer_ac_auto_lights
2024-07-13 23:06:11.004 ERROR (MainThread) [homeassistant.components.climate] Error while setting up gree platform for climate
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 364, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/gree/climate.py", line 165, 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, air_entity_id, target_temp_entity_id, anti_direct_blow_entity_id, hvac_modes, fan_modes, swing_modes, preset_modes, auto_xfan_entity_id, auto_light_entity_id, horizontal_swing, light_sensor_entity_id, encryption_version, disable_available_check, max_online_attempts, encryption_key, uid)
  File "/config/custom_components/gree/climate.py", line 305, in __init__
    if self.hass.states.get(auto_light_entity_id).state is STATE_ON:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-13 23:06:11.007 INFO (MainThread) [custom_components.gree.climate] Setting up Gree climate platform
2024-07-13 23:06:11.007 INFO (MainThread) [custom_components.gree.climate] Adding Gree climate device to hass
2024-07-13 23:06:11.007 INFO (MainThread) [custom_components.gree.climate] Initialize the GREE climate device
2024-07-13 23:06:11.008 INFO (MainThread) [custom_components.gree.climate] Setting up xfan entity: input_boolean.slaapkamer_ac_xfan
2024-07-13 23:06:11.008 INFO (MainThread) [custom_components.gree.climate] Setting up health entity: input_boolean.slaapkamer_ac_health
2024-07-13 23:06:11.008 INFO (MainThread) [custom_components.gree.climate] Setting up powersave entity: input_boolean.slaapkamer_ac_powersave
2024-07-13 23:06:11.008 INFO (MainThread) [custom_components.gree.climate] Setting up sleep entity: input_boolean.slaapkamer_ac_sleep
2024-07-13 23:06:11.008 INFO (MainThread) [custom_components.gree.climate] Setting up auto xfan entity: input_boolean.slaapkamer_ac_auto_xfan
2024-07-13 23:06:11.008 ERROR (MainThread) [homeassistant.components.climate] Error while setting up gree platform for climate
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 364, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/gree/climate.py", line 165, 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, air_entity_id, target_temp_entity_id, anti_direct_blow_entity_id, hvac_modes, fan_modes, swing_modes, preset_modes, auto_xfan_entity_id, auto_light_entity_id, horizontal_swing, light_sensor_entity_id, encryption_version, disable_available_check, max_online_attempts, encryption_key, uid)
  File "/config/custom_components/gree/climate.py", line 315, in __init__
    if self.hass.states.get(auto_xfan_entity_id).state is STATE_ON:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-13 23:06:11.009 INFO (MainThread) [custom_components.gree.climate] Setting up Gree climate platform
2024-07-13 23:06:11.009 INFO (MainThread) [custom_components.gree.climate] Adding Gree climate device to hass
2024-07-13 23:06:11.009 INFO (MainThread) [custom_components.gree.climate] Initialize the GREE climate device
2024-07-13 23:06:11.009 INFO (MainThread) [custom_components.gree.climate] Setting up xfan entity: input_boolean.slaapkamer_<redacted>_ac_xfan
2024-07-13 23:06:11.009 INFO (MainThread) [custom_components.gree.climate] Setting up health entity: input_boolean.slaapkamer_<redacted>_ac_health
2024-07-13 23:06:11.009 INFO (MainThread) [custom_components.gree.climate] Setting up powersave entity: input_boolean.slaapkamer_<redacted>_ac_powersave
2024-07-13 23:06:11.009 INFO (MainThread) [custom_components.gree.climate] Setting up sleep entity: input_boolean.slaapkamer_<redacted>_ac_sleep
2024-07-13 23:06:11.009 INFO (MainThread) [custom_components.gree.climate] Setting up auto xfan entity: input_boolean.slaapkamer_<redacted>_ac_auto_xfan
2024-07-13 23:06:11.009 ERROR (MainThread) [homeassistant.components.climate] Error while setting up gree platform for climate
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 364, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/gree/climate.py", line 165, 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, air_entity_id, target_temp_entity_id, anti_direct_blow_entity_id, hvac_modes, fan_modes, swing_modes, preset_modes, auto_xfan_entity_id, auto_light_entity_id, horizontal_swing, light_sensor_entity_id, encryption_version, disable_available_check, max_online_attempts, encryption_key, uid)
  File "/config/custom_components/gree/climate.py", line 315, in __init__
    if self.hass.states.get(auto_xfan_entity_id).state is STATE_ON:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-13 23:06:13.235 ERROR (SyncWorker_14) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 781, in _async_xfan_entity_state_changed
    _LOGGER.info('xfan_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                  ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-13 23:06:13.235 ERROR (SyncWorker_14) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 809, in _async_health_entity_state_changed
    _LOGGER.info('health_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                    ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-13 23:06:13.235 ERROR (SyncWorker_14) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 862, in _async_sleep_entity_state_changed
    _LOGGER.info('sleep_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                   ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-13 23:06:13.241 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 833, in _async_powersave_entity_state_changed
    _LOGGER.info('powersave_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                       ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-13 23:06:13.241 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 781, in _async_xfan_entity_state_changed
    _LOGGER.info('xfan_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                  ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-13 23:06:13.241 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 809, in _async_health_entity_state_changed
    _LOGGER.info('health_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                    ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-13 23:06:13.242 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 862, in _async_sleep_entity_state_changed
    _LOGGER.info('sleep_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                   ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-13 23:06:13.242 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 833, in _async_powersave_entity_state_changed
    _LOGGER.info('powersave_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                       ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-13 23:06:13.247 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 781, in _async_xfan_entity_state_changed
    _LOGGER.info('xfan_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                  ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-13 23:06:13.248 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 809, in _async_health_entity_state_changed
    _LOGGER.info('health_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                    ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-13 23:06:13.248 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 862, in _async_sleep_entity_state_changed
    _LOGGER.info('sleep_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                   ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-13 23:06:13.248 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 833, in _async_powersave_entity_state_changed
    _LOGGER.info('powersave_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                       ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
RobHofmann commented 1 month ago

Included @toughvj

RobHofmann commented 1 month ago

I think this happened when upgrading my HASS version to latest. I guess it lost old state and then null checks seem to fail. climate.txt

With this file I no longer have errors in the logs, however one of the AC's is still Unavailable.

RobHofmann commented 1 month ago

Another addition. After a while the last AC is also Available again. So it seems these null checks are needed. let me know your thoughts @toughvj.

toughvj commented 1 month ago

I'll take a look at it tomorrow. This looks like a state machine problem to me. looking at your log, the problem affects every input_boolean. Did the problem occur before the HASS update?

toughvj commented 1 month ago

Ok, check if auto_xfan and auto_light input_booleans really exists in your system. It looks like they are missing and that's why they are Nonetype.

RobHofmann commented 1 month ago
input_boolean:
  zolderkamer_ac_lights:
    name: Lights

  zolderkamer_ac_xfan:
    name: XFan

  zolderkamer_ac_auto_lights:
    name: Auto Lights

  zolderkamer_ac_auto_xfan:
    name: Auto XFan

  zolderkamer_ac_health:
    name: Health

  zolderkamer_ac_sleep:
    name: Sleep

  zolderkamer_ac_powersave:
    name: Powersave

  slaapkamer_ac_lights:
    name: Lights

  slaapkamer_ac_xfan:
    name: XFan

  slaapkamer_ac_auto_xfan:
    name: Auto XFan

  slaapkamer_ac_health:
    name: Health

  slaapkamer_ac_sleep:
    name: Sleep

  slaapkamer_ac_powersave:
    name: Powersave

  slaapkamer_<redacted>_ac_lights:
    name: Lights

  slaapkamer_<redacted>_ac_xfan:
    name: XFan

  slaapkamer_<redacted>_ac_auto_xfan:
    name: Auto XFan

  slaapkamer_<redacted>_ac_health:
    name: Health

  slaapkamer_<redacted>_ac_sleep:
    name: Sleep

  slaapkamer_<redacted>_ac_powersave:
    name: Powersave

These are all AC related input booleans. The input booleans exist whenever I look in HASS, but I assume the script gets initialized before the booleans are available. This seems to happen specifically after an upgrade (I assume the state is wiped at that point?).

Right now the AC's work again, and im unsure how to reproduce this. So my suggestion is: lets do some null checks (look at my version, i added several null checks which seems to have done the trick. I was getting several more errors after fixing the first batch).

toughvj commented 1 month ago

HA never ceases to surprise me. If we do it the way you suggested, in my opinion, if the input_booleans have no state when the integration starts, they will become useless. We need a loop that will check whether a specific entity id has already appeared in the state machine. Take a look at the attached file.

pay attention to the UpdateInputBooleans function, which executes in a loop in the update function.

climate.txt

RobHofmann commented 1 month ago

With your version i'm still getting this (without any upgrades of HASS versions or w/e):

2024-07-16 17:36:54.194 ERROR (Dummy-2) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 792, in _async_xfan_entity_state_changed
    _LOGGER.info('xfan_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                  ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-16 17:36:54.202 ERROR (SyncWorker_0) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 820, in _async_health_entity_state_changed
    _LOGGER.info('health_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                    ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-16 17:36:54.206 ERROR (SyncWorker_0) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 873, in _async_sleep_entity_state_changed
    _LOGGER.info('sleep_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                   ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-16 17:36:54.206 ERROR (SyncWorker_0) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 844, in _async_powersave_entity_state_changed
    _LOGGER.info('powersave_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                       ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-16 17:36:54.214 ERROR (SyncWorker_0) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 792, in _async_xfan_entity_state_changed
    _LOGGER.info('xfan_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                  ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-16 17:36:54.214 ERROR (SyncWorker_0) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 820, in _async_health_entity_state_changed
    _LOGGER.info('health_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                    ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-16 17:36:54.220 ERROR (SyncWorker_0) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 873, in _async_sleep_entity_state_changed
    _LOGGER.info('sleep_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                   ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-16 17:36:54.220 ERROR (SyncWorker_0) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 844, in _async_powersave_entity_state_changed
    _LOGGER.info('powersave_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                       ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-16 17:36:54.221 ERROR (SyncWorker_0) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 792, in _async_xfan_entity_state_changed
    _LOGGER.info('xfan_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                  ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-16 17:36:54.233 ERROR (SyncWorker_5) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 820, in _async_health_entity_state_changed
    _LOGGER.info('health_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                    ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-16 17:36:54.234 ERROR (SyncWorker_5) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 873, in _async_sleep_entity_state_changed
    _LOGGER.info('sleep_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                   ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-16 17:36:54.234 ERROR (SyncWorker_5) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 844, in _async_powersave_entity_state_changed
    _LOGGER.info('powersave_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                       ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-16 17:36:54.877 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree/climate.py", line 1004, in _async_auto_light_entity_state_changed
    _LOGGER.info('auto_light_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                        ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-16 17:36:54.913 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree/climate.py", line 1032, in _async_auto_xfan_entity_state_changed
    _LOGGER.info('auto_xfan_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                       ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-16 17:36:54.929 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree/climate.py", line 1032, in _async_auto_xfan_entity_state_changed
    _LOGGER.info('auto_xfan_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                       ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-16 17:36:54.930 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gree/climate.py", line 1032, in _async_auto_xfan_entity_state_changed
    _LOGGER.info('auto_xfan_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
toughvj commented 1 month ago

strange, because I didn't make any changes in the input booleans event handling. it seems that after the HA update, input booleans are loaded after the integration is loaded

RobHofmann commented 1 month ago

No I remember also seeing this with the version I modified (thats also why in my version i check all the states on None).

Also with your version shared in this thread there seems to be a big delay in booting (it gets stuck for 30ish seconds).

I'm trying to test this on a separate test environment atm.

RobHofmann commented 1 month ago

yeah i'm still getting the errors just shared by me. However I can confirm that after an upgrade the AC's are no longer available with your version shared in this thread.

Whenever I downgrade HASS & also use the 2.14 version, it will give me an error after upgradeing HASS again. So you did fix something with this version :).

toughvj commented 1 month ago

Ok, and how about that: take clean 2.14 version but set "dependencies": ["input_boolean"] in manifest.json and restart.

RobHofmann commented 1 month ago

Unavailable again:

2024-07-17 01:22:03.901 ERROR (MainThread) [homeassistant.components.climate] Error while setting up gree platform for climate
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 364, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/gree/climate.py", line 165, 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, air_entity_id, target_temp_entity_id, anti_direct_blow_entity_id, hvac_modes, fan_modes, swing_modes, preset_modes, auto_xfan_entity_id, auto_light_entity_id, horizontal_swing, light_sensor_entity_id, encryption_version, disable_available_check, max_online_attempts, encryption_key, uid)
  File "/config/custom_components/gree/climate.py", line 305, in __init__
    if self.hass.states.get(auto_light_entity_id).state is STATE_ON:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-17 01:22:03.902 ERROR (MainThread) [homeassistant.components.climate] Error while setting up gree platform for climate
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 364, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/gree/climate.py", line 165, 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, air_entity_id, target_temp_entity_id, anti_direct_blow_entity_id, hvac_modes, fan_modes, swing_modes, preset_modes, auto_xfan_entity_id, auto_light_entity_id, horizontal_swing, light_sensor_entity_id, encryption_version, disable_available_check, max_online_attempts, encryption_key, uid)
  File "/config/custom_components/gree/climate.py", line 315, in __init__
    if self.hass.states.get(auto_xfan_entity_id).state is STATE_ON:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-17 01:22:03.904 ERROR (MainThread) [homeassistant.components.climate] Error while setting up gree platform for climate
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 364, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/gree/climate.py", line 165, 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, air_entity_id, target_temp_entity_id, anti_direct_blow_entity_id, hvac_modes, fan_modes, swing_modes, preset_modes, auto_xfan_entity_id, auto_light_entity_id, horizontal_swing, light_sensor_entity_id, encryption_version, disable_available_check, max_online_attempts, encryption_key, uid)
  File "/config/custom_components/gree/climate.py", line 315, in __init__
    if self.hass.states.get(auto_xfan_entity_id).state is STATE_ON:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-17 01:22:04.813 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 781, in _async_xfan_entity_state_changed
    _LOGGER.info('xfan_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                  ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-17 01:22:04.816 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 809, in _async_health_entity_state_changed
    _LOGGER.info('health_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                    ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-17 01:22:04.817 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 862, in _async_sleep_entity_state_changed
    _LOGGER.info('sleep_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                   ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-17 01:22:04.817 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 833, in _async_powersave_entity_state_changed
    _LOGGER.info('powersave_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                       ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-17 01:22:04.817 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 781, in _async_xfan_entity_state_changed
    _LOGGER.info('xfan_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                  ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-17 01:22:04.818 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 809, in _async_health_entity_state_changed
    _LOGGER.info('health_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                    ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-17 01:22:04.818 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 862, in _async_sleep_entity_state_changed
    _LOGGER.info('sleep_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                   ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-17 01:22:04.818 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 833, in _async_powersave_entity_state_changed
    _LOGGER.info('powersave_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                       ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-17 01:22:04.819 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 781, in _async_xfan_entity_state_changed
    _LOGGER.info('xfan_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                  ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-17 01:22:04.819 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 809, in _async_health_entity_state_changed
    _LOGGER.info('health_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                    ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-17 01:22:04.819 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 862, in _async_sleep_entity_state_changed
    _LOGGER.info('sleep_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                   ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
2024-07-17 01:22:04.819 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/gree/climate.py", line 833, in _async_powersave_entity_state_changed
    _LOGGER.info('powersave_entity state changed | ' + str(entity_id) + ' from ' + str(old_state.state) + ' to ' + str(new_state.state))
                                                                                       ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'
krismarc commented 1 month ago

Hi guys,

I've manually added those 2 helpers and my AC became available again. I also had to create target_temp manually in order to set specific value directly.

None of those options (light/target temp) became available/selectable in UI cards. Should they?

What about built-in temp sensor? In the changelog you have mentioned it's going to be supported. In the official mobile app there's a button to get actual temp.

krismarc commented 1 month ago

I just gave it a try with light input_boolean. I can control lights after creating it manually. This is very first time I had to create inputs manually for the inegration, so I assume something's wrong?

RobHofmann commented 1 month ago

Fixed in 2.14.2.