cmroche / greeclimate

Python package for controlling Gree based minisplit systems
GNU General Public License v3.0
42 stars 21 forks source link

A/C not responding to device.push_state_update #75

Closed Tempmail1234-pass closed 1 month ago

Tempmail1234-pass commented 3 months ago

using this code

import asyncio
import logging
from greeclimate.device import Device, DeviceInfo, Mode, TemperatureUnits, FanSpeed, HorizontalSwing, VerticalSwing
from greeclimate.discovery import Discovery, Listener

logging.basicConfig(
    level=logging.DEBUG, format="%(name)s - %(levelname)s - %(message)s"
)
_LOGGER = logging.getLogger(__name__)

class DiscoveryListener(Listener):
    def __init__(self, bind):
        super().__init__()
        self.bind = bind

    async def device_found(self, device_info: DeviceInfo) -> None:
        if self.bind:
            device = Device(device_info)
            await device.bind(key='a3K8Bx%2r8Y7GREE')
            device.power = True
            device.mode = Mode.Cool
            device.target_temperature = 16
            await device.push_state_update()

async def run_discovery(bind=False):
    _LOGGER.debug("Scanning network for Gree devices")
    discovery = Discovery()
    listener = DiscoveryListener(bind)
    discovery.add_listener(listener)

    await discovery.scan(wait_for=10)

    _LOGGER.info("Done discovering devices")

asyncio.get_event_loop().run_until_complete(run_discovery(True))

getting the output:

greeclimate.network - DEBUG - Sending packet:
{"cid": "app", "i": 0, "t": "pack", "uid": 0, "tcid": "9424b8a2f6cd", "pack": {"opt": ["Pow", "Mod", "SetTem", "TemRec", "TemUn"], "p": [1, 1, 16, null, null], "t": "cmd"}}
greeclimate.network - DEBUG - Received packet from 192.168.0.165:
{"t": "pack", "i": 1, "uid": 0, "cid": "", "tcid": "", "pack": {"t": "dev", "cid": "9424b8b7cc08", "bc": "00000000000000000000000000000000", "brand": "gree", "catalog": "gree", "mac": "9424b8b7cc08", "mid": "10001", "model": "gree", "name": "", "lock": 0, "series": "gree", "vender": "1", "ver": "V2.0.0", "ModelType": "32776", "hid": "362001065279+U-WB05RT13V1.21.bin"}}
greeclimate.discovery - INFO - Found gree device Device: 9424b8b7cc08 @ 192.168.0.165:7000 (mac: 9424b8b7cc08)
greeclimate.device - INFO - Starting device binding to Device: 9424b8b7cc08 @ 192.168.0.165:7000 (mac: 9424b8b7cc08)
greeclimate.device - INFO - Bound to device using key a3K8Bx%2r8Y7GREE
greeclimate.device - DEBUG - Pushing state updates to (Device: 9424b8b7cc08 @ 192.168.0.165:7000 (mac: 9424b8b7cc08))
greeclimate.device - DEBUG - Sending remote state update Pow -> 1
greeclimate.device - DEBUG - Sending remote state update Mod -> 1
greeclimate.device - DEBUG - Sending remote state update SetTem -> 16
greeclimate.network - DEBUG - Sending packet:
{"cid": "app", "i": 0, "t": "pack", "uid": 0, "tcid": "9424b8b7cc08", "pack": {"opt": ["Pow", "Mod", "SetTem", "TemRec", "TemUn"], "p": [1, 1, 16, null, null], "t": "cmd"}}
__main__ - INFO - Done discovering devices

But the A/C is not responding back, what is wrong?

cmroche commented 3 months ago

Nothing looks out of the normal, does the device respond to the command at all?