Hacker News new | past | comments | ask | show | jobs | submit login
Making my dumb A/C smart with Elixir and Nerves (milanvit.net)
63 points by Cellane 5 months ago | hide | past | favorite | 19 comments



ESPHome has built-in support for IR control of many aircons, and exposes itself as a "climate" entity in Home Assistant (which can in turn expose a web UI, or HomeKit, or anything else you'd want).


Some AC units have a serial port that allows two-way communication: https://static.xtremeownage.com/blog/2023/pioneer-mini-split...


Only yesterday I successfully exposed the CPU temps of all my machines as custom sensors in Home Assistant by creating a 30 line python webserver. The Home Assistant configuration took a few minutes more than the webserver portion, but it was mostly a matter of locating and reading the appropriate documentation. Entire job done in 45 minutes (from idea to completion, including SystemD'ification, deployment to 3 snowflakes, and git'ification for reproducibility).

Erlang, Elixir, and the BEAM are super cool space tech for sure, and are also overkill sometimes. For example, for a simple LAN service where a minimalist solution will get the entire job done in 20-30 minutes (or in the case of TFA, a few hours).


HomeAssistant seems nice enough, but everytime I sit down to try to bend it to my will I get real stuck.

I want to coordinate two thermostats that are on a zoned system, and I have a lot of things I want to do, but the first thing is I want to replace the automatic fan with something more specific, and I can't figure out how to get started:

If zone 1 is off (or fan) and zone 2 has had the fan run less than 30 minutes in the last 60, and less than 8 hours in the last 24, run the fan.

But I can't figure out how to write a homeassistant helper that gets recent runtime.

Eventually, I'll probably just write some Erlang to poll HomeAssistant (since HomeAssistant knows how to poll the thermostat with HomeKit, and HomeKit is otherwise inscrutable).


Node Red.

This will do it (though it'll require some learning and trial & error, like any worthwhile automation platform, be it HA, HomeSeer, etc).

https://nodered.org

https://community.home-assistant.io/t/home-assistant-communi...

I stupidly programmed my entire garage door auto-closer in Node Red over the course of half a day, before realizing they all come with this functionality (to be fair, my fancy automation takes the motion sensor into account so it won't close while someone is actively in the space).

Node Red is great because you can fall back to writing Javascript functions once you learn how to setup and debug event workflows.


I'm pretty sure home assistant has at least one way to find out how long it's been since there was a state change on something. In fact I know it does, because I have a toggleable control one of my outlets to limit its maximum on time.

This might get you started:

https://www.google.com/search?q=home+assistant+time+since+la...

Here's one example: https://community.home-assistant.io/t/show-time-since-last-s...

Here's another: https://community.home-assistant.io/t/get-difference-from-no...

Hope this helps!


Don't rely on this for any kind of interlocking or complex logic. They will get into an inconsistent/broken state sooner or later.

I believe the "how long since a state change" only starts counting from the state change and within the same session. If the server restarts, the counter stops and will restart from scratch only from the next state change.

This means if an automation relies on such timers to reset itself back to its idle state, a server restart will forever leave it in that state.

Automations are nice for quick one-off actions but for anything that lasts more than a few seconds I'd suggest looking for alternatives. Something as complex as managing multiple devices with interdependent states is way too complex and is bound to go wrong even if you actually manage to express it in an automation (and don't give up because of the absolutely awful automation editor UI).

Home Assistant is great as a proxy/aggregator to connect many different devices/protocols and expose them under a single, consistent API, but it's terrible at logic. For any kind of complex task I'd suggest making a stand-alone app that interacts with the Home Assistant API to observe device states and control them.


If you also have the target device hooked up to a smart outlet, you can easily reset it to known state, even if the target is IR only.


Other things with temperature stats probably worth monitoring and/or orchestrating with e.g. HA: attic fans, crawlspace fans, vents, motorized blinds, bath fans, inline duct fans,

There are recycled mining rig space heaters (that may or may not need Internet access to keep heating), pool heating immersion mining rigs, and probably also water heaters with temperature stats that might be useful in a smart home interface instead of something like Grafana.


How is your solution less overkill than using Elixr?

Less overkill in what way? file size, speed, dev-time, other?


Dev time and python3 with no dependencies, so the deployment story is as simple as Golang (since python3 is part of Debian base). iOT sensors and relays aren't complex systems compared to your average enterprise web service, and it's not like they need to scale behind a few readings per minute at most.

People are of course free to spend their time as they wish, but I'd rather solve it efficiently and move on to things I find more interesting and challenging. "Good enough" is great.


I fully endorse spending time as you wish. I do however not understand the interest in home automation. "Good enough" to me is walking over to the thermostat and changing it if I'm too warm or too cold. This is almost never. I set a temperature that I'm comfortable with and then forget it.

Same with lights. If needed, I turn them on when I enter a room. I turn them off when I leave.

In my car I can't stand "automatic" climate control. It never works properly. The best system is one manual dial for fan speed and one dial or slider for heat with an on/off for AC. Simple, reliable, and adaptable to conditions that are outside the parameters of the automatic sensors and programming.


Spoken like a true engineer.


I did something similar with Home Assistant and LIRC with a raspberry pi

https://partofthething.com/thoughts/controlling-a-fujitsu-he...


I love my smart AC, but I'm sure that smart functions will not last (or at least not without being a risk of security by unmaintained firmware) so I love these kind of projects that help you modularize the internet part.


Regarding the footnote about the temperature encoding: it seems to be Gray code


I made an arduino version of this, using an ethernet shield, and a simple infrared receiver and high-power LED, running MQTT. Some aircons actually transmit a status back, hence the receiver.


If anyone wants this without the hacking part - look at homekit compatible infrared blasters.


"Have trodden?"

If you're using verbs like "to trod" you could do better.

Also, all of the jerks here who want to say you should have used their tech stacks should STFU.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: