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 !

Linearburn commented 4 years ago

2 secs

Linearburn commented 4 years ago

I2C SCAN RESULT found=128, addr0=0, addr1=1, addr0=2

this one has persisted after 4 refreshes ill refresh again in a few

ljalves commented 4 years ago

Oh wait! There's a bug on the code... let me recompile it. And add more stuff to test.

Linearburn commented 4 years ago

Oh wait! There's a bug on the code... let me recompile it. And add more stuff to test.

np ill flash it when its up

Linearburn commented 4 years ago

Just wondering how much spare flash space do these modules have? I could probably build a decent webpage for them if they have enough flash

ljalves commented 4 years ago

Ok... bugs fixed. New FW to test i2c: https://drive.google.com/open?id=1gijtTdLMlO-xfW2nngJX1OH83DXQACFM (please paste output)


About flash space for webpages, it has a lot but the limitation on these modules is that a webpage is limited to 1400 bytes. There is an alternative, which consists in rebuilding the main webpage with additional files. I can show you how to do this later. Any help on the webpages are welcome!

Linearburn commented 4 years ago

I2C SCAN 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | t=128

Linearburn commented 4 years ago

was that what you were looking for?

ljalves commented 4 years ago

ok, same as before... The PIC is answering to all slave addresses... not promising. I would suggest a hard-reboot (remove power and reapply) and test that again. If the result is the same, then it's really a crappy i2c implementation...

To make some sense of what we are doing: The PIC controls the output of the dimmer. Looking at the board, I can see 5 leds so I would expect 5 levels of brightness. 0=off, 5=full brigthness I would expect to be able to write a value somewhere to set the dimming level.

I don't know what to write to the i2c bus, but we can try guessing... You can write to the i2c bus with: http://_module_ip_/state?a=6&v=1 (It will write 'v'alue 1 to 'a'ddress 6)

Then try changing 'a' until something happens.

If no luck, I will change the code to write '1' or '5' to all addresses and see if we can get it to turn ON...

If I had a working module, I could easily "sniff" the correct values...

Linearburn commented 4 years ago

ill eat dinner then ill go trip the breaker and turn it back on

ljalves commented 4 years ago

New FW: https://drive.google.com/open?id=15TStxySnqZ5DlDKv-pmTho9oklrBVtLj This will allow to write a value to all addresses with:

http://_module_ip_/state?v=5 (It will write 'v'alue 5 to all addresses)

Linearburn commented 4 years ago

this will be great once it's working I have 44 of these switches rn I plan on flashing

ljalves commented 4 years ago

I'm sure we can make it work - worst case you can ship me a working module so that I can easily reverse engineer the i2c traffic and dump the original fw. Once done I can send it back to you.

For now, let me know what was the result of the power cycle, and then the last FW results with: http://module_ip/state?v=5 (and test other values)

Linearburn commented 4 years ago

is there any way to flash the led's so i can identify what switch is what

Linearburn commented 4 years ago

The switch droped off wifi im not shure whats going on with it I may have to pull it and try to hook a serial cable to it whern the usb adaptor gets here I do still have a second switch on line still

Linearburn commented 4 years ago

yea i don't know what up with it now its no longer showing online its not responding to ping or showing a webpage its posable one of my kids pushed a button on it. I'm going to pull the switch tomorrow and swap it with a known good switch. The main problem now is I don't know which one of the 2 it is lol

Linearburn commented 4 years ago

If you want to buy a switch I could prob toss you 10 bucks on it then you don't have to mess with shipping

amitn322 commented 4 years ago

Hey guys.. sorry i was out today . I am also open to pay some money if you are willing to buy a switch. this is a cheap dimmer and may be worth getting it to work locally.

Linearburn commented 4 years ago

I ordered a USB to the serial converter when I get it ill pull the factory firmware if it's still needed

ljalves commented 4 years ago

I'm from Portugal so I can't make use of those dimmers (here mains is 230V AC). But as I said, I can reverse engineer it and then ship it back to someone who needs it.

Unfortunately with the USB serial adapter you can only flash firmware (I have confirmed that). To dump the original firmware from a working module you need to read the flash rom (needs a flash rom programmer).

Meanwhile, let me know if you make progress with the I2C firmware. @amitn322 are you able to test this fw and paste here the output?

amitn322 commented 4 years ago

Is there a way to test this dimmer without actually hooking up with the mains ?

amitn322 commented 4 years ago

I kind of bricked one last time and have one left, so if i will have to either order a new one , or just pull the one out.. but in any case, would be easier if i can still power this thing on outside the mains.

ljalves commented 4 years ago

Yes, you can test unplugged from mains, just power it with 3.3V on the pin labeled 3V3 and ground on GND (as seen in the pictures sent by @Linearburn ). NEVER plug an USB serial converter with the module connected to mains supply!!

@amitn322 , by the way, why do you say it is briked? Can't you access the webpage? Or try to ping it. You can also try to use the android app to config the wifi. Anyway, it's always unbrickable by programing with an usb serial converter.

ljalves commented 4 years ago

Well... I just placed an order for one of these dimmers. I'll let you all know once it arrives.

Linearburn commented 4 years ago

I may try to use an Adriano flash programmer on it I saw how to make on on youtube the other day so maybe ill try to build one. on you might be able to use a bridge to step down the current for powering the board the relays shouldnt care if its 230 or 110 if you wanted to use it check the power supply and change any resisters for the higher voltage

Linearburn commented 4 years ago

I would think you could probaly use a higher value resister to drop the power to keep the specs for poweing the controler

ljalves commented 4 years ago

I shouldn't need to power it with AC to make it work. Powering the module with 3.3V should be enough. Later I'll check all the high voltage components to see if it can work on 230V. Specially the triac (the 3 pin device attached to the aluminum heat sink) and all the capacitors. From the pics, I can see that they use a MP157 to produce the low voltage power (12V maybe?).

Do you still have the module disassembled? If yes, are you able to take a couple more pics of the side hidden by the heatsink? I guess it is hard.

Well... I'll wait for mine to be delivered to finally finish the code.

Linearburn commented 4 years ago

im going to pull the bricked one this week and disassemble it

Linearburn commented 4 years ago

I got my first box of 20 today so i have the speares to swap them

Linearburn commented 4 years ago

I would like to see how to remake the main webpage to include the links for the subpages and change the way it looks

Linearburn commented 4 years ago

IS there a way to flash the led's? for identifying the switch that mounted if its posable maby add a locate feature to the firmware for locating deployed switches

Linearburn commented 4 years ago

I would like to see someday something like.

Pairing mode long flash, quick flash quick flash, long flash . . Locate mode . . . . . . . . operating mode normal LED operation, something like that

Linearburn commented 4 years ago

also looking at the code is there a way to change the device name having every switch in the house named HF-LPB100.ixxxx.com is not very usefull

ljalves commented 4 years ago

My firmware allows to change the module name. As for the main webpage, check this package: https://drive.google.com/open?id=1-x_O1EsdIv_qU0DUoKlAWhGH0fx4JpVa

It contains the original webpage files and instructions of how to modify them. Then you run a tool in there to create a webpage.bin file to flash on http://module_ip/iweb.html Let me know if you need help.

Linearburn commented 4 years ago

I need the path list for all the additional config options and webpages you want to use. I also plan to free up flash space by striping all the Chinese web files is there any objections to this? I'm planning on doing a full rework on the existing page and need to lighten it a lot so there is enough space and if the files aren't needed for the functionality why keep them

Linearburn commented 4 years ago

I made a Discord server if you would like to use it to discuss this project and any future projects when you join it ljalves ill make you admin.

https://discord.gg/x7GkRKV

ljalves commented 4 years ago

I don't need the chinese pages - you can remove them all! The links are available on the main github page (README.md): https://github.com/ljalves/hfeasy#implemented-features

Lastly, that's the SDK for the modules. It's needed to develop code for it and it's already included in the sources here.

Thanks for the efforts. Let me know when you have a nicer webpage - I'll upload it here.

Linearburn commented 4 years ago

I don't need the chinese pages - you can remove them all! The links are available on the main github page (README.md): https://github.com/ljalves/hfeasy#implemented-features

Lastly, that's the SDK for the modules. It's needed to develop code for it and it's already included in the sources here.

Thanks for the efforts. Let me know when you have a nicer webpage - I'll upload it here.

Can you make a Path List ( basically the extra pages you included for config/diag and a copy of the original pages you made so I can ingrate the code into the main interface? maby put it in a http bin folder, ) Thanks

ljalves commented 4 years ago

@Linearburn , not sure what you're asking... the list of links to the extra pages I've made are on the link I posted above. Those pages cannot be placed in a file. They need to be inside the code to get parameters from forms or show dynamic information (they are not not static pages). And I don't have access to the same API as the original webpages have (i.e. for setting wifi parameters). All you can do is to add links to the pages I've made.

ljalves commented 4 years ago

I took another look at the API they use for setting wifi parameters and maybe I can make use of it! Let me test and if it works we may be able to move some config pages to the webpage file system.

ljalves commented 4 years ago

I took another look at the API they use for setting wifi parameters and maybe I can make use of it! Let me test and if it works we may be able to move some config pages to the webpage file system.

Nop... doesn't work.

Linearburn commented 4 years ago

the web files look pretty simple to understand its badly written but fairly straight forward

Linearburn commented 4 years ago

I chipped in on that outlet hope it helps

ljalves commented 4 years ago

Thanks! The dimmer I ordered should arrive in the next couple of days - I'll make it work as soon as I get my hands on it.

ljalves commented 4 years ago

The dimmer arrived! Already dumped original firmware and now I'm making the adjustments for hfeasy to work.

Linearburn commented 4 years ago

sweet let me know if you want me to flash it

ljalves commented 4 years ago

Firmware for dimmer available: https://drive.google.com/open?id=1ArMzHVdy_qJj4CGXCV69LFmOnd0lGouY (edited: link updated)

The dimmer levels go from 1 to 128. To control with MQTT, you just send the value to the subscribed topic. To control with HTTP, use the "sw" to set the dimmer level. Example: http://dimmer_ip/state?sw=level

Some special level values: 0: OFF 255: restore previous dimmer level (from OFF) 254: toggle ON/OFF

The UP/DOWN buttons on the module will increase/decrease the dim level by 6 (maybe I can make that configurable). Please try it and let me know what you think.

ljalves commented 4 years ago

Original firmware for the dimmer also available at gdrive: https://drive.google.com/open?id=1qk_tf5u-_8w3zS267hc5efIwsiWJO3Re

I just noticed that the buttons are swapped from the original fw: up is down, down is up (according to board pin labels). I've uploaded and overwritten the firmware file to fix this, so if you had flashed already, get it again: https://drive.google.com/open?id=1ArMzHVdy_qJj4CGXCV69LFmOnd0lGouY

ljalves commented 4 years ago

I would really like to get some feedback from anyone testing this since I couldn't really plug it to AC mains (no 110V here) and only tested plugged to an o'scope...

Does it work ok? Does it need any fixes?

If I get some time maybe I'll check how many components I need to change for this to work on 230V.

Linearburn commented 4 years ago

there working as intended I have one of the other switches that is just a simple on off I wonder if the firmware would work on it as well