StationIO

What is StationIO ?

An Arduino framework-ish thingy that takes care of the (my?) basics !
It runs on ESP8266 and ESP32 boards, connects to WiFi, provides a web server (with basic endpoints), use a file system (and a command line utility to build said FS), support a bunch of sensor out of the box and provides an easy way to execute function on a timer.

How does it work ?

It uses a set of classes to handle the basic station, sensors, callbacks on a timer and web server endpoints, while still being arduino code.
That way you can hookup your custom code in a breeze.
There are a few (very inventivelly named) bash scripts to handle common tasks :

All the script have plenty of options that are documented, so just use --help to get all the infos.

But.... WHY ?

I know there are plenty of great IOT stack out there but I do not like their architecture, it is too centralized to my taste. I'd rather have independent microservices that can be queried by whatever wants to.
So instead of stations reporting to a central hub, I can have my hub query the stations, stations querying each others, computers querying stations and even stations reporting to a hub (....yep, I know).
Freedooooooom....
Also, I find it a bit annoying to waste "so much" computing power (I know it sounds weird to read) on an interpreter (for micropython) or doing nothing (a few MQQT message an hour).
ESPes have a good chunk of power and can easily handle a webserver and "on the edge" processing, not just reporting values.
Another thing, doing stuff on arduino, considering I have no idea what I'm doing, is mostly copy/pasting (and trials, and errors, mostly errors)...And I really HATE copy/pasting....! StationIO is more or less an "Arduino project copy/paste manager" XD...

Huuum.... how do you get that running then ?

But it's for linux and I run windows (useless nerd !)

Well I dunno... use WSL or something ...
Note that PIO is a python tool, so it should work on windows too, but I did not try it. And you really do not have to use my utils scripts (that are written in bash), just use PIO directly (I use the vscode extension while working on my stations).

What about MacOS ?

Look pal, I ain't responsible for your poor life choices, now if you care to donate a mac (those M2 pro minis look sweeeet) I promise to add support, how's that ?

Can you integrate with other IoT stacks ?

Huuuum, ...., I did not even try ^^'.
It should be easy though, if your stack can fetch info with http queries, no problemo !
On the "/" endpoint, you can set the "Accept" header to "application/json", "application/xml","text/csv", "text/plain" and you'll get a corresponding response. It also works with the get attribute "format". Default is html
For more information, use the "/openapi" endpoint, it will give you a OpenApi doc file that you can use there for more details (yes, if you use addEndpoint, they'll appear in the doc too :D)
If you need MQTT, or other protocols, you should be able to integrate with timer callbacks, I think...
If timer callbacks do not work, fear not, you can still use standard arduino code, in the exact same way as before. (declaration, setup, loop)

What's your use case ?

At home I have several stations (more or less in every room) that run StationIO with a panache of sensors (the ones implemented as a matter of suprising fact) to report temperature, humidity, and so on...
I have a Rpi running a docker-compose stack with a mysql database, a grafana instance and a nodejs instance.
A cronjob on the Rpi fetches the data from the stations and inserts it into the database and my computer displays several widgets that fetch data from the stations in real time for a quick look.
Also, some stations talk to each other in order to decide what actions to execute. For example, I heat my upper floors using hot air taken from above my wood stove.
All fans are controlled by a station that uses intake air temperature, my main room temperature and the heated room temperature to decide what speed to run them at.
I plan on "smartifying" (cough) my garden and greenhouse (hence the Wifi extender) the spring so I'll probably update a few things here and there.

Could you add support for ...

WOOOooow wow, heeeyy there, how ya doin' ? Huum, I'm sorry but I'm afraid not (for now).
If you want a sensor that is not supported, you can add a "custom" sensor in the configuration tool, fill up the form, and boom, it'll generate the (basic) code in the "sensor" tab.
I know it's not perfect, buuut, once you added and tested your sensor, make a pull request so the next lad can benefit from our collective work !

Now, if you want to modify/add/whatever js or css files (or any other type for that matter), put them in "src/assets/...". you can then use the built-in script "utils/buildFS" to build and upload the file system.
Use "utils/buildFS --help" for more info.

Also, if you want, you can load a plugin

Plugins ? What plugins ?

As of now, I have a few :

How does it work ? Can I make one ?!?

NOOooow we're talking !
"Plugins" are just javascript files that I load after the initial load, I do not control ANYthing you are doing, (AT ALL)
Want to add html somewhere ? sure !
Add event listeners ? why not.
Overhaul the look and feel of the generator ? HELL YEAH !
Add code to main.cpp (or install, or custom sensor) output ? Go. For. It.
The plugin "api" provides a way to hook into the templates, so you can add your own stuff to the generated code.
Go and have a look at the IR remote plugin to get an example.
If you made something cool you'd like to share, don't hesitate to make a pull request so I can add it to the list of plugins !

Duuuude, your code is trash, that's not how how you do..., ...

Yuuuup, I'm not too proud of a few things, how sensor work for example, but how do you do proper inheritance and stuff in C++ anyway ? Yes my interfaces are all other the place, I guess you haven't seen my office ^^'. Strings are bad they say ! Meh!, maybe.
I'll gladly take a bit of time to make things better so any suggestions/fingers in the right direction/examples are very welcome ! Use github's issues to report things, or make a pull request !

Can I use it for my project ?

That's what the license says :). Don't expect extensive and ultra responsive support, but if you encounter bug with my core code or the generated one, please open an issue on github.
I'll do my best to fix things as this is the codebase for MY home automation (I'd like to keep it "bug free" :P)

Now go, little one, your next project awaits ...

This tool will help you to generate a StationIO station. You can configure your station, each modification regenerates the code for the main file in main.cpp as well as installation instructions/script.

Main config

Timers config

Sensor config

Endpoint Config

This install guide is for linux systems. It is bash so little to no effort shoud go into running it on mac (I don't have one)
As said in the About section, windows user should use WSL, I know I could install a VM but I have no use for it. If you tried and had to do special things to make it work, please open an issue with the relevant information so I can update the install script.

PlateformIO

Please fill the config form
// Nothing to see here // please fill the configuration form !
No custom sensor defined yet