Hagakurje / ESPHome_Gree_AC

24 stars 10 forks source link

Send pin number in gree_ir. #10

Open te0203 opened 1 year ago

te0203 commented 1 year ago

Good afternoon. I am using your code. It works, but there is a question. Let's say the air conditioner is not one, but several, and that for each you need to write a separate file gree_ir.h with your own number Gpio? How to pass the pin number to this file, for example, a global variable.

# in ir_bedroom.yaml
substitutions:
    transmitter_pin: "14"

globals:
- id: transmitter_pin
  type: uint16_t
  restore_value: no
  initial_value: $transmitter_pin

# in gree_ir.h
const uint16_t kIrLed = id(transmitter_pin);

Something like this, but it doesn't work for me. Help me please. Thank you.

Hagakurje commented 1 year ago

Hi. File 'gree_ir.h' is not for conditioner. This file is for your IR remote device. Your IR remote has only one IR transmitter, so only one transmitter pin. You can not control two ore more AC separately. IR remote send IR command, and all AC near this IR remote will receive this command.

te0203 commented 1 year ago

Yes, I understand, but on each air conditioner I have my own device with a IR remote control and there are 5 of them. 5 separate ESP12E. The range of the remote control is 1.3 meters. And they are in different rooms. I understand you can write five files for each device, but this is not logical.

Hagakurje commented 1 year ago

You can try to add new method like 'set_temp_sensor' for set pin. And call it like this: bedroom_ac->set_transmitter_pin(10);

te0203 commented 1 year ago

If I could I would write, but I don't understand anything in C++. Fine. Thanks for your reply, sorry for wasting your time. I will learn C++. :))

te0203 commented 1 year ago

Good afternoon again. I wrote something here, could you check it. Everything seems to be working for me. From the remote control reads and remembers. Although everything is bad with the transfer of the pin number. within the class it accepts but not in the global scope. But it’s already kind of late to pass it inside the class. Maybe at least some kind of idea. Thank you.