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
318 stars 106 forks source link

Expand the auto light feature #166

Open red3 opened 6 months ago

red3 commented 6 months ago

My ac has the built-in auto light feature, which automatically turn the panel light on or off based on the light Illuminance environment.

Can we expand the current auto light feature to support the built-in one?

Additionally, the command of the built-in auto light feature is LigSen, and it’s value would be 0 means on and 1 means off (quite weird it uses 0 to represent on state and I double checked)

toughvj commented 6 months ago

challenge accepted

red3 commented 6 months ago

hey @toughvj , just add some details here: I've started looking into the javascript files within the Gree+ app and found a few methods might helpful, comments are added by me by analyzing the contexts, so they can be inaccurate):

setLig:function(t) {
    var e=0,n=0;
    switch(t.value){
      case 0:
        e=0,n=1;break; // off
      case 1:
        e=1,n=1;break; // on
      case 2:
        e=1,n=0;break; // auto
      default:break
    }
    this.setState(["ableSend",!0]),
    this.sendData({Lig:e,LigSen:n})
}

LigStatus:function(){
    return console.log("LigStatus=======",[0,0,2,1][2*this.Lig+this.LigSen]),
    [0,0,2,1][2*this.Lig+this.LigSen]
    // 3 for on;
    // 2 for off;
    // 1 for auto
}

seed like we need an input_selector to represent the light status or maybe just another input_bool to represent built-in auto light on/off

toughvj commented 5 months ago

We should replace light input boolean and auto_light with input_selctor with options:

I need some time to take a look at this

toughvj commented 5 months ago

@red please try attached file. To enable light sensor add light_sensor: to config.yaml with input_boolean entity id. Please let me know if it works. climate.txt

red3 commented 5 months ago

Thanks for your work, I will try this later this week.

red3 commented 5 months ago

@toughvj I tried and it did not turn the inner light sensor on, maybe we should try to use command Lig:1,LigSen:0 like I previous said to let it work. Another thinking: can we turn off both the lights and the light sensor when the ac is turned off, cause if the light sensor remains on when the ac is off, and it is daytime, the lights will turn on automaticly, which can be annoying.

toughvj commented 5 months ago

@red3 I need log from HA and configuration.yaml to see what is wrong.

red3 commented 5 months ago

I didn't turn on logs on my previous test, I'm currently away from home and I will collect the logs next time. From what I observed on the HA dashboard ui: when I turned the light on first, and then turned the light sensor on, the gree+ app was displayed as AUTOMATICALLY which was expected, wish this would be helpful.

toughvj commented 5 months ago

Strange thing. If the gree+ application shows light as automatically, it means that both parameters have been set correctly in the device. Maybe there should be another parameter there?

Can U send me back javascript files from gree+ app?

red3 commented 5 months ago

As I said the gree+ app only display automatically when I turn on lights before turn on light sensor, I guess we should use both Lig:1 and LigSen:0 to represent turn on the built in light sensor. I will send you the JavaScript file tomorrow.

toughvj commented 5 months ago

try attached file but remove light_sensor entity id from configuration. Then try switch light on, this would send {'Lig':1, 'LigSen':0} This is for testing only. climate.txt

red3 commented 5 months ago

hey @toughvj this version works well: when I turn light on, gree+ app shows Automaticly when I turn light off, gree+ app shows Off Also, attached file is javascript file from gree+ app, you can search setLig:function for detailed information gree.txt

toughvj commented 5 months ago

ok, and light sensor works well?

red3 commented 5 months ago

Do you mean whether the built-in light sensor functionality is working correctly? yeah it's working well

toughvj commented 5 months ago

this is some kind of starting point. Need some time to get this working.

toughvj commented 4 months ago

@red3 please try attached file. from this version auto_light, auto_xfan and light_sensor must be provided with input_boolean entity id. Please give any feedback if it fit's your needs. climate.txt

red3 commented 4 months ago

this version works fine, thanks for your excellent work. @toughvj

toughvj commented 4 months ago

@RobHofmann this can be closed, solved in #188