dlarrick / pykumo

Python library to interact with Mitsubishi KumoCloud devices via their local API
MIT License
34 stars 12 forks source link

I get address not set?? not sure how to fix... #50

Open trlafleur opened 1 month ago

trlafleur commented 1 month ago
>>> unit = kumos['Bunk Room']
>>> unit.update_status()
Unit Bunk Room address not set

>>> account.get_indoor_units()
['9Y34P008F100512F', '1134P008N100272F', '1134P008N100267F', '9934P0083100096F', '0Z34P008P100175F']
>>> unit._request(query)
Unit Bunk Room address not set
{}

also tried

>>> query = '{"c":{"9Y34P008F100512F":{"status":{}}}}'.encode('utf-8')
>>> unit._request(query)
Unit Bunk Room address not set
{}
dlarrick commented 1 month ago

This means the KumoCloud service has not (yet?) picked up the IP addresses of your indoor units.

See https://github.com/dlarrick/hass-kumo#ip-addresses for some suggestions to get that to refresh via the Installer mode in the Kumo app.

You can try saving the output of the get_raw_json method to a file, editing it to add your IP addresses, and passing that to KumoCloudAccount (as kumo_dict) instead of providing username/password for the KumoCloud service.

trlafleur commented 1 month ago

Not a Python expert, not sure how to do this??

You can try saving the output of the get_raw_json method to a file, editing it to add your IP addresses, 
and passing that to KumoCloudAccount (as kumo_dict) instead of providing username/password 
for the KumoCloud service.
skisteep commented 1 month ago

Here is my Python3 Test program, might point others in the right direction, ps only a test, pss, tab formatting is messed up by Github, but you should be able to get the idea

Updated 8/14/2024 Changed unit.update_status() to getKumoStatus(unit)

import os import sys import pykumo import json import pprint

Setup

unit_addr = {"0Y34P008W100262F": "192.168.25.96","2634P008T100191F": "192.168.25.98", "2634P008T100189F": "192.168.25.97", "2634P008T100193F": "192.168.25.95"}

unit_data = {"0Y34P008W100262F": {"name": "Master Bedroom", "nickname": "MB", "address": "192.168.25.96"}, "2634P008T100191F": {"Name": "Joeys Bedroom", "nickname": "JB", "address": "192.168.25.98"}, "2634P008T100189F": {"Name": "Erics Bedroom", "nickname": "EB", "address": "192.168.25.97"}, "2634P008T100193F": {"Name": "Guest Bedroom", "nickname": "GB", "address": "192.168.25.95"}}

future usage

account._need_fetch = True

print(account._kumo_dict)

Authenticate and get current JSON file for all units

def KumoAccount(fetch_if_needed=False):

Authenticate and get current JSON file for all units

account = pykumo.KumoCloudAccount("wxxw@xxxx.com", "***********", kumo_dict=None)  #
account.get_indoor_units()  # Needed to build kumo_dict
kumo_json_raw = account.get_raw_json()  # Get kumo_dict

# Insert IP address into Dictionary
for id in unit_data:
     kumo_json_raw[2]["children"][0]["zoneTable"][id]['address'] = unit_data[id]["address"]  # add IP Address

kumo_dict = kumo_json_raw  # switch to update DICT with addresses
print(kumo_dict)

kumos = account.make_pykumos()  # kumos is a dictionary
unit_MB = kumos["Master Bedroom"]
#unit_MB.update_status()  # Returns True/False for Status updated
unit_JB = kumos["Joeys Bedroom"]
#unit_JB.update_status()
unit_EB = kumos["Erics Bedroom"]
#unit_EB.update_status()
unit_GB = kumos["Guest Bedroom"]
#unit_GB.update_status()

return unit_MB, unit_JB, unit_EB, unit_GB

def getKumoStatus(unit): unit.update_status() name = unit.get_name() mode = unit.get_mode() fan = unit.get_fan_speed() vane = unit.get_vane_direction() roomTemp = unit.get_current_temperature() coolSP = unit.get_cool_setpoint() unit.set_mode("off")

return name, mode, fan, vane, roomTemp, coolSP

start main

unit_MB, unit_JB, unit_EB, unit_GB = KumoAccount()

unit_name, unit_mode, unit_fan, unit_vane, unit_roomTemp, unit_coolSP = getKumoStatus(unit_MB) print(unit_name, unit_mode, unit_fan, unit_vane, unit_roomTemp, unit_coolSP)