Background:
Most (if not all) IoT vendors have their devices phone home and will likely auto update the device’s firmware to a newer version if available. In most cases, these firmware updates do not require consent from the user. Vendors are also known to restrict or out right disable functionality of devices with new firmware releases. This guide is to show how TP-Link (KASA) IoT devices can be updated while being blocked from accessing the internet and without the KASA App.
Requirements:
- Home Assistant is running with local folder access (www) enabled (you can search the forum on how to enable local folder access)
- HTTPS access disabled in Home Assistant (this can be done temporarily)
- Python modules for accessing the TP-Link device. This guide will use tplink-smartplug
- TP-Link devices are able to connect to Home Assistant
EDIT
Rather than using the HASS as the web server, it’s somewhat simpler to use the available Python web server module.
Steps:
- Download the required firmware from TP-Link. Eg: smartPlug_FCC_HS105US_1.5.4_Build_181224_Rel._1549088397494.bin.
- Copy (or move) the firmware to the Home Assistant www directory.
- Verify that the file can be downloaded from the Home Assistant url http://homeassistant:8123/local/smartPlug_FCC_HS105US_1.5.4_Build_181224_Rel._1549088397494.bin
- Using tplink_smartplug.py, connect to the TP-Link device:
./tplink_smartplug.py -t <device IP> -c info
Sent: {"system":{"get_sysinfo":{}}}
Received: {"system":{"get_sysinfo":{"sw_ver":"1.0.7 Build 210407 Rel.173024","hw_ver":"2.0","model":"HS220(US)"....}
- Download the firmware to the TP-Link device:
./tplink_smartplug.py -t <device IP> -j '{"system":{"download_firmware":{"url":"http://homeassistant:8123/local/HS220_FCC_HS220US_1.0.7_Build_210407_Rel.173024_2021-04-07_17.56.35.bin"}}}'
The device will apply the firmware automatically once the download completes.
6. Check the download status:
./tplink_smartplug.py -t <device IP> -j '{"system":{"get_download_state":{}}}
Sent: {"system":{"get_download_state":{}}}
Received: {"system":{"get_download_state":{"status":0,"ratio":0,"reboot_time":5,"flash_time":5,"err_code":0}}}
status seems to go from 0 - 6 - I do not know the meaning of the values
ratio seems to go from 0 - 100 - I assume this is the download progress
7. Verify the new firmware was successfully applied:
./tplink_smartplug.py -t <device IP> -c info
Sent: {"system":{"get_sysinfo":{}}}
Received: {"system":{"get_sysinfo":{"sw_ver":"1.0.7 Build 210407 Rel.173024","hw_ver":"2.0","model":"HS220(US)"....}
- Done
NOTE: The firmware for the HS220USv2 listed in this guide was downloaded from here which was found in the TP-Link forum.
The HS105US link was taken from a paper by Andrew Halterman