EnzoD86 / tuya-smart-ir-ac

Control Tuya IR based air conditioners from Home Assistant
MIT License
15 stars 2 forks source link

Power-on command does not work when the air conditioner is off #17

Closed minu-j closed 1 week ago

minu-j commented 2 weeks ago

Problems

When sending a command to turn on the air conditioner, an issue occurs. The power-on command does not successfully execute when the unit is off, and the air conditioner does not turn on. However, commands to change the mode and adjust the temperature work correctly when the unit is on.

Logs

Power off when the air conditioner is on(successful)

2024-08-30 02:47:32.685 INFO (MainThread) [custom_components.tuya_smart_ir_ac] climate.air_conditioner setting hvac mode to off
2024-08-30 02:47:32.686 DEBUG (MainThread) [custom_components.tuya_smart_ir_ac] API send_command url: /v2.0/infrareds/ebd5bd0526540a550ecmkn/air-conditioners/eb34564cb4780179b9pl6m/command
2024-08-30 02:47:32.687 DEBUG (MainThread) [custom_components.tuya_smart_ir_ac] API send_command request: {'code': 'power', 'value': '0'}
2024-08-30 02:47:33.013 DEBUG (MainThread) [custom_components.tuya_smart_ir_ac] API send_command response: {'result': True, 'success': True, 't': 1724953652951, 'tid': 'c4c5b5f6662e11ef95b0e2c325534a77'}

Power on when the air conditioner is off (fail)

2024-08-30 02:47:34.824 INFO (MainThread) [custom_components.tuya_smart_ir_ac] climate.air_conditioner setting hvac mode to cool
2024-08-30 02:47:34.824 DEBUG (MainThread) [custom_components.tuya_smart_ir_ac] API send_multiple_command url: /v2.0/infrareds/ebd5bd0526540a550ecmkn/air-conditioners/eb34564cb4780179b9pl6m/scenes/command
2024-08-30 02:47:34.824 DEBUG (MainThread) [custom_components.tuya_smart_ir_ac] API send_multiple_command request: {'power': '1', 'mode': '0', 'temp': '27.0', 'wind': '0'}
2024-08-30 02:47:35.076 DEBUG (MainThread) [custom_components.tuya_smart_ir_ac] API send_multiple_command response: {'result': True, 'success': True, 't': 1724953655014, 'tid': 'c60beef2662e11efbcbd7aea62a19b8a'}

Mode change when the air conditioner is on (successful)

2024-08-30 02:51:54.569 INFO (MainThread) [custom_components.tuya_smart_ir_ac] climate.air_conditioner setting hvac mode to cool
2024-08-30 02:51:54.570 DEBUG (MainThread) [custom_components.tuya_smart_ir_ac] API send_multiple_command url: /v2.0/infrareds/ebd5bd0526540a550ecmkn/air-conditioners/eb34564cb4780179b9pl6m/scenes/command
2024-08-30 02:51:54.570 DEBUG (MainThread) [custom_components.tuya_smart_ir_ac] API send_multiple_command request: {'power': '1', 'mode': '0', 'temp': '27.0', 'wind': '0'}
2024-08-30 02:51:54.961 DEBUG (MainThread) [custom_components.tuya_smart_ir_ac] API send_multiple_command response: {'result': True, 'success': True, 't': 1724953914899, 'tid': '60de3fb3662f11ef95b0e2c325534a77'}

Thanks!

minu-j commented 2 weeks ago
work

or other libraries used by Home Bridge, these commands were sent when the air conditioner was turned off. This worked well. As you can see, I sent the on command twice.

not work

But this library only sends on command once, and my air conditioner doesn't turn on.

EnzoD86 commented 2 weeks ago

Hi @minu-j , the problem you describe is very strange. It doesn't seem like an integration issue and I don't know if we can fix it. In fact, from the logs you sent me I don't see any errors, the integration correctly sends the power on command to the cloud and the cloud responds successfully... but your air conditioner doesn't receive it. You told me that with another library the power on command is sent twice... but this is a strange way of working... not standard compared to other air conditioners. Do you have the source of this library for me to investigate?

In any case I would like to understand the problem better. When you turn on the air conditioner from Smart Life does it work correctly?

Try turning on the air conditioner using this command from the developer tools, in the action tab:

action: climate.turn_on
target:
  entity_id: your_entity_id

Does anything change? Thank you

minu-j commented 2 weeks ago
스크린샷 2024-08-31 오전 12 07 10

It works!

I think it's because the action of turning on the air conditioner on the air conditioner card and homekit doesn't work. All I can do with the card is switch from off to cooling. There is no action to turn on the power. For now, I think I can turn on the air conditioner by turning that action into a switch.

minu-j commented 2 weeks ago

The plug-in of the home bridge I used had a separate option to turn on the air conditioner in the homekit. I'll leave a link. I don't know if it helps.

https://github.com/prasad-edlabadka/homebridge-tuya-ir

EnzoD86 commented 2 weeks ago

Perfect! Probably your air conditioner does not accept the sending of multiple commands, or probably this only applies to power on/off.

It's normal that you don't have any buttons on the card to turn it on, because Home Assistant turns on the air conditioners by directly setting the HVAC mode (cool, heat, dry, etc...); the power on is sent together with this command.

Instead, for example, using Google Assistant (connected to Home Assistant) I noticed that the power on is performed first and then the hvac mode is set.

I've seen the plugin of the home bridge, and it also only handles sending single commands

This integration has been optimized to send as few commands as possible to the air conditioner and therefore when an HVAC mode is set, it sends a single command that contains the power on, HAVC mode, fan mode and temperature.

A possible fix could be to add an option which, if activated, changes the mode of sending commands from multiple to single. However, at the moment I have not received any other reports of this type, so this type of change would be a low priority.

Anyway, thank you for your report!

minu-j commented 2 weeks ago

Ok, thanks!

Jozefik commented 2 weeks ago

Hi, I'm having the same issue. I need to turn on climate either by service or manualy and then it will work.

minu-j commented 2 weeks ago

@Jozefik

Hi!, I solved it by adding a simple automation.

automation: 
  ...
  - alias: Turn on AC when state changes from 'off'
    trigger:
      platform: state
      entity_id: climate.airconditioner
      from: 'off'
    action:
      - service: climate.turn_on
        target:
          entity_id: climate.airconditioner

And I also added one switch to check on/off.

switch:
  - platform: template
    switches:
      ...
      virtual_ac_switch:
        value_template: "{{ not is_state('climate.airconditioner', 'off') }}"
        turn_on:
          - service: climate.turn_on
            target:
              entity_id: climate.airconditioner
        turn_off:
          - service: climate.turn_off
            target:
              entity_id: climate.airconditioner

Thank you for presenting the same issue. Good luck!

Jozefik commented 2 weeks ago

@minu-j

Hi,

That's clever idea. Thank you for a suggestion. I will try it.

EnzoD86 commented 1 week ago

hi @minu-j , I'm reopening this issues because more people are having the same problem. I would need more information; when the air conditioner is turned on by setting the HVAC mode you said that the air conditioner does not turn on; but if you check from the SmartLife or Tuya application, does the air conditioner appear to be on? I need this information to try to create a fix that solves the problem. Thanks

EnzoD86 commented 1 week ago

hi @minu-j , @Jozefik, can you give me this information? Otherwise I can't solve this problem. Thank you

hi @minu-j , I'm reopening this issues because more people are having the same problem. I would need more information; when the air conditioner is turned on by setting the HVAC mode you said that the air conditioner does not turn on; but if you check from the SmartLife or Tuya application, does the air conditioner appear to be on? I need this information to try to create a fix that solves the problem. Thanks

minu-j commented 1 week ago

Hi @EnzoD86, sorry for the late comments. When I changed the HVAC mode, I checked the SmartLife app and it looks like the air conditioner is on. To be precise, If you press the power button on me, I hear the beep sound from the air conditioner when I receive the IR signal twice. I guess these two beeps are the signals to turn on the power and set the HVAC mode, respectively. However, just changing HVAC mode through this plug-in doesn't make any beep. It looks like it doesn't even get a signal to change HVAC before it's turned on. Of course, as I said before, SmartLife shows as if the air conditioner is on. And the actual air conditioner is not on, but when HVAC is changed to OFF, the beep code sounds normal once. I guess they recognize the power-off signal well. I hope my explanation helps. What's sent to Tuya cloud is consistent with what's in the top comment. Thank you!

EnzoD86 commented 1 week ago

@minu-j you were very clear, thank you! I try to find a solution and release a beta version with the possible solution that will be tested.

minu-j commented 1 week ago

Thanks!

EnzoD86 commented 1 week ago

hi @minu-j , @Jozefik, I released version 2024.9.0-beta with fix. It is important to activate the "Force power on when setting hvac mode" option in the air conditioner configuration.

image

Can you tell me if this solves your problem? Thank you

minu-j commented 1 week ago

Hi @EnzoD86, thank you for resolving the issue so quickly.

I also have a suggestion that I’d like to share. Please consider it as a light reference.

  1. Wind Speed Adjustment in Apple HomeKit

The current wind speed control in Apple HomeKit is a bit confusing. The gauge increments at 0%, 33%, 67%, and 100%, making it unclear which setting corresponds to “Automatic.” Additionally, when adjusting the wind speed slider, the system sends multiple signals, causing repetitive beeping sounds. Is there a way to improve this experience?

  1. Enhancing IR Remote Control Reliability

Since IR remotes are one-way, it’s hard to be sure whether the air conditioner is actually on or off. I know some people use electricity usage monitoring or sensors attached to the air conditioner blades to check its status. It would be great if we could link the on/off status to the sensor data. For example, the system could wait for confirmation from the sensor before updating the on/off state. This would also ensure that even when the physical remote control is used, the system’s state remains accurate. Just a suggestion to enhance reliability.

EnzoD86 commented 1 week ago

Hi @minu-j , I'm glad the problem has been resolved. I will release the official version soon. As for your suggestions:

  1. unfortunately the problem is on Apple HomeKit. The integration identifies the fan speed using the standard names provided by home assistant, so I can't do anything unfortunately.

  2. this point is interesting, but the integration is only a bridge between Home Assistant and Tuya. It doesn't have much logic. To be able to develop something like this I would have to have hardware with which to do this type of testing.

Thank you for your suggestions, I will keep them in mind.