I do no longer actively maintain this code base. I have archived it; this means you can still inspect it and check it out. Take care: the ideas on which I have initially built this project may now be outdated.
The code in this repo is NOT production grade anymore. Its primary purpose has been learning Scala and Akka concepts. I have been running it in production myself, but I had additional security measures in place back then.
You can in no way hold me liable for damage caused directly or indirectly by using this code; see also the license.
Hyperion (Υπερίων) was probably the god of observation in ancient Greece.
Fast-forward to the present, Hyperion is a system that observes a 'Smart Meter' system.
Using Hyperion you can read your smart meter from your computer or Raspberry Pi.
To do so, you need a connection between your smart meter to the computer.
The smart meter has a P1 port, which is in fact an RJ11 connector.
You can connect to the serial port or the USB-port as long as your operating system supports reading from it.
On a Raspberry Pi, using a RJ11-to-USB cable, the serial port will become visible on /dev/ttyUSB0
.
Hyperion is built as an actor system and implemented with Akka. The main actors are:
- The
MeterAgent
creates theIO(Serial)
extension (from akka-serial); it starts it and reacts to the messages it sends. - When a
Serial.Received
comes in, theMeterAgent
converts its payload to an UTF-8 string and sends it to theCollecting
actor. - The
Collecting
that collects pieces of data coming in until it thinks there is complete P1 Telegram. It then parses the content of its buffer using theP1Parser
(not an actor). If that succeeds, it sends the telegram usingTelegramReceived
to theMessageDistributor
. - Actors that want to do something with the data subscribe themselves for incoming telegrams by sending
RegisterReceiver
to theMessageDistributor
. All actors that are subscribed will receive theTelegramRecived
messages that theMessageDistributor
receives from theCollecting
actor.
There are also some actors that process data from the smart meter:
- The
RecentHistoryActor
keeps a limited buffer of received telegrams. Using that buffer, it can report on the last 30 minutes (for example) of energy usage. Useful for seeing how a certain device influences energy usage. - The
DailyHistoryActor
will schedule itself to sleep when it starts, and awake at a fixed time once a day. It will then wait for oneTelegramRecived
, log some metrics in a database and go to sleep again. Useful for generating daily/monthly/yearly reports. - The
ActualValuesHandlerActor
is created once a WebSocket is connected at its endpoint. From then on, it will pass on allTelegramRecived
to that WebSocket. Useful for having a "life" view on the energy meter.
There is also a web front-end to Hyperion. It is maintained in a separate Git repository.
Hyperion is written in Scala using the Akka-framework.
Pre-built Debian packages can be downloaded from CircleCI.
Click on the latest green build and move to the 'Artifacts' tab.
The packages are located in the deb
folder.
The integration tests are written using Rest Assured and stored in ./src/it/
.
Test data is injected using an SQL script (found in ./scripts/database
).
To run the tests locally, issue
sbt \
-Dconfig.file=app/src/test/resources/environment.conf \
integrationTest/test
Hyperion is licensed under the MIT License. See the LICENSE
file for details.