Migration from OpenHAB to HA

Hi, it’s my first post here but I have briefly tried HA with docker installation and are considering to migrate from OpenHAB to HA for the following reasons:

  1. HA seems to be more actively developed with larger community
  2. Matter support - for sure important for Apple users, OH still doesn’t have a concrete plan on matter support
  3. Better HomeKit support, including integration to native Homekit devices, I have some IoTs which only support HomeKit
  4. UI and app on iOS also looks better

Given that said, there are also many things I’ll miss in OH, and I’m still new to HA so I’d like your input on whether HA provides similar features and where to look/read:

  1. With OH I have most configurations of Things/Items/transformations/Rules as text files and it’s easier to version control them and backup, does HA also allow pure text configuration for everything?
  2. OH has very good IDE support so I can develop rules/configurations in Visual Studio Code with syntax checker, auto completion and live values from OH server, does HA have something similar?
  3. I’m a developer so I prefer to define automation rules in code - it is also because I have some more complex automation which I think easier to manage in code. What are my options of automation in HA if I want to develop complex logic in code?
  4. Anther thing I’m heavily relying on OH is the persistency, with the default RRD4J I can keep a long history of time series without worrying about disk space. I mainly use persistency for 2 things: charting and rules. OH has a very good support for charting so I can plot item values to find correlations etc with just simple configuration. Another important use case of persistency is in rules, where I sometime need historic value to control the logic of my rules. For example I have rules that check if there is any water leakage by comparing the current reading to previous day. A more complex example, I use persistency service in rules to calculate threshold of electricity price based on historical movement, I’m looking at min, max, avg and std deviations which is very handy. Does HA has support for historical value and I can use them for charting and automations?
  5. Stability - OH is a super complex system to get it right, however once it works it’s very reliable, what’s your experience with HA in terms of stability and reliability?
  6. OH app allows both local and remote connections for free, I read HA remote connection through HA cloud isn’t free, is there other alternatives? How about push notification?

I have seen many migrated from OH and HA, and I appreciate if you could give me some hints/suggestions on the what/how and best practices.

Hi, and welcome to the HASS community,

I parallel ran openHAB and HASS for a year, rewrote automations, then moved over several years ago so know exactly the switch from Java(ish) to YAML. I still kind of miss complex tech posts from rlkoshak on the forums!

Top Tip Parallel-Run openHAB and HASS using one MQTT broker for both platforms. Publish from one to the other where needed.

Since then, HASS has become much easier to configure with many areas auto-configuring (something I first hated in openHAB - now love), or GUI.

  1. HASS does use several YAML ‘text’ files for config, however some elements are in a database. That’s not really an issue as HASS backups are TAR files of the raw config - add .tar to the and and you can extract individual files.
    The database-stored config tends to be stuff that is automated - e.g. discovered, created, so all you’ve done is add a location or name.
    If you really want to run a git blame, there are add-ons to sync backups and config to external media. Personally, I used to SCP automations.yaml & configuration.yaml but stopped once the config was stable.

Top Tip: I remember an openHAB presentation where MQTT auto-discovery was discussed and I was horrified at the potential removal of text file config.
I was VERY wrong!
The difference is:

  • openHAB uses a nest of complex text files to configure MQTT, full of syntax nasties (I used to have nightmares over adding RSSI to all devices :slight_smile: ).
    Device: simple; HA: very hard
  • HASS uses Auto-Discovery or Tasmota Discovery. Configure the DEVICE once with Friendly Name 1 and Device Name, and this IMMEDIATELY creates entities in HASS. More entiries exist than are displayed (e.g. RSSI is there, just not in the GUI, unless you want it)
    Device: harder; HA: automatic

(I’ve written custom devices in Python using HASS Discovery and it works well. I’ve written several posts on here going into the details of Python, Tasmota config, and ESPhome with discovery.)

Top Tip: If you use the Tasmota alternative ESPxx firmware, it moved away from HASS Discovery to Tasmota Discovery . Read up on SetOption19=0.

  1. Yes. There is a Studio Code Server, but I just use Add-Ons for Terminal & SSH and File editor (has basic completion and syntax checking in the browser, terminal copy-paste needs SHIFT pressed).

Top Tip: Use the interactive web-based tools in HASS to learn, prototype and debug. The Developer Tools tab has a lot to explore - just start searching. Template tab can be very useful to add complex extraction into YAML automations.

  1. YAML is typically significantly easier than the various rules engines in openHAB. It is different, more even driven and sometimes needs templating for text transformation. There are ways to write in Pyton, etc, but honestly, YAML works for me.
    One light automation in openHAB was 60 lines long - I achieved the same in 10 lines of YAML due to the event model and flipped logic.

Top Tip: YAML is based on indentation, which can be a PITA to spot errors. Use 4x spaces, expand tabs (yuck!), and if all else fails, copy-pasta the YAML into a web YAML linter to spot where you’ve missed something.

Top Tip: Use the GUI to create an automation FIRST to get the basic logic, then edit it as you need. Let the tool get the syntax right!

  1. Yes - HASS has long-term statistics with functions to extract and graph (like filter functions). ISTR some are add-ons in HACS (a community add-ons store).
    Some folks use a custom database for long-term stats but DON’T - you’ll end up with 4TB of raw rows that will eventually prevent you from updating (e.g. a good index optimisation that takes DAYS to complete as you’ve too much junk data).
    HASS summarises into 60minute (ISTR) after 10 days which is fine for me.
    You can get to the database to edit/ extract/ query if needed, the DB code keeps getting optimised (good extra indicies!), and the graphing is also regularly improving.

Top Tip: If you really want your old stats code to keep going, use MQTT and a trigger to publish values from HASS into MQTT / custom shell code.
There is also a RESTful API.

  1. HASS >> openHAB in reliability. I use a Yellow, which is basically a RPi4 with a SSD, but some use a SFF Intel box. The key difference is to understand HASS is the application, but HAOS includes the OS and update tooling. HAOS is very easy to admin, but is welded shut (unless to turn on dev mode). so some folk run a VM and manage it themselves.

Top Tip: If you want 100% availability, buy a pre-production test platform. A second RPi4 is cheap and gives you somewhere to test and experiment. It is also a cold spare…

  1. HASS has the same options as anything else - roll-you-own network, VPN, TailScale, SD-WAN, reverse-proxy, etc. Personally, I pay NabuCasa to fund development and make the remote access very easy. Push notifications to phone apps work as long as you have a network (email or other app connectors also work).

I often pepper my posts with links to docs, but basically, read the HASS user docs, then read the HASS developer docs, then search the forum.

Oh, and subscribe to the monthly HASS release party videos - an hour of time that basically has the developers explaining WHY change was made. Very useful.

If you’re doing complex stuff, keeping an eye on the dev blog can also be useful for detailed change notifications.

And yes, ask me!

If this helps, :heart: this post!

1 Like

Hi James, thanks a lot for the detailed reply! Hope you don’t mind some follow up questions.

Top Tip Parallel-Run openHAB and HASS using one MQTT broker for both platforms. Publish from one to the other where needed.

Do you mean to use MQTT as a bridge between the 2 platforms during migration? So basically I should first migrate the integration to IoTs to HA while keeping the OH rules (OH receives data from HA instead), right?

I’d like to learn more about automation possibilities in HA. I have read the documentation but seems I can only do IFTTT styled simple automation. What other options do I have if I want to get the full power? For example I need to do delays, loops, and query historical data, I assume it’s not possible to do all with yaml?

It would be very interesting to hear as an example if you don’t mind to share.
Once again thanks for sharing your experience!

Do you mean to use MQTT as a bridge between the 2 platforms during migration? So basically I should first migrate the integration to IoTs to HA while keeping the OH rules (OH receives data from HA instead), right?

Sounds right, but to be more epxlicit…

  • openHAB has a MQTT broker
  • Add HASS, add the MQTT add-on, connect HASS to the openHAB broker
  • Get MQTT devices working in both openHAB and HASS (e.g. Tasmota, Arduino, etc).
  • Port over automations openHAB → HASS
  • For non-MQTT devices like Z-Wave, migrate to HASS, but where openHAB still has functionality, use HASS to trigger an automation on <thing> and publish <thing> into MQTT for openHAB to use
  • Switch from a openHAB broker to a HASS broker
  • Turn off openHAB (if needed)

I’d like to learn more about automation possibilities in HA. I have read the documentation but seems I can only do IFTTT styled simple automation.

We could be here a while! :slight_smile: :mage:

For me, openHAB tended to encourage blocks of code with complex logic and local variables. HASS is more event driven, more asynchronous, so complex logic is broken down with templates, helper functions, and background processing maintaining shared state. Does the difference between Java and JavaScript make any sense?

e.g. One automation is an alarm clock:

  • ON/ OFF is controlled by a input_boolean.alarm_clock (like a GUI switch with a global state variable)
  • The date is converted to a form for TTS once using a trigger (docs) ; (code and good thead)
  • The automation is fired from a time pattern, and uses the other states.

delays

delay:
  hours: 0
  minutes: 0
  seconds: 40
  milliseconds: 0

loops

repeat:
  count: 2
  sequence: []

or use a template as a counter, do while?

Try the automations GUI - the examples were 10S hacks via edit in YAML.

query historical data

Not something I typically do, but there are template functions to perform calculations which can get complex with layers of IF THEN ELSE (random recent example).

I’ve seen stuff from Bayesian sensors to filters creating derived sensors from “dirty” primary data.

Try searching the forum as there’s a lot in here (two random examples using a template and SQL):


What other options do I have if I want to get the full power?

Look in HACS (a community add-ons store) for the sharper and more dangerous tools! These range from Spook (useful general toolbox hobby project from a core developer), to unmaintained code that might explode, but does something very clever.

Then use HASS as an API via MQTT, REST, webhooks, SSH, etc.

I probably should call out the “20 things” thread as it is quite good:

If this helps, :heart: this post!