kevinschweikert
I’ve had the idea to integrate Nerves devices into Home Assistant. The idea would be to communicate with Home Assistant which autodiscovers new devices and creates entities in Home Assistant to get all the wonderful features like a nice UI, historical data, automations, backup, interop with other devices and more for free.
My vision is to make device smart and integrate them easily into Home Assistant.
Some pseudo code could look like this:
defmodule MyNervesProject do
use HomeAssistantNerves
entity :sensor, :temperature do
name "Living Room Temperature"
unit_of_measurement "°C"
device_class :temperature
state_class :measurement
state_fn fn ->
{:ok, temp} = YourTempSensor.read()
temp
end
update_interval 60_000
end
entity :switch, :relay do
name "Garage Light"
state_fn fn ->
GPIO.read(pin)
end
on_command fn state ->
GPIO.write(pin, state)
end
end
end
This could be a nice use case for Build a Weather Station with Elixir and Nerves (PragProg)
But i’m still not a 100% sure on how to implement the communication layer between Nerves and Homeassistant. I see three options:
-
MQTT
Homeassistant offers a automatic device discovery with MQTT. This is very nice, because we wouldn’t have to create a custom integration and using native mechanics. The downside would be, that the user has to configure MQTT and run a broker (which should be already pretty common in a smart home but still) -
Native API
Another option would be to directly hook in to the native APIs from Home Asssistant. This would had the same benefit of not writing a custom integration and also not having to use a MQTT broker but we would have to maintain the calls to the REST API (entity creation) and WebSocket API (realtime updates) -
Custom Integration
This would be the most complex solution but also the most flexible. We could decide ourselves on how to communicate with the device (SSH, gRPC, WebSocket, TCP, HTTP) and implement Nerves only functionality into Home Assistant if there is a need for it. This would involve writing a custom integration in Home Assistant (which i’ve done for other devices, e.g. GitHub - kevinschweikert/ha-mahlkoenig: A homeassistant integration for the Mahlkönig X54 coffee grinder · GitHub) which acts as a translation layer. -
Any other ideas?
Before starting this adventure, is there anything you would wish for? Any ideas for improvements? Is there a need/interest in the community?
I’ve looked at other topics but they wanted to write a standalone smart home solution or just connect to the existing information in Home Assistant
Trending in Discussions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex











Showing Posts 16 to 7- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
kevinschweikert
It’s released! homex | Hex
lawik
Thanks bossman
kevinschweikert
For all others:
Add a new user to Mosquitto (and don’t forget to press “Save”
)
and set the credentials in the homex config:
lawik
Fork. All. The. Things
LostKobrakai
It’s not just an issue with the emqtt package though: Version on hex.pm is outdated · Issue #258 · emqx/emqtt · GitHub
lawik
Publish a copy under homex_emqtt or something if you need to
not ideal but 
I have Home Assistant set up now. Set up a local Homex project on my computer and that gets:
Mosquito reports this:
Sure I’ve missed something in config on one side or the other
kevinschweikert
No, unfortunately not
lawik
Can a hex package not have github deps?
kevinschweikert
I know and i did that but that prevents me from pushing
homexto Hex itself. I am thinking about switching the client implementation although i kind of like how it works currentlylawik
Don’t wait on this, this is not a thing that seems to happen very much. Pin a github ref