RomanKotov

RomanKotov

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
./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.

Most Liked

Sebb

Sebb

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?

RomanKotov

RomanKotov

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:

Sebb

Sebb

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

  • IFTTT
  • 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.

obsidienne

obsidienne

Glad to help if you launch your project

Sebb

Sebb

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.

Where Next?

Popular in Libraries Top

pkrawat1
Hey guyz We at @aviabird are working on a payment library in elixir/phoenix. We are targeting March 2018 to add 56 Gateways to it. Have...
New
Crowdhailer
Raxx is an alternative to Plug and is inspired by projects such as Rack(Ruby) and Ring(Clojure). 1.0-rc.1 is now available. To use it re...
New
oltarasenko
Dear Elixir community, After a year of development, bug fixes, and improvements, we are proudly ready to share the release of Crawly 0.1...
New
nikokozak
Hello all, I’ve been working on Svonix - a library for quickly integrating Svelte components into Phoenix views. It’s a much-needed succ...
New
OvermindDL1
Been making an MLElixir thing (not released yet…) for fun in spare time in the past day. I’m just trying to see how much I can get an ML...
132 13487 106
New
Jskalc
Hi! Today, after a couple weeks of development I’ve released v0.1 of LiveVue. It’s a seamless integration of Vue and Phoenix LiveView, i...
New
zorbash
I created Kitto a framework for dashboards inspired by Dashing. [demo] The distributed characteristics of Elixir and the low memory foo...
New
engineeringdept
I’ve just released the first version of Snap, an Elasticsearch client. It borrows ideas about application structure and process managemen...
New
vic
Expat is a tiny experiment I did for extracting patterns and being able to reuse them (compose and share patterns between elixir librarie...
New
versilov
Could not wait for the missing Elixir ML libraries to appear, so, I wrote one myself, taking https://github.com/sdwolfz/exlearn as a foun...
New

Other popular topics Top

openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New

Sub Categories:

We're in Beta

About us Mission Statement