Open sloaiza86 opened 4 weeks ago
Hi, sorry but I didn't understand your request very well. Currently the integration has an option called "Force power on when setting HVAC mode" that, if activated by the configuration, sends the power on command before changing the HVAC mode.
In your case I didn't understand if the problem occurs when this option is active.
Thanks for taking the time to check it.
Sorry if I didn’t explain myself clearly. As home assistant does not have an “on” mode, I need to activate the “Force power on when setting HVAC mode” option to turn my AC on by setting ‘cool’ or ‘heat’. If I don’t activate such option, the AC receives only the mode setting but not the ON command. Until here, everything is ok and the feature works as intended (I suppose).
The problem is that when my AC is currently on, for example in ‘cool’ mode, if I press ‘heat’ to change the mode, the ON command (that it is the same as the off command) is sent, so instead of my AC changing mode, the AC is turned of, but if I deactivate the option “Force power on when setting HVAC mode” then my AC never turns on.
The request, if possible, is to add in a future version an additional option that IF the current state is OFF, then send do a force power on, but, if the AC is already ON (any state different than off), and a HVAC mode change is sent (for example, to change from ‘cool’ to ‘heat’), then the force power on commend is not send.
On Oct 24, 2024, at 7:00 PM, EnzoD86 @.***> wrote:
Hi, sorry but I didn't understand your request very well. Currently the integration has an option called "Force power on when setting HVAC mode" that, if activated by the configuration, sends the power on command before changing the HVAC mode.
In your case I didn't understand if the problem occurs when this option is active.
— Reply to this email directly, view it on GitHub https://github.com/EnzoD86/tuya-smart-ir-ac/issues/29#issuecomment-2436409555, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKFHKUTCCJHZ6BUZZHVUPGTZ5FUZNAVCNFSM6AAAAABQRKUQKOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMZWGQYDSNJVGU. You are receiving this because you authored the thread.
Now it's clearer. But it's strange that the power on command is the same as the power off command...
Home Assistant actually has an ON mode; to do this you have to call the service:
action: climate.turn_on
target:
entity_id: your_entity_id
So if it's like you say, if you call the same service twice, the air conditioning should turn on the first time and off the second time. Can you kindly do this test to be sure?
The change you are asking me to make is very simple to do. The reason why I did not put a control on sending the power on command only if the air conditioner is off is because the status of the air conditioner (on/off) that I have on Home Assistant (and on Smart Life) does not necessarily correspond to the real status of the device.
For example, if the air conditioner is turned on from its physical remote control on Home Assistant it will remain off and when it is turned on by Home Assistant with this control it will turn it off instead of turning it on. I don't know if I was clear.
This is because we are talking about controls via IR without having an actual feedback on the status of the air conditioner.
In any case, if you can, try to do the test I indicated and then we will understand how to proceed. Thanks.
Yes, it is strange but my bet is that it is related to the IR implementation as done by the manufacturer of the AC. I have 4 mini splits AC at home and only one has this issue. The other 3 have separated On and Off commands.
I tested sending the action you provided, an indeed the first time turns it on and the second time it turns it off.
I fully understand the feedback issue, and believe me, it’s a nightmare with this specific AC. In the other 3 ACs, the separate ON and OFF commands make synchronization between home assistant and the AC easy to reach, but with this AC I constantly get out of sync.
The current "Force power on when setting HVAC mode” works great for most ACs (3 in my case), that is the reason why I created the issue as a feature request for an additional option and not as a bug.
Thanks!
On Oct 24, 2024, at 8:34 PM, EnzoD86 @.***> wrote:
Now it's clearer. But it's strange that the power on command is the same as the power off command...
Home Assistant actually has an ON mode; to do this you have to call the service:
action: climate.turn_on target: entity_id: your_entity_id So if it's like you say, if you call the same service twice, the air conditioning should turn on the first time and off the second time. Can you kindly do this test to be sure?
The change you are asking me to make is very simple to do. The reason why I did not put a control on sending the power on command only if the air conditioner is off is because the status of the air conditioner (on/off) that I have on Home Assistant (and on Smart Life) does not necessarily correspond to the real status of the device.
For example, if the air conditioner is turned on from its physical remote control on Home Assistant it will remain off and when it is turned on by Home Assistant with this control it will turn it off instead of turning it on. I don't know if I was clear.
This is because we are talking about controls via IR without having an actual feedback on the status of the air conditioner.
In any case, if you can, try to do the test I indicated and then we will understand how to proceed. Thanks.
— Reply to this email directly, view it on GitHub https://github.com/EnzoD86/tuya-smart-ir-ac/issues/29#issuecomment-2436516377, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKFHKURVF6D5BZRPQ2OWX4TZ5F7WXAVCNFSM6AAAAABQRKUQKOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMZWGUYTMMZXG4. You are receiving this because you authored the thread.
Perfect, thanks for the test; so it's exactly as you say... It uses the same command to turn on and off... absurd!
Now I'll think for a moment about what is the best way to do this implementation; quickly I can say that there are 2 ways:
The first one risks creating the problems I told you in the previous post... maybe the second way could be the best... I'm just afraid of creating too much confusion with all these compatibility flags!
I'll let you know!
Thanks!!! I agree with you that the second option is the best. Let me know if you need additional testing.
hi @sloaiza86, I released the version 2024.11.0-beta with the change we talked about in the past few days. You will notice that I have opted for an intermediate choice compared to what was said; the compatibility option "Force power on when setting HVAC mode" has now changed to a selection of three options which are: "never", "always" and "onlt if turned off".
You will also notice that when you select one of the three options (which in your case will be Only if turned off) and you go to save, reopening the configuration will seem that it has not been saved. It is just a visual bug that depends on the Home Assistant interface; i have already reported it on their repository and I am waiting for feedback. Until this problem is resolved, I will not be able to release the official version of the integration with this change.
In the meantime, I kindly ask you to do some tests, to see if this solution is the most appropriate... and if it works... ! Thanks
Hi @EnzoD86
It works like a charm! I did some testing and it responds as expected. I will start to use it continuously and will let you know if I get any extrange behavior.
Thanks!!!
Also, almost forgot to mention. It is working with the following device, not listed in your main documentation, so maybe you can add it.
First of all, I wanted to thank you for your support!
I'm glad it works as expected!
I'm surprised about the hardware you're using; in another issue I was told that the device wasn't updating the display based on the Home Assistant status and vice versa. Are you having this kind of problem too? Thanks again!
Until now, I was only using home assistant and the physical capacitive buttons on the IR hub. After some testing I can report the following:
I only use tuya app for initial configuration, so not an issue for me. Wondering if there is a timer to pull the status via API periodically that is causing the delay? (not a big issue honestly)
Let me know if you need some testing or log capture.
ah, great, so it works! and to think I wanted to list this device among the incompatible ones!!!
It's exactly as you said, there is an update interval that I set to 60 seconds and that I deliberately did not make configurable for two reasons; the first is to avoid that a too low value could create too much traffic to the tuya data centers, with the risk of a block from them (for the configured user) and the second is for the same reason as you, those who use HomeAssistant mainly use the Tuya or SmartLife app only for the first configuration of a device.
Obviously I had not considered devices like yours, where there is a physical interface, and a more immediate update can actually be useful.
If it were necessary, we can make it configurable but only at the integration level (so from the configuration.yaml in which there are also the other 3 settings); this is because when the integration updates the status of the air conditioners, it does so for all of them. I don't know if I was clear!
The behavior of the device remains a bit anomalous... I don't understand the behavior of the third point. If the API used by Home Assistant updates the display and the capacitive commands update Home Assistant, it should have been almost obvious that the Tuya app had to update both.... strange, very strange... I don't understand!!!
Thank you for testing, I will add this device to my compatible list!
Great! And indeed, the configurable timer will be helpful. I understand the possible issue with Tuya servers, so the yaml option is great.
Ok! I'll add a check anyway to avoid inserting delays that are too low, for example under 10 seconds. I will release a new beta as soon as I have something testable.
Hi @sloaiza86, I released another beta version in which I implemented the ability to configure the update interval with the tuya server. The interval is expressed in seconds and must be between 10 and 3600 seconds. If not specified the default interval is 60 seconds. Here is an example of yaml file configuration.
tuya_smart_ir_ac:
access_id: !secret tuya_access_id
access_secret: !secret tuya_access_secret
country: EU
update_interval: 60
Kindly let me know if you find any anomalies. Thanks!
I did some poking and found that this product use another Service API to update the display. It uses IoT Core
api.
But to get the instruction set, there are some settings required.
First, go to device tab of the tuya developer playform, then selected the IR device on the grid (not from the list), click the eye icon within the grid , make sure it is set to DP Instruction
, if not then click Change Instruction Mode
button to swap it.
After finish those, go to Service API debug page to retrieve the instruction set, and these are what I get.
{
"result": {
"category": "hwktwkq",
"functions": [
{
"code": "infared_switch",
"desc": "infared switch",
"name": "infared switch",
"type": "Boolean",
"values": "{}"
},
{
"code": "target_temp",
"desc": "target temp",
"name": "target temp",
"type": "Integer",
"values": "{\"unit\":\"℃\",\"min\":16,\"max\":30,\"scale\":0,\"step\":1}"
},
{
"code": "mode",
"desc": "mode",
"name": "mode",
"type": "Enum",
"values": "{\"range\":[\"cold\",\"warm\",\"auto\",\"air\",\"dehumidify\"]}"
},
{
"code": "fan_level",
"desc": "fan level",
"name": "fan level",
"type": "Enum",
"values": "{\"range\":[\"auto\",\"low\",\"middle\",\"high\"]}"
},
{
"code": "filter_reset",
"desc": "filter reset",
"name": "filter reset",
"type": "Boolean",
"values": "{}"
},
{
"code": "upper_temp",
"desc": "upper temp",
"name": "upper temp",
"type": "Integer",
"values": "{\"unit\":\"℃\",\"min\":16,\"max\":30,\"scale\":0,\"step\":1}"
},
{
"code": "lower_temp",
"desc": "lower temp",
"name": "lower temp",
"type": "Integer",
"values": "{\"unit\":\"℃\",\"min\":16,\"max\":30,\"scale\":0,\"step\":1}"
},
{
"code": "temp_unit_convert",
"desc": "temp unit convert",
"name": "temp unit convert",
"type": "Enum",
"values": "{\"range\":[\"c\",\"f\"]}"
},
{
"code": "work_type",
"desc": "work type",
"name": "work type",
"type": "Enum",
"values": "{\"range\":[\"scene_1\",\"scene_2\",\"scene_3\"]}"
},
{
"code": "status",
"desc": "status",
"name": "status",
"type": "Enum",
"values": "{\"range\":[\"done\",\"run\",\"idle\"]}"
},
{
"code": "internet_disc_switch",
"desc": "internet disc switch",
"name": "internet disc switch",
"type": "Boolean",
"values": "{}"
},
{
"code": "runtime_total_reset",
"desc": "runtime total reset",
"name": "runtime total reset",
"type": "Boolean",
"values": "{}"
},
{
"code": "ir_send",
"desc": "ir send",
"name": "ir send",
"type": "String",
"values": "{\"maxlen\":3072}"
}
]
},
"success": true,
"t": 1730997865008,
"tid": "8bfd71019d2711efa253a6f43842afdb"
}
I tried to do send command with code infared_switch
and set value to true
and the device screen does indicate turned on. However, I am still struggling on how to integrate it, not that familiar with python yet.
It's funny that I found another repo only did the exact opposite to the same device. It can only update the display, but the remote isn't able to send out IR signal. FYI: https://github.com/make-all/tuya-local/issues/478
hi @lukechen0129 , I was pretty sure that the device used an IOT core API, after that test we did with the Tuya OpenAPI. I don't know if the calls to the IOT core API have limitations, it would be important to find out.
I know the tuya local integration well; you can send commands to the device because it does it locally without going through the cloud (in fact it shouldn't update the data on the smart life app) but unfortunately I confirm that sending ir commands doesn't work.
While I was studying a system to be able to locally manage my IR sensors (which don't have touch controls on the screen), I managed to send a command through a python script that was able to turn on the air conditioner. I had extracted the command from the debug logs on the Tuya IOT Platform
A few months have passed, the code should be this:
import tinytuya
import json
d = tinytuya.Device('xxxxxxxxxxxxx', 'xx.xx.xx.xx', 'xxxxxxx', version=3.4)
data = d.status()
print('Device status: %r' % data)
command = {
"control": "send_ir",
"head": "010ed800000000000700100032004100860536002603c9",
"key1": "001000500@*%$0040885BE400A30000EB@^%$0040885BE4004200002A@^%$0098885BE400009C4C000A0000600600008301002E@&",
"type": 0,
"delay": 300,
}
# Sending the IR command:
payload = d.generate_payload(tinytuya.CONTROL, {"201": json.dumps(command)})
d.send(payload)
The problem is that I was not able to decode the command.. since there is a double encoding... the one used by tuya to encrypt the command that it sends to its device and then the IR encoding of the air conditioner remote control (obviously different for each device).
So to be able to manage all the combinations (on, off, hot, cold, fan, etc...) it was necessary to map all the commands one by one... I considered it a heresy.. and for this reason I did not go further. I hope it can help you.
Bye
Hi @sloaiza86, I released another beta version in which I implemented the ability to configure the update interval with the tuya server. The interval is expressed in seconds and must be between 10 and 3600 seconds. If not specified the default interval is 60 seconds. Here is an example of yaml file configuration.
tuya_smart_ir_ac: access_id: !secret tuya_access_id access_secret: !secret tuya_access_secret country: EU update_interval: 60
Kindly let me know if you find any anomalies. Thanks!
Thanks!! just installed it. Strangely, If have found the following behavior when operating the device buttons:
Temperature change: Updated ok in home assistant Mode change from off to heat/cool Updated ok in home assistant Mode change between heat/cool: Updated ok in home assistant Mode change from heat/cool to off: Not updated in home assistant
This also happens in the previous beta version. Do you think that this is something related to the API with not apparent solution as discussed in the other topic?
hi @sloaiza86 , that's very strange! I would need the debug logs of the integration to try to better understand what's happening.
After you turn off the air conditioner from the device we need to understand what Home Assistant pulls down from the tuya server.
I kindly ask you to post the log if you can. Thanks
Hi @EnzoD86. I am attaching three logs:
Let me know if you need any extra info or logs.
Hi @sloaiza86, thanks for sending me the logs. I analyzed them and unfortunately I have to ask you to send me more accurate logs. This is because for both points 1. and 2. I only see the initial state of the air conditioner and not the subsequent one after you sent the command from the button on the IR hub.
Instead for point 3. I can see 3 changes of state:
This is what the integration receives from the Tuya server and confirms what you wrote. If you are sure that you have not sent a power off command, I think we cannot solve this scenario because it is not a bug in the integration. When this scenario occurs, how is the device seen on smart life/tuya appplication?
At this point I think that the second point (cool to off: ) also presents a similar problem, however if you send me other logs I will try to investigate. Thanks
Please help me Thanks Telegram: @david200316
Please help me Thanks Telegram: @david200316
hi, please open a new issue explaining what kind of problem you are having and attaching the logs if necessary. Thanks
Hi @EnzoD86 Sorry it took me so long. I was having issues with everything related to tuya cloud (both official integration and yours) and just managed to solve the issue.... Just FYI if it ever happens to you, my official tuya integration and yours suddenly stopped working. The solution: deactivate IPv6 in home assistant. Very strange.
Now, about the topic, I captured the logs again:
Let me know if this time you can see the required info. heat to cool.log Cool to off.log Off to cool.log
For a future update, is it possible to add an additional Compatibility option Called Force power on when setting hvac mode from off mode? In my case, I need to force power on when setting the mode, otherwise the AC won't turn on, but, If I activate such option and change the mode from cool to heat, the power on/off sigal is sent, and my AC is turned off instead of changing mode.