So my Lanbon L8 light switches were seriously buggy. Problems included;
- Mesh WiFi network was flawed and consistently losing connectivity
- Artifacts on the screen and buttons in a stuck mode
- Random rebooting of the switches
- Sluggish response from the touch screens
- Firmware doesn't automatically update, requires contact with supplier to do anything.
- Doesn't easily working with Home assistant
So, I had a look at what custom firmwares were available and found this;
Custom Firmware on Lanbon L8 LCD Touch Switch | Blakadder's Smarthome Shenanigans
Which was pretty good, but still lacked the detail of how this things works, just sort of showed how to get started. Thought it would be a good idea to go into some detail for new comers.
This article will walk through the firmware to configuration on home assistant including a few extra learnings...
Prerequisites;
- USB to serial (ardiuno writer) (like this CP2102 module USB to TTL serial UART STC download cable PL2303 Super Brush line upgrade for arduino|Integrated Circuits| - AliExpress)
- A LanBon L8 light switch
- Recommended - Ethernet cable, dupont connectors and dupont crimper
- Home Assistant (Supervised)
- Home Assistant Add-on "Mosquitto Broker" (MQTT broker addon)
- Home Assistant Add-on "Terminal & SSH"
- Home Assistant Add-on "HACS repository" (GitHub - hacs/integration: HACS gives you a powerful UI to handle downloads of all your custom needs.)
- From the HACS repository install the "openHASP integration"
- On your PC you will need;
- Install Arduino IDE
- Install ESP driver support (Installing — Arduino-ESP32 2.0.2 documentation (espressif.com))
- Install pyserial
- Command is "pip install pyserial"
- I don't remember if python came with the IDE, but you may need python for this as well if it didn't
Do a search after this, you should find the file "esptool.py" in one of you directories under "arduinodata"
I am going to assume you have installed all the above and you have some experience with the above...
Connecting the Lanbon L8
Backup;
You can skip this step, but i like to have a backup of the working image in case this doesn't work and need to flash it back.
*****IMPORTANT ***** Everytime you do an action with the L8 and ESP memory you will need to reboot it.
* Run in administrative command prompt from the esptool.py directory
Please note my COM port was COM3, you will need to find yours (best is to load the Arduino IDE and take a look at "Tools->Port")
esptool.py --port COM3 --baud 921600 flash_id
Read the memory size (mine was 8MB)
--The 0x800000 will equate to 8MB of memory
Writing OpenHASP to the device
- Reset the device (this means disconnect +5V and reconnecting it)
- Erase the current OS
- esptool.py --port COM3 erase_flash
- Reset the device
- Write the openHASP image to the device
- esptool.py --port COM3 --baud 921600 write_flash 0x0 lanbon_l8_full_8MB_v0.6.2.bin
Configure the "Plate"
Thats it, you have now installed openHASP on the Plate, next step configuring it;
For reference here is how it fits together;
Once write confirmed remove IO0 from Ground and reboot.Should show this
Add to wifi manually (should get an IP pop up)
Then you should see this;
In a web browser put the IP that it got from DHCP.
Should look like this;
Next enter the MQTT broker details;
Save settings then reboot the device (can do from the web interface now)
If you have done everything as expected you should be able to see it on the MQTT broker using MQTT explorer.
Next is configuring the GPIOs for the relays and mood lights. You can do this manually but its far easier using MQTT explorer;
Send the following json to hasp/[mqttnodename]/config/gpio
{"config":[197658,263456,329249,655628,655886,656155,0,0]}
See example:
Setting the display up
So all the base setting up is done, now we need to draw up the GUI. I am not going to go into something complex, rather I will give you my first "pages.jsonl" to work with;
{
"page": 0,
"id": 1,
"x":0, "y":0, "w":80, "h":20,
"comment": "Time in the top left",
"obj": "label",
"text_color": "#FFFFFF",
"text": "00:00",
"align": "left",
"bg_color": "#2C3E50"
}
{
"page": 0,
"id": 2,
"x":160, "y":0, "w":60, "h":20,
"comment": "Temp",
"obj": "label",
"text_color": "#FFFFFF",
"text": "00.0",
"align": "right",
"bg_color": "#2C3E50"
}
{
"page": 0,
"id": 3,
"x":220, "y":0, "w":20, "h":20,
"comment": "Temp sign",
"obj": "label",
"text_color": "#FFFFFF",
"text": "°C",
"align": "right",
"bg_color": "#2C3E50"
}
{
"page": 0,
"id": 6,
"x":0, "y":300, "w":80, "h":20,
"comment": "tab nav on the bottom, prev",
"obj": "btn",
"action": "prev",
"bg_color": "#2C3E50",
"text": "\uE141",
"text_color": "#FFFFFF",
"radius": 0,
"border_side": 0,
"text_font": 28
}
{
"page": 0,
"id": 7,
"x":80, "y":300, "w":80, "h":20,
"obj": "btn",
"action": "back",
"bg_color": "#2C3E50",
"text": "\uE2DC",
"text_color": "#FFFFFF",
"radius": 0,
"border_side": 0,
"text_font": 22
}
{
"page": 0,
"id": 8,
"x":160, "y":300, "w":80, "h":20,
"obj": "btn",
"action": "next",
"bg_color": "#2C3E50",
"text": "\uE142",
"text_color": "#FFFFFF",
"radius": 0,
"border_side": 0,
"text_font": 28
}
{
"page": 1,
"id": 101,
"x":0, "y":30, "w":240, "h":80,
"comment": "relay1",
"obj": "btn",
"toggle": true,
"text": "\uEA70 Dining Room",
"mode": "break",
"align": "center",
"groupid": 1
}
{
"page": 1,
"id": 102,
"x":0, "y":120, "w":240, "h":80,
"comment": "relay2",
"obj": "btn",
"toggle": true,
"text": "\uF1E1 Kitchen Bench",
"mode": "break",
"align": "center",
"groupid": 2
}
{
"page": 1,
"id": 103,
"x":0, "y":210, "w":240, "h":80,
"comment": "relay3",
"obj": "btn",
"toggle": true,
"text": "\uF054 Outdoor Trampoline Area",
"mode": "break",
"align": "center",
"groupid": 3
}
Here are a couple of key details;
- Page 0 is common for all pages (header and footer page)
- The time and temperature will be fed back (to the placeholder) from the HA server they do not live on the plate at all.
- The id will be referenced later in Home Assistant
- Special images are in the font and can be used using \uABCD
- Groupid relates to the GPIO port it will use
Okay, now upload it via the web page via the HASP Designer, save and REBOOT.
Should look something like this... But without the time and temperature (as HA isn't configured)
Configuring Home Assistant
Open up the terminal on the home assistant web page.
Goto the config directory
cd config
I am going to assume you know how to use the vi editor or something similar, not going to go into it here, google vi editor if you dont know how to use it...
vi configuration.yaml
Insert the line "openhasp: !include openhasp.yaml"
Write and quit the file.
You could insert the code into this file but it would be long and painful, not recommended
vi openhasp.yaml
DO NOT USE TABS in the file, it will not parse correctly if you do.
- Sensor.time I added and entity to Home assistant to show time on unit
- Sensor.hue is a philips motion sensor that I am pulling the temperature from.
Summary
- Mesh WiFi network was flawed and consistently losing connectivity - Resolved
- Artifacts on the screen and buttons in a stuck mode - Resolved
- Random rebooting of the switches - Resolved
- Sluggish response from the touch screens - Resolved
- Firmware doesn't automatically update, requires contact with supplier to do anything. - Resolved
- Doesn't easily working with Home assistant - Resolved
No comments:
Post a Comment