Created
December 9, 2022 19:16
-
-
Save gjdv/eb984538265c728be94cb4206de5b006 to your computer and use it in GitHub Desktop.
Script to change the wifi settings of a Daikin airco (tested on FTXA)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
default_ip = '192.168.127.1' | |
def do_get(url): | |
try: | |
resp = requests.get(url) | |
except Exception as e: | |
raise Exception("Could not reach url: %s" % url) from e | |
if 200 <= resp.status_code < 300: | |
return resp.text | |
else: | |
raise Exception("Could not perform %s action: %s" % url, resp) | |
def get_wifi(ip): | |
url = "http://%s/common/get_wifi_setting" % ip | |
return do_get(url) | |
def set_wifi(ip, ssid, key, do_set=False): | |
url = "http://%s/common/set_wifi_setting" % ip | |
key_encoded = "".join('%' + hex(ord(c))[2:].rjust(2, '0') for c in key) | |
data = 'ssid=%s&security=mixed&key=%s' % (ssid, key_encoded) | |
if do_set: | |
return do_get("%s?%s" % (url, data)) | |
return "%s?%s" % (url, data) | |
def do_reboot(ip): | |
url = "http://%s/common/reboot" % ip | |
return do_get(url) | |
def main(): | |
inp = input("Please input the ip address of the Daikin device: ") | |
if inp == '': | |
ip = default_ip | |
print("Using default ip address: %s" % ip) | |
else: | |
ip = inp | |
print("Result of get_wifi: %s" % get_wifi(ip)) | |
ssid = input("Please enter the ssid for the new network: ") | |
key = input("Please enter the key for the new network: ") | |
print("Result of preparing set_wifi: %s" % set_wifi(ip, ssid, key, do_set=False)) | |
inp = input("Do you want to continue setting these network settings (yes/*)? ") | |
if inp != 'yes': | |
print("Terminating without making changes") | |
exit(1) | |
print("Result of set_wifi: %s" % set_wifi(ip, ssid, key, do_set=True)) | |
inp = input("Do you want to continue by rebooting the device (yes/*)? ") | |
if inp != 'yes': | |
print("Terminating without reboot") | |
exit(1) | |
print("Result of set_wifi: %s" % do_reboot(ip)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@gjdv thanks for posting this. I couldn't get any of their terrible apps to let me set the wifi, and I only plan to use the api directly anyway.
for future people finding this, if you're using nix, the following shebang works to just grab python and the package this uses: