ljalves / hfeasy

HFeasy - firmware for HF-LPx100/LPx30 based devices
45 stars 14 forks source link

Support for Dimmer Wall Switch ? #8

Closed amitn322 closed 4 years ago

amitn322 commented 4 years ago

Hi there,

Does this firmware support wall switch dimmer ?

https://www.amazon.com/gp/product/B07C5YKRSG/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

I know that the model number is HF-LPB100 . I have access to the web UI .

Thank you !

ljalves commented 4 years ago

The current firmware doesn't support the dimmer switch. Should be easy to add it but I don't own one to develop the code...

amitn322 commented 4 years ago

Any hints/pointers/instructions ? May be i could try to add that feature ? I have some programming background.

ljalves commented 4 years ago

Are you able to build the FW? (Keil µVision with toolchain MDK-ARM)

I could provide you sample code to control that dimmer.

amitn322 commented 4 years ago

Yes I could build the FW I believe.

Thank You

ljalves commented 4 years ago

I will add basic support in the code, then you can compile, test and fix whatever needed.

amitn322 commented 4 years ago

Sounds good, thanks a bunch !

amitn322 commented 4 years ago

Hi there, were you able to add the support for dimmer ?

ljalves commented 4 years ago

Yes... I've added it 8 days ago. Check the commit history: https://github.com/ljalves/hfeasy/commits/master

Not sure if it is working as is (no way to test), but the basics are there.

ljalves commented 4 years ago

BTW, if you aren't able to build the firmware maybe I can do it and then you do the testing. The current code should make the dimmer switches (up/down) work. If it does work, then all that is left is to add the mqtt control code.

amitn322 commented 4 years ago

Yeah Sorry, I saw it after I replied.. I was trying to download all the tools to build the firmware but if you already have the environment and can build it , that would be awesome. Also I am using hubitat so i am not sure mqtt is needed but other people might benefit. Another question.. is there a way to backup existing firmware from the device ?

ljalves commented 4 years ago

Flash this fw using the webpage:

And test if the buttons work (up/down). If they do, then I'll finish the code to make it work with http requests and mqtt. Let me know what are the results... To revert back to original fw, flash this file: Edit: Removed broken FW links...
amitn322 commented 4 years ago

I did upload the firmware and the device rebooted ,but I still get the old interface and old firmware :(

ljalves commented 4 years ago

That doesn't make sense. Please remember that the main webpage is "hardcoded" (it will not change). Can you try browsing to: http://module_ip/status and report what you see?

amitn322 commented 4 years ago

This is what i see :


System

Reset flags: 00000002, reason: softreset
Free memory: 25308 bytes
Uptime: 0 days 2h26m10s
GPIO status

Switch: High
Relay: Open(Off), last changed by: HTTP, publish: 0, action: 0
Timer status

Countdown (turn OFF): disabled
Countdown (turn ON): disabled
Connectivity
Hostname:
MQTT server: Disconnected```
amitn322 commented 4 years ago

Oh you know what, looks like it actually flashed :( my bad, the interface looked the same and i was expecting it to look a little different.. also my REC app is showing it offline now.

amitn322 commented 4 years ago

But I do not see any buttons like you mentioned :(

ljalves commented 4 years ago

Yes, the main webpage is fixed, that's what makes these modules almost "unbrickable" (easy to flash back another fw and wifi settings are kept).

But I do not see any buttons like you mentioned :(

I mean the physical buttons (in the wall). Do they work?

amitn322 commented 4 years ago

Nope, they don't seem to work.. i can't even turn on/off the switch anymore..

ljalves commented 4 years ago

Ok, bad news - try flashing the original FW and see if all works good again. I will check the code and try to find bugs.

amitn322 commented 4 years ago

Does not seem to work with the original firmware that you provided either.

ljalves commented 4 years ago

Hmm... that might explain why it didn't work... Does the switch show in the App? If yes, there's a option to upgrade the FW in the app. Try that.

amitn322 commented 4 years ago

It shows offline in the app. I do have another switch as well, but i am not sure if there is a way to extract firmware from there.

ljalves commented 4 years ago

Yes there is, but you have to open it up and connect the module serial port to a usb-serial adapter... If you are able do that, can you post some pictures of the insides? By the way, is the switch exactly as the one you posted on the first message?

amitn322 commented 4 years ago

Yes that is the exact switch, I don't think i would be able to extract the firmware with usb-serial adapter unfortunately :(

ljalves commented 4 years ago

I find it weird that the app doesn't show the switch. Did you try a "factory reset"? Also, are you able to open up the switch and take some photos of the board?

amitn322 commented 4 years ago

Okay, I will try to pull it out and take some pictures tomorrow.

Thank You

ljalves commented 4 years ago

Btw, dont do a factory reset - we might loose acess to webpage due to wifi getting unconfigured! I have some ideas to make it work. Let me do some tests on my side first. Meanwhile if you can get pictures of the insides it may help.

amitn322 commented 4 years ago

Actually I did do factory reset, but i am still able to access webpage over 10.x address..I will get pictures tomorrow.

ljalves commented 4 years ago

1 question: did you try the physical buttons to turn on/off the lights after flashing the original firmware that I provided? If not, please test and let me know if that works.

amitn322 commented 4 years ago

Yes I did try that and it does not work.

ljalves commented 4 years ago

I'm uploaded another version. When you have the chance try flashing this one:

Please test physical buttons and app.´ Edit: Broken fw removed
amitn322 commented 4 years ago

I uploaded this version and now i don't have the "DEFAULT Open WIFI" .. The physical buttons or app does not work.

amitn322 commented 4 years ago

Nevermind, the default wifi came back after some time.. the physical buttons still don't work.. no LEDs blinking on the switch.

ljalves commented 4 years ago

This means that they have 2 different dimmer modules... I'll try to find out more info on that... Meanwhile, whenever you can, disassemble your module and take some detailed board pictures - it should help.

ljalves commented 4 years ago

Whats the name of the app you use with those dimmers?

amitn322 commented 4 years ago

REC Smart by Ankuoo on google play store.

amitn322 commented 4 years ago

Btw.. my working switch has v 1.08 while the firmware that you sent is 1.06

amitn322 commented 4 years ago

Also I now see the switch in the APP but it does not turn on.

ljalves commented 4 years ago

If you can see it in the APP, try using the "update firmware" option in the app. Let me know if it worked.

amitn322 commented 4 years ago

Yeah that just times out on check :(

Linearburn commented 4 years ago

https://drive.google.com/drive/folders/1mPB06ZeS8gLTq-jwH-Yf6IBn9lred7eF?usp=sharing

there are the board pics for model AW51011D https://www.amazon.com/gp/product/B07C5YKRSG/ref=ppx_yo_dt_b_asin_title_o05_s02?ie=UTF8&psc=1

ljalves commented 4 years ago

Nice. It's actually a LPT100F and not LPB100 as I thought!

Can you read the IC reference near the LPT100F? Can't see it from the pics. It looks like a port expander...

Edit: In one of the pictures I can barely read "PIC16F1503"

ljalves commented 4 years ago

Ok, looking at the pics:

I2C is used to communicate with that IC above the module (which I assume it is a 8bit PIC) which does all the work.

So, the "only" thing missing to build a proper firmware for this module is to know which commands to send by I2C.

There are a couple of ways to do this: 1) With a working module capture I2C traffic for each button press. 2) With a working module dump firmware, disassemble and look for the i2c code. 3) With the broken module (or a working one) read PIC flash mem and disassemble code (it may not work as PICs allow to protect firmware from being read back).

Can anyone do any of the above? Easiest is 1) and I could easily do it if I had a working module.

Caution: NEVER program or "play" with the module while connected to the AC line! These module are powered from the AC line without any kind of isolation.

For example, to capture the I2C traffic, the board should be powered exclusively with a 3.3V supply, disconnected from the AC line.

ljalves commented 4 years ago

Another way is to find the module firmware online. I know that the app allows to upgrade the firmware so it has to grab it somewhere! I don't have experience decompiling android app's... anyone?

ljalves commented 4 years ago

@amitn322 (or someone else that's willing to get this working), please flash this firmware: https://drive.google.com/open?id=10fHrj-Irh_oNLUc-L0sOlkZ-JYjNGl1c

Then go to: http://_module_ip_/state

And copy/paste the result. Should be something like:

I2C SCAN RESULT found=0, addr0=0, addr1=0, addr0=0

It does an I2C scan and it should report back the address to control the PIC (if well implemented!).

If this works, it should be half way to get it done!

Edit: link updated

Linearburn commented 4 years ago

I2C SCAN RESULT found=113, addr0=15, addr1=16, addr0=17

Linearburn commented 4 years ago

do you have a discord this would be a good case for a channel to discuss things

ljalves commented 4 years ago

What the f...?? Well... not really a surprise having a crappy i2c slave implemented by them...

Makes things harder but doable I think. I will make a web gui for you to try and send some values to those addresses to see if we can get the lights to turn on.

ljalves commented 4 years ago

do you have a discord this would be a good case for a channel to discuss things

Not really... I'll see what I can do.

ljalves commented 4 years ago

I2C SCAN RESULT found=113, addr0=15, addr1=16, addr0=17

When you hit refresh do you always get the same values? I hope so...