probonopd / ESP8266HueEmulator

Emulate a Philips Hue bridge running on an ESP8266 using the Arduino IDE.
MIT License
411 stars 93 forks source link

Use spiffs to store scenes etc. #53

Open probonopd opened 7 years ago

probonopd commented 7 years ago

Let's use spiffs to store scenes etc. https://github.com/sticilface/Esp8266-Hue/tree/spiffs_branch is using spiffs.

Quanghoster commented 6 years ago

What's the status of this - definitely a good idea...

probonopd commented 6 years ago

To my knowledge no one has started implementing this so far, and I don*t have the time to do this anytime soon. PRs welcome! I could help with testing.

Quanghoster commented 6 years ago

I will take a look at it.

Quanghoster commented 6 years ago

I've modded the main sketch quite a bit as I'm using a different neopixel library. Shouldn't matter as I would probably use another sketch that works with your lightservice classes

probonopd commented 6 years ago

Whatever you are doing, if the result is that it works better with your changes than before, I'd ask you to submit your changes as pull requests so that we can all benefit. Ideally you don't wait until many changes have accumulated, but send one separate PR per improvement at a time, as is best practice in any open source project.

Thank you for your great work!

mcer12 commented 6 years ago

Hi @Quanghoster any news on this? Sadly the sticilface rep is buggy (causes imediate hue app crash for me) and not maintained anymore looks like.

Quanghoster commented 6 years ago

I've been tied up with other work lately but will start spending a bit of time on this over the next few days. I'm thinking we have simply store the json as files, load on boot and save on change...

Quanghoster commented 6 years ago

OK, some progress. I now have spiffs support to store bulb groups which I have tested with the hue switcher app. I am basically saving each group slot as a file and loading them into the existing array on start up, if they exist. I've also made a start on spiffs support for scenes with the same approach the scene is being saved to the file system but I'm not seeing them listed in the app yet. I think there may be another Json format issue for the list scenes function which I hope to investigate this evening. Once I have groups and scenes working with spiffs I'll post a PR. Need some thoughts on how to handle formatting of fs initially...

Quanghoster commented 6 years ago

Is scenes working for anyone? I can create a scene which gets stored in a file with my code changes, but they aren't getting listed in the app when added. I've done some comparison with a bridge and see no difference in the json format so am not quite sure why this doesn't work for me.

Quanghoster commented 6 years ago

Here's what I'm getting back from an /api/user REST command, after adding a scene with the app. { "lights": { "1": { "type": "Extended color light", "manufacturername": "OpenSource", "swversion": "0.1", "name": "Hue LightStrips 1", "uniqueid": "2C:3A:E8:06:54:FB-1", "modelid": "LST001", "state": { "on": false, "bri": 0, "xy": [ 0.00000, 0.00000 ], "colormode": "hs", "effect": "none", "ct": 500, "hue": 0, "sat": 0, "alert": "none", "reachable": true } }, "2": { "type": "Extended color light", "manufacturername": "OpenSource", "swversion": "0.1", "name": "Hue LightStrips 2", "uniqueid": "2C:3A:E8:06:54:FB-2", "modelid": "LST001", "state": { "on": false, "bri": 0, "xy": [ 0.00000, 0.00000 ], "colormode": "hs", "effect": "none", "ct": 500, "hue": 0, "sat": 0, "alert": "none", "reachable": true } } }, "groups": { "1": { "name": "G1", "lights": [ "1", "2" ] } }, "config": { "name": "hue emulator", "swversion": "81012917", "bridgeid": "2C3AE8FFFE0654FB", "portalservices": false, "linkbutton": true, "mac": "2C:3A:E8:06:54:FB", "dhcp": true, "ipaddress": "192.168.1.25", "netmask": "255.255.255.0", "gateway": "192.168.1.1", "apiversion": "1.3.0", "timezone": "Europe/London", "whitelist": { "api": { "name": "clientname#devicename" } }, "swupdate": { "text": "", "notify": false, "updatestate": 0, "url": "" } }, "schedules": {}, "scenes": { "": { "name": "S1", "lights": [ "1", "2" ], "owner": "api", "recycle": false, "locked": false, "appdata": { "version": "1", "data": "" }, "picture": "", "lastupdated": "2017-11-04T10:17:15", "version": 2 }, "": { "name": "S2", "lights": [ "1", "2" ], "owner": "api", "recycle": false, "locked": false, "appdata": { "version": "1", "data": "" }, "picture": "", "lastupdated": "2017-11-04T10:17:15", "version": 2 } }, "rules": {}, "sensors": {}, "resourcelinks": {} }

probonopd commented 6 years ago

I don't think I have implemented scenes, at least not close to fully.

Quanghoster commented 6 years ago

Ah ok - it's not too far off as far as I can see. I just noticed that the index isn't being saved for each scene in the json above so will fix that. Your code is otherwise saving scenes and returning them. If I can fix this I can look at a PR for spiffs very soon

probonopd commented 6 years ago

Cool, looking forward to it.