-
Notifications
You must be signed in to change notification settings - Fork 297
The future of Heimcontrol: structural changes, new features (please discuss!) #105
Comments
As promised, some more details on a possible implementation: I think it would be good to run Heimcontrol’s server side as an API server, i.e., to step away from template rendering, and handle that in the client instead. This could presumably be done with something like Angular (or Ember, or Backbone, or …) on the client, and Sails (or SocketStream, or LoopBack, or Actionhero … Derby, Meteor – the choices are overwhelming). I don’t have experience with any of these, and they probably all have their ups and downs. For example, on first look:
Again, the potential advantages would be speed, stability, structure & maintainability, and a better API. (Whether it works out that nicely remains to be seen. Maybe the frameworks will turn out to be bloated overkill with none of the benefits I hoped for, who knows.) [@ni-c If you find all of this entirely repulsive, please complain ;-).] |
A complete rewrite will take a lot of time and at the moment i'm a little bit busy. But i like the idea and we can give it a try. I have some experience with Angular and Swagger, i will take a look at the other frameworks when i got some time. |
Maybe you could include Node-RED :) |
@ni-c Don’t worry, I’m not in any hurry – and if the experiment doesn’t work out well, we can always stay with the current setup. But the more I learn about those frameworks, the more I want to try them. In case any one is interested, I’ve found (yet another) really interesting framework: Autobahn/WAMP + Crossbar can set up websockets to enable not just soft-real-time messaging/events, but remote procedure calls – not just server–client, but inter-client, too! I’ve also played around with Angular some more, and I’m now pretty convinced that serving up a JSON API only (plus the static Angular HTML/JS files) is the way to go. Angular handles the rest with ease, and the Pi will be under less load. |
I think it could very nice if heimcontrol.js could be used in master slave setting where RPI is the master of several distributed remotely controlled Arduino modules. Modules could communicate with RPI through NRF24l01, RFM12B or some other low power-low - cost wireless module. The modules could be used to measure environment variables as temperature, motion, light intensity and turn on/off high voltage appliances. The master RPI could request measurements from the slaves and the slaves could report on certain time intervals their measurements to the master. The data could be stored in mongo collections for later use/reporting. Cheerz, |
[@gubagu: That’s actually exactly what I have in mind for my own home automation: A bunch of Arduino Pro Minis w/ sensors (temp, brightness, door state) and actuators (lights and power sockets) communicating via cheap wireless. (I’m giving 433 MHz a try: it’s dirt cheap, I already use it for my power sockets, and I don’t need a whole lot of reliability – if a sensor doesn’t report I don’t care, if an actuator doesn’t respond, I’ll resend.) The goal being a unit cost of not much more than $5.] But that inter-Arduino communication is definitely beyond the scope of Heimcontrol. Striving for modularity is clearly good though. Here’s what I’ve been thinking about:
On the technical side, the sensors’ readings and other state information are distributed via websocket, the actuators are triggered as remote procedure calls: … Well, that’s the theory. I really like it, though. I’ll try to write a minimal proof-of-concept soon. |
Nice to find alike thinking ppl I don't think the price with everything attached to one module will go above $5 per piece (work hours not included) :DDD |
Hi Guys, To introduce myself, I started working on my own home automation controller only to find out later that there are already a bunch of these open source projects so after some comparing I decided to go for Heimcontrol. After all it's much more fun to work together on a project that already has some traction. I've already seen some good ideas in the above comments. This pull request should already help a bit with that vision. Do you guys always test the code on an actual Raspberry Pi when developing? @tjanson I really like the suggestion you make of using Crossbar.io. It seems like a really solid and extendable setup. It's kind of on the same line with what I implemented for my home automation. See the image below for a basic graphical view of the implementation. So all events that are triggered were sent to the PubSub system in the NodeJS app and this distributed the event again to all other protocols. @tjanson @ni-c are you guys still thinking about doing a rewrite because I really want to help. |
Hi @Sitebase,
Not at the moment, no. It’s definitely something I still want to do at some point, but I’m too busy at the moment. But it’s good to hear you’re interested too. :-) I had a tiny Hello World for WAMP pub/sub/RPC using only Node.js (rather than crossbar/Python, which didn’t run well on my Pi). I remember trying to implement a way for the clients to auto-discover each other’s methods (cf. Wamp “reflection”) and being a bit frustrated that it wasn’t built in. The following was my “dream architecture” (just brain-storming): All user interfaces, actuators, and sensors to be derived from a very simple common Wamp client (which is where I wanted to go with the example linked above). The entire system would be decentralized in the sense that the components could be completely separate and run anywhere on the network (e.g., a temperature sensor might be a 10 line NodeJS programm running on a Pi). And dynamic in the sense that they could be added/removed from the network at any time (through the (so far non-existent) discoverability) – the interface would simply show the sensors currently available (or their last reading). … Again, I’m unfortunately busy with school right now, but I’m still very curious to see what you come up with; and maybe we can work on it together in the future. – TJ |
Hi, I am currently working on a new version of the Arduino plugin. This version include a way to communicate to remote Arduino with 433 MHz RF modules and the VirtualWire library. It is simple, the main Arduino is connected directly (USB) to the RPi and it communicates to the others wirelessly. To do that I fork duino project from ni-c and add some functions and a new code for the main Arduino and the remotes Arduino. For the moment, only DigitalWrite/Read and AnalogWrite/Read are implemented. I also fork the Heimcontrol.js project and tweak the Arduino plugin, but I have not test it at the moment. Have a look at my work: Some ideas :
Gagnon06 |
HI @tjanson, I'm also working on a home visualisation with nodejs. My Idea is to read the actual values from my plc at home (Wago controller with codesys). some of the values (temperature, etc.) i want to save in a DB (Mongo, etc.) for a temperature graph. The connection to the frontend i want to do with sockets for realtime visualisation. At the moment i'm fighting how i can implement the function that every changed value of temperature is saved in the DB and also send over the active socket connections. At sails.js the framework will do everything for me. but i have no idea where i should implement my function for constantly reading my values with modbus TCP. How is your status? thanks. greetings Michael |
Hi @micha1983; I’m afraid I’m currently not working on home automation at all, nor have I tried Sails.js – so I can’t help you with that, sorry … Best of luck though. :) |
HI @tjanson , thanks for the fast feedback. greetings from Würzburg. Michael |
Hi, where are things headed? I think the rewrite is an awesome idea and I'd like to contribute. I'm working with AngularJS right now, so I feel somewhat comfortable to help with the frontend. Also, today I have implemented a simple project using the RPi w/ heimcontrol & arduino and am using the RPi itself to flash the arduino, so from the moment I got everything wired up, it's 100% standalone (except electronics you need to assemble of course). Something like this could be used as a functionality like uploading sketches to the app and have it compile and flash the duino on the fly. What do you think? |
So I've been thinking about the state of Heimcontrol and possible new features, so I figured I'd share.
Application Structure
routes/index.js
; the app could use some structureThis to me sounds very much like it's time for a rewrite, in particular using a stronger framework [that is, something more than Express]. It should help get all the basics right, with little effort: Rest API endpoints, websockets, data store via ORM, authentication, logging, and most of all structure are all staples of current frameworks, and that's exactly what HC needs.
Do we need a framework? No, but I think it's an exciting opportunity and could solve a lot of problems (see below). And it's a learning experience, of course! :)
Features (all just ideas / a wishlist, of course)
if..then
, e.g., "if dark, turn on light")Here again I see the benefit of a rewrite: keeping our feature requests in mind while choosing the framework and restructuring the existing code should make the implementation a lot easier.
I'll write some more tomorrow, but for now: What do you think? Please don't hesitate to share your thoughts, feature requests, anything. :) (As always especially @ni-c, but everyone else as well!)
The text was updated successfully, but these errors were encountered: