Exshome - DIY Elixir Smart Home

Hi everyone!

Exshome is a DIY smart home solution.

General idea behind it is to have multiple applications, like clock and music player.
Each application consists of dependencies. You can get a value of a dependency, subscribe to it, etc. The other parts of application also use the idea of broadcasting changes. It also allows to cover the application with tests.

For example, a clock page has ‘current_time’ dependency. User subscribes to it when visits a page, and unsubscribes from it on leave. The page updates every time the ‘current_time’ changes.
‘Current_time’ depends on a ‘timezone’. When the user updates a ‘timezone’, everyone else sees the changes immediately.

Tech stack:

  • Phoenix LiveView.
  • Ecto.
  • Sqlite3.
  • Tailwind.

Project goals:

  • It should be mobile-friendly and support a dark theme.
  • Be easy to extend.
  • Have a nice test coverage. I have set CI coverage threshold of 90%.
  • Should be easy to set up on different Single Board Computers.

I have tested it on MacOS and Linux computers. There are no plans for Windows support. It is not a Neves application now, but there are plans of adding support for it in future.

You can try setting it up with this snippet:

wget https://raw.githubusercontent.com/exshome/exshome/main/bin/exshome
chmod +x exshome

It downloads the launcher, and makes it executable. Launcher uses Mix.install/2 to start an application. You can download launcher to some other place, like /bin to make launcher accessible across the system.
NOTE: This snippet uses launcher from main branch and it can use unreleased version. Feel free to edit a version inside it. You can find the latest released version here: exshome | Hex

I stream the development process from time to time on Twitch. Recordings are also available at YouTube.

Here are the docs for an application. Plan to fill them as the architecture matures.

The UI is quite simple and I plan to focus on the features first, and then make it usable :slight_smile:

Will be glad to get any feedback about Exshome.


We talked about smart devices in a Nerves thread a little while back so Exshome sounds great to me! :023:

1 Like

Its completely unclear to me what this does.

Smart home for me means connecting actuators (lights, blinds, …) to sensors (button, motion detector, …).
What do you mean by smart home? How does exshome compare to eg https://www.home-assistant.io/ or openhab?


Thanks for your questions.

I see Exshome as an application that allows to automate some home actions. Its architecture focuses on the automation.

Let me tell you a history behind this project:

TLDR, project history We wanted to listen to a music in our office back in 2018. I have removed the dust from Orange PI Prime and connected it to an audio system. There were some music player solutions, but they required user interaction to start playback. Another ones had other limitations or felt too complicated for my purpose.

I have spend my weekend to create a simple CLI player on top of mpg123. It picks a random file from folder and plays it. It exits on the file end. This script also generates simple “status” file, and accepts user input via some dark bash magic :slight_smile:
I have used systemd as a supervisor, so it started the script on system startup and restarted it when the file ended.

This solution was extended with cloud commander, so people were able to upload their tracks.

Repeating tracks were not the best thing to listen to, so we have decided to listen to a neutral radio on workdays and launch our tracks on holidays, to make them feel special.

This led to another systemd template together with a stripped bash player script.

The team asked for YouTube tracks and playlists, because it is more fun to see the playlist contributors. It became more easy to find who to blame for ugly track in the playlist :slight_smile:

This led to a local_assistant thing. I have made it public today too :slight_smile:

It is a Phoenix Live View application using Mopidy (together with Mopidy-YouTube) as a backend. It was fun to create it, and it was a prototype for Exshome. It is far from perfect, but it works well for a couple of years already.

I liked the results and wanted to make it something more than just a player. The architecture of local_assistant does not allow extend and test it easily. We have also had some stability issues with Mopidy Youtube integration over this time. My Mopidy client was synchronous and polled the server too hard every second, instead of subscribing to the changes.

That’s why I have decided to create another version of application, together with another player backend. Exshome uses MPV, and its client is much more tolerant to the server :slight_smile:

We have had some routine player tasks at the office: someone needed to start it at the start of a working day, shut it down in the evening, so neighbours can sleep nicely and turn on our special Friday or Christmas Playlist and have a party :slight_smile:

Sometimes previous players lacked observability. If they refused to play a track, I needed to dig into their logs to find out outdated youtube_dl version, or deal with some network issue, etc. Exshome already has many features to deal with this issue. It is easy to attach to get output of running MPV application, its state, every message, etc. There is no UI for it right now.

Now project has building blocks for applications and two of apps: Clock and Player. Both are very simple, but they are enough for me. I plan to start implementation of Automation app. It will be responsible for bringing more “smart-homeness” into the project :slight_smile:

I also have an Arduino kit full of sensors, and actuators in front of me. It gathers the dust and demands for a real work. All I can do now is just tell it to wait for a brighter future :slight_smile:

I can not compare exshome to home-assistant, or openhab. They are way more mature. Thanks for the link and your suggestion. I can use these solutions as inspiration.

I plan to attach low-level things (like Arduino) to Exshome and automate everyday’s life with it. So it will be more DIY thing, than buying a ready-made hub from smart home provider and attaching ready-made locks, sensors and equipment via Z-Wave to it. Possibly the project will have these integrations someday. I will be happy if it help someone to release own creativity.

The project is full of Elixir code and tests. I like hacking it and hope that someone can find it useful too :slight_smile:

Conclusion: the project is in early stage now and it looks more like a feature-less player (which can fail if there is no MPV installed) and a clock. It dreams to become Smart Home solution one day, but now it has only Smart Home as a part of its title.

Plan to post updates about its state in this thread :slight_smile:


Thank you for a link. Have also shared another example of home automation I created there (GitHub - exshome/cctv). I believe that similar camera integration may be the part of Exshome someday :slight_smile:

1 Like

Thanks for the background.

I’m also thinking about building a smarthome solution in Elixir.
It would be focused on bringing together different protocols, at a minimum:

also some services like

  • some weather API
  • some geofencing solution
  • some calendar solution

and some logic

  • scenes controller
  • timers
  • rules (luerl maybe)

I already had a deeper look at the architecture of home assistant (which is a very powerful tool).
It is extremely complex and seems to rebuild lots of stuff we get for free with BEAM/OTP.

1 Like

Glad to help if you launch your project


Yeah, BEAM/OTP is a great tool for automation and smart home :slight_smile:

I think your solution will be great. I have faced these questions while preparing architecture of Exshome and my answers on them:

  1. Testing:
  • How to decouple each test to make it async? - Each Exshome test has own sqlite database, root folder, Repo, etc. Many features rely on PubSub (Event Bus). It is easier to send event and observe result, than mocking underlying services.
  1. Deployment:
  • Which targets do you want to support? - Linux or MacOs based ones. I have Orange PI, so it should be able to run Exshome too. That’s why I do not focus on Nerves right now.
  • Will you need custom applications (ports, scripting languages, etc)? - I need at least MPV to run Exshome properly. It will require changes to the compilation in Nerves base images. I would not like to support own base image now.
  • What needs to deploy an application? - Docker is not an ideal solution for Exshome. It is easy to dockerize it, but it requires many workarounds to make audio work properly from Docker. For now Exshome supports releases or Mix.install scripts.
  1. Features:
  • Which features to support first? - I try to create minimal working part and then extend it. It shouldn’t be perfect but working.
  1. UI:
  • Do you plan to support UI for Mobile phones? - Exshome tries to look fine at small screens too. It may be not so nice on large ones now though :slight_smile:
  • Does UI need to be real-time? - I like LiveView together with PubSub for this :slight_smile:
  1. Configuration:
  • How to register new integrations? - Exshome uses compile-time hacks to collect features. Automations will require Elixir Registry for dynamic things too.

I have also looked into the home assistant docs. Exshome architecture uses the similar approach as a core of home assistant:

  • Event Bus (PubSub)
  • State Machine (Exshome Dependencies, Variables, etc.)
  • Service Registry (using compile-time registry for the code itself and Elixir Registry for tests)
  • Timer (BEAM/OTP features)

I will be happy, if Exshome implementation details will inspire you :slight_smile:

There are no plans adding extra protocols to Exshome now. I understand, that ready-made IoT tools are very handy, but they have limited or no support in some countries. Arduino-like things are easier to buy, or even create by yourself.

Regarding rules and scripting: It could be great if we could integrate Livebook, or parts of it into the application :slight_smile:

1 Like

I’ll look into this thing in the next two weeks, so it will make more sense to comment on your points then.
For now: you make some important points, that also came up on our side.


Thank you!

Looking forward to your feedback :slight_smile:

1 Like