jhthorsen / homebridge-tasmota-aircon-http

Control Aircon through Tasmota HTTP commands
MIT License
4 stars 2 forks source link

Save state between restarts #7

Closed macjl closed 2 years ago

macjl commented 2 years ago

Hello,

Here is the new PR, only for #4 .

Also, I'm not sure about the "HomeBridgeTasmotaAirconHTTP" name. Can you give me a reference to where CamelCase is used?

I used this name because I didn't know what to use else. I think a good directory name is needed to understand what is stored in. Feel free change it if you prefer something else.

Another thing I just thought about: You have to call _initialState() first, since the storage might not have a complete view of the required state. Meaning that after this.state is initialized, then you can overwrite any values with data from storage inside the if (...) below.

I don't really understand the problem. The state read from disk should be exhaustive, because the whole state var is saved at every changes. And the read is synchronous, so it will be completed before next step.