Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No possible disable sleep #44

Closed
claudiosala80 opened this issue Nov 24, 2019 · 27 comments
Closed

No possible disable sleep #44

claudiosala80 opened this issue Nov 24, 2019 · 27 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@claudiosala80
Copy link

Describe the bug
I added the option for sleep, with an input Boolean
When I set the button to true, the sleep is enabled on the final device.
If I make the button change status, the sleep is not disabled on the device

my yaml

  • platform: gree
    name: Condizionatore camera
    host: 192.168.x.x
    port: 7000
    mac: '123456789'
    target_temp_step: 1
    sleep: input_boolean.bedroom_ac_sleep

Platform:

  • OS: Hassbian
  • Browser: Chrome
  • Version: 0.10x
@RobHofmann
Copy link
Owner

How do you implement this boolean? Can you share the input_boolean.bedroom_ac_sleep entity?

@claudiosala80
Copy link
Author

input_boolean:
bedroom_ac_sleep:
name: Condizionatore camera sleep
initial: off

@RobHofmann
Copy link
Owner

Can you turn on debugging for this component and paste the debug log? The boolean seems fine.

@claudiosala80
Copy link
Author

Here!
When I turn on the device, it was with sleep on and the boolean on lovelace was correct.
I set it to off, the device did sound, but sleep still on and after a sync also on lovelace was still on

I did operation around 16:22

[custom_components.gree.climate].log

@RobHofmann
Copy link
Owner

Hmm. I dont use/have this feature, so its hard for me to debug.

@wjketting implemented this feature. maybe he can aid us with this issue.

@claudiosala80
Copy link
Author

I don't know python and so I don't how debug

@wacher74
Copy link

I experienced similar strange thing about sleep mode, finally I gave it up and I implemented this feature via automation (temp decreasing/increasing + quiet mode at specified time).
I'm not use input_boolean for controling at all, because its icon don't change color (Home Assistant it is very messy in this term). I made template switches for control AC.
(Power on/off, Quiet mode and panel lights, Cold plasma/health)

@claudiosala80
Copy link
Author

I experienced similar strange thing about sleep mode, finally I gave it up and I implemented this feature via automation (temp decreasing/increasing + quiet mode at specified time).
I'm not use input_boolean for controling at all, because its icon don't change color (Home Assistant it is very messy in this term). I made template switches for control AC.
(Power on/off, Quiet mode and panel lights, Cold plasma/health)

It is something you like to share with me?
I want "get inspiration" from what you did!

@wacher74
Copy link

Here are some code snipet.
I have Gree Amber (climate.gree_ac_1).

## Switches for control
switch:
- platform: template
  switches:
    ac1_onoff:
        friendly_name: 'AC1 power'
        value_template: >-
          {% if states('climate.gree_ac_1') != 'off' %}
            on
          {% else %}
            off
          {% endif %}

        turn_on:
        - entity_id: climate.gree_ac_1
          service: climate.turn_on

        turn_off:
        - entity_id: climate.gree_ac_1
          service: climate.turn_off

    ac1_quiet:
        friendly_name: 'AC1 quiet mode'
        icon_template: 'mdi:headphones'
        value_template: >-
          {% if state_attr('climate.gree_ac_1', 'fan_mode') == 'Quiet' %}
            on
          {% else %}
            off
          {% endif %}

        turn_on:
        - entity_id: climate.gree_ac_1
          service: climate.set_fan_mode
          data:
            fan_mode: 'Quiet'

        turn_off:
        - entity_id: climate.gree_ac_1
          service: climate.set_fan_mode
          data:
            fan_mode: 'Auto'

    ac1_panel_light:
        friendly_name: 'AC1 panel light'
        icon_template: 'mdi:lightbulb-on'
        value_template: "{{ states('input_boolean.ac1_panel_light') }}"

        turn_on:
        - entity_id: input_boolean.ac1_panel_light
          service: input_boolean.turn_on

        turn_off:
        - entity_id: input_boolean.ac1_panel_light
          service: input_boolean.turn_off

    ac1_cold_plasma:
        friendly_name: 'AC1 Health (cold plasma)'
        icon_template: 'mdi:pine-tree'
        value_template: "{{ states('input_boolean.ac1_health') }}"

        turn_on:
        - entity_id: input_boolean.ac1_health
          service: input_boolean.turn_on

        turn_off:
        - entity_id: input_boolean.ac1_health
          service: input_boolean.turn_off





## temperature controlling at specified time, I use AC for heating now.
## 22:00 22C, quiet on
## 07:00 23C
## 08:00 24C, quiet off


automation:
- alias: 'Klíma fűtés, 22:00, 22 fok, quiet mode on'
  trigger:
  - platform: time
    at: '22:00:00'
  condition:
    condition: state
    entity_id: climate.gree_ac_1
    state: 'heat'
  action:
    - service: switch.turn_on
      entity_id: switch.ac1_quiet # fan mode quiet
    - delay:
        seconds: 5
    - service: climate.set_temperature
      entity_id: climate.gree_ac_1
      data_template:
        temperature: 22


- alias: 'Klíma fűtés, 07:00, 23 fok'
  trigger:
  - platform: time
    at: '07:00:00'
  condition:
    condition: state
    entity_id: climate.gree_ac_1
    state: 'heat'
  action:
    - service: climate.set_temperature
      entity_id: climate.gree_ac_1
      data_template:
        temperature: 23

- alias: 'Klíma fűtés, 08:00, 24 fok, quiet mode off'
  trigger:
  - platform: time
    at: '08:00:00'
  condition:
    condition: state
    entity_id: climate.gree_ac_1
    state: 'heat'
  action:
    - service: switch.turn_off
      entity_id: switch.ac1_quiet # fan mode: Auto lesz
    - delay:
        seconds: 5
    - service: climate.set_temperature
      entity_id: climate.gree_ac_1
      data_template:
        temperature: 24

@claudiosala80
Copy link
Author

Here are some code snipet.
I have Gree Amber (climate.gree_ac_1).

## Switches for control
switch:
- platform: template
  switches:
    ac1_onoff:
        friendly_name: 'AC1 power'
        value_template: >-
          {% if states('climate.gree_ac_1') != 'off' %}
            on
          {% else %}
            off
          {% endif %}

        turn_on:
        - entity_id: climate.gree_ac_1
          service: climate.turn_on

        turn_off:
        - entity_id: climate.gree_ac_1
          service: climate.turn_off

    ac1_quiet:
        friendly_name: 'AC1 quiet mode'
        icon_template: 'mdi:headphones'
        value_template: >-
          {% if state_attr('climate.gree_ac_1', 'fan_mode') == 'Quiet' %}
            on
          {% else %}
            off
          {% endif %}

        turn_on:
        - entity_id: climate.gree_ac_1
          service: climate.set_fan_mode
          data:
            fan_mode: 'Quiet'

        turn_off:
        - entity_id: climate.gree_ac_1
          service: climate.set_fan_mode
          data:
            fan_mode: 'Auto'

    ac1_panel_light:
        friendly_name: 'AC1 panel light'
        icon_template: 'mdi:lightbulb-on'
        value_template: "{{ states('input_boolean.ac1_panel_light') }}"

        turn_on:
        - entity_id: input_boolean.ac1_panel_light
          service: input_boolean.turn_on

        turn_off:
        - entity_id: input_boolean.ac1_panel_light
          service: input_boolean.turn_off

    ac1_cold_plasma:
        friendly_name: 'AC1 Health (cold plasma)'
        icon_template: 'mdi:pine-tree'
        value_template: "{{ states('input_boolean.ac1_health') }}"

        turn_on:
        - entity_id: input_boolean.ac1_health
          service: input_boolean.turn_on

        turn_off:
        - entity_id: input_boolean.ac1_health
          service: input_boolean.turn_off





## temperature controlling at specified time, I use AC for heating now.
## 22:00 22C, quiet on
## 07:00 23C
## 08:00 24C, quiet off


automation:
- alias: 'Klíma fűtés, 22:00, 22 fok, quiet mode on'
  trigger:
  - platform: time
    at: '22:00:00'
  condition:
    condition: state
    entity_id: climate.gree_ac_1
    state: 'heat'
  action:
    - service: switch.turn_on
      entity_id: switch.ac1_quiet # fan mode quiet
    - delay:
        seconds: 5
    - service: climate.set_temperature
      entity_id: climate.gree_ac_1
      data_template:
        temperature: 22


- alias: 'Klíma fűtés, 07:00, 23 fok'
  trigger:
  - platform: time
    at: '07:00:00'
  condition:
    condition: state
    entity_id: climate.gree_ac_1
    state: 'heat'
  action:
    - service: climate.set_temperature
      entity_id: climate.gree_ac_1
      data_template:
        temperature: 23

- alias: 'Klíma fűtés, 08:00, 24 fok, quiet mode off'
  trigger:
  - platform: time
    at: '08:00:00'
  condition:
    condition: state
    entity_id: climate.gree_ac_1
    state: 'heat'
  action:
    - service: switch.turn_off
      entity_id: switch.ac1_quiet # fan mode: Auto lesz
    - delay:
        seconds: 5
    - service: climate.set_temperature
      entity_id: climate.gree_ac_1
      data_template:
        temperature: 24

I will try to use what you do for quiet for the sleep mode
Thanks for now

@claudiosala80
Copy link
Author

No working: the result is the same.
I think there is a problem in one of the scripts

@claudiosala80
Copy link
Author

@RobHofmann and @wjketting

I did some test: with light, that seems the same, all it is ok.

With sleep this is what happen after I enable the switch in Home Assistant to stop the sleep
2019-12-24 17:40:10 INFO (MainThread) [custom_components.gree.climate] sleep_entity state changed |input_boolean.living_ac_sleep|<state input_boolean.living_ac_sleep=on; icon=mdi:car @ 2019-12-24T17:38:40.270750+01:00>|<state input_boolean.living_ac_sleep=off; icon=mdi:car @ 2019-12-24T17:40:10.888039+01:00> 2019-12-24 17:40:10 INFO (MainThread) [custom_components.gree.climate] Updating HVAC with changed sleep_entity state |<state input_boolean.living_ac_sleep=off; icon=mdi:car @ 2019-12-24T17:40:10.888039+01:00> 2019-12-24 17:40:11 INFO (MainThread) [custom_components.gree.climate] HA sleep option set according to HVAC state to: off 2019-12-24 17:40:42 INFO (SyncWorker_2) [custom_components.gree.climate] HA sleep option set according to HVAC state to: off 2019-12-24 17:40:42 INFO (SyncWorker_1) [custom_components.gree.climate] HA sleep option set according to HVAC state to: on 2019-12-24 17:40:42 INFO (MainThread) [custom_components.gree.climate] sleep_entity state changed |input_boolean.living_ac_sleep|<state input_boolean.living_ac_sleep=off; icon=mdi:car @ 2019-12-24T17:40:10.888039+01:00>|<state input_boolean.living_ac_sleep=on; icon=mdi:car @ 2019-12-24T17:40:42.699876+01:00>

As you can see, one of the sync thread switch to on. I cannot understand if there is a problem in the perl script or it is a problem on Gree device that don't stop the sleep

@wjketting
Copy link
Contributor

@claudiosala80

sorry for delayed respons.
switching sleep to off seems not to work for me either.
i'll try to look into it.

@wjketting
Copy link
Contributor

wjketting commented Dec 25, 2019

After a bit of testing it seems the problem is with the airco not accepting the status change for SwhSlp from 1 => 0, see summarised part of my log below.

The 8th parameter in the numbered list is SwhSlp (sleepmode).
The scripts sends 0 (acOptions => statePackJson) and receives 1 (part after Done sending etc...) back from the airco.

  • Overwriting SwhSlp: 0
  • Done overwriting acOptions
  • acOptions: {'Pow': 1, 'Mod': 1, 'SetTem': 20, 'WdSpd': 1, 'Air': 1, 'Blo': 0, 'Health': 0, 'SwhSlp': 0, 'Lig': 0, 'SwingLfRig': 0, 'SwUpDn': 4, 'Quiet': 2, 'Tur': 0, 'StHt': 0, 'TemUn': 0, 'HeatCoolType': 0, 'TemRec': 0, 'SvSt': 0}
  • Start sending state to HVAC
  • statePackJson: {"opt":["Pow","Mod","SetTem","WdSpd","Air","Blo","Health","SwhSlp","Lig","SwingLfRig","SwUpDn","Quiet","Tur","StHt","TemUn","HeatCoolType","TemRec","SvSt"],"p":[1,1,20,1,1,0,0,0,0,0,4,2,0,0,0,0,0,0],"t":"cmd"}
  • Done sending state to HVAC: {'t': 'res', 'mac': '', 'r': 200, 'opt': ['Pow', 'Mod', 'SetTem', 'WdSpd', 'Air', 'Blo', 'Health', 'SwhSlp', 'Lig', 'SwingLfRig', 'SwUpDn', 'Quiet', 'Tur', 'StHt', 'TemUn', 'HeatCoolType', 'TemRec', 'SvSt'], 'p': [1, 1, 20, 1, 1, 0, 0, 1, 0, 0, 4, 2, 0, 0, 0, 0, 0, 0], 'val': [1, 1, 20, 1, 1, 0, 0, 1, 0, 0, 4, 2, 0, 0, 0, 0, 0, 0]}

If you do the same for status change for SwhSlp from 0 => 1, the airco accepts the change.

Don't know the reason. With the Gree App it is possible to switch sleep on and off and select several sleep modes (at least on my airo).
Maybe the payload used in the script is missing a parameter.
Don't know how to check and solve this any further.

@claudiosala80
Copy link
Author

claudiosala80 commented Dec 25, 2019 via email

@claudiosala80
Copy link
Author

claudiosala80 commented Dec 25, 2019 via email

@PLTorrent
Copy link
Contributor

Hi,

I have compiled and run GreeRemoteAndroid from this repo and I can already tell you that with this it is also not possible to set sleep to off. You can only turn it on. A workaround is to switch to FAN mode or other mode that excludes sleep so sleep will be set to 0.

However it is much easier to experiment using this app, and also you have the source code so modifications are pretty straightforward.

@claudiosala80
Copy link
Author

claudiosala80 commented Jan 4, 2020 via email

@PLTorrent
Copy link
Contributor

Leave that to me. Got them captured already. Just need to decode the packs and see whats inside. I'll compare them with what the custom app as well as Home Assistant is sending to the device. ;]

@claudiosala80
Copy link
Author

claudiosala80 commented Jan 5, 2020 via email

@RobHofmann RobHofmann added bug Something isn't working help wanted Extra attention is needed labels Jan 5, 2020
@PLTorrent
Copy link
Contributor

PLTorrent commented Jan 5, 2020

Ok so this is how app does it:
Activate:
{'opt': ['SwhSlp', 'SlpMod', 'SvSt', 'StHt'], 'p': [1, 1, 0, 0], 't': 'cmd'}
Dev responds:
'opt': ['SwhSlp', 'SlpMod', 'SvSt', 'StHt'], 'p': [1, 1, 0, 0], 'val': [1, 1, 0, 0]}

Deactivate:
{'opt': ['SwhSlp', 'SlpMod'], 'p': [0, 0], 't': 'cmd'}
Dev responds:
{'opt': ['SwhSlp', 'SlpMod'], 'p': [0, 0], 'val': [0, 0]}

and then status message from device:
'cols': ['Pow', 'Mod', 'TemUn', 'SetTem', 'TemRec', 'HeatCoolType', 'WdSpd', 'Tur', 'Quiet', 'SwUpDn', 'SwingLfRig', 'Air', 'Blo', 'Health', 'SvSt', 'Lig', 'StHt', 'SwhSlp', 'SlpMod', 'AllErr'], 'dat': [1, 1, 0, 24, 0, 0, 1, 0, 0, 6, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0]

So it seems that to deactivate sleep mode app sends only 2 params: SwhSlp and SlpMod

Later I will try to send such payload from python to device and see if the Sleep Mode will deactivate. Will keep you updated, also if some other captures from original app are required please let me know.

@claudiosala80
Copy link
Author

claudiosala80 commented Jan 5, 2020 via email

@PLTorrent
Copy link
Contributor

PLTorrent commented Jan 5, 2020

Pull request resolving this below.

UPDATE: I can now confirm that what we are missing is SlpMod parameter. I have sent the following request to device:

statePackJson = '{' + '"opt":["Pow","Mod","SetTem","WdSpd","Air","Blo","Health","SwhSlp","Lig","SwingLfRig","SwUpDn","Quiet","Tur","StHt","TemUn","HeatCoolType","TemRec","SvSt","SlpMod"],"p":[1,4,24,1,0,0,1,1,1,0,6,0,0,0,0,0,0,0,1],"t":"cmd"}'

And this has turn the device on, set to heating, temp to 24C, Health to on, Light to on and Sleep mode to on.

Then I have sent:

statePackJson = '{' + '"opt":["Pow","Mod","SetTem","WdSpd","Air","Blo","Health","SwhSlp","Lig","SwingLfRig","SwUpDn","Quiet","Tur","StHt","TemUn","HeatCoolType","TemRec","SvSt","SlpMod"],"p":[1,4,24,1,0,0,1,0,1,0,6,0,0,0,0,0,0,0,0],"t":"cmd"}'

And the sleep mode has been successfully deactivated.

So it is simply a matter of adding SlpMod at the end.

Furthermore I can confirm that not sending this parameter (i.e. SlpMod) will allow to activate the Sleep mode but since while Sleep mode is set SlpMod is set to 1 it is not possible to deactivate it without this parameter present. Just checked this as well.

Both SwhSlp and SlpMod must be present in order to deactivate Sleep mode.

@claudiosala80
Copy link
Author

claudiosala80 commented Jan 6, 2020 via email

@claudiosala80
Copy link
Author

claudiosala80 commented Jan 6, 2020 via email

@PLTorrent
Copy link
Contributor

You're welcome.

@RobHofmann
Copy link
Owner

Merged & Closed

Version 2.1.0 released. Can be updates through HACS!

Thanks @everyone for all of your efforts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants