Home Assistant Core -- TrueNAS CORE Community Plugin

@adorobis - Can you test this please

iocage console $jail_name
# Press 0 to exit menu

ee /usr/local/etc/rc.d/homeassistant

I’m not sure which line in your version, but it should be near the top of script, in the homeassistant_prestart() function…

Please find and edit the following line to add -r as shown below.

rc_flags="-f -o ${logfile} -P ${pidfile} -p ${pidfile_child} -r ${HA_CMD} ${HA_ARGS}"

PS sorry , i just fixed that first command if you didn’t figure what I meant

1 Like

I think I will play it safe for the plugin’s rc script and still go with -R restart_delay_seconds

I’m just gonna an add a new rcvar homeassistant_restart_delay with a default 1 second delay. That way if a longer pause is needed we can set it without editing files

For example to set a 3 second delay

sysrc homeassistant_restart_delay=3 
1 Like

No worries, I’m editing via WinSCP and notepad++

Looks like it works ok also when restarting via GUI
Interesting observation: seems that the deamon is not really being restarted as the PID did not change when restarting via GUI. It always changes when restarting the service from command line.

1 Like

OK… I’ve updated the plugin again. :crossed_fingers:

1 Like

Thank you once again troy, you are a ripper.

1 Like

Thanks @troy
Your support is superb.

btw, on the github page people mentioned that they used snapshots to roll back to a previous, working version.
Is there a description page how to setup snapshots for this plugin and how to use them to roll back?

1 Like

So snapshots aren’t specific to this plugin. They’re a zfs thing.

Here’s a link to the general TrueNAS docs on the subject

https://www.truenas.com/docs/core/storage/snapshots/

Also when you run the Plugin UPDATE, TrueNAS will automatically take a snapshot of your jail

There’s also an old wiki page with a quick how to manually snapshot and restore using the command line

And there is a wiki page with a blueprint to trigger snapshots from Home Assistant. It’s not as straightforward as normal blueprints and it never really went anywhere… I think it still works though

First and foremost, let me be clear… Home Assistant has never supported FreeBSD. We’ve been lucky it just works (most of the time) – Those of you who follow along know that I’ve already switched my server to TrueNAS SCALE and I’ve been on the fence about what to do with this plugin ever since.

Obviously the Home Assistant 2022.02 update caught us completely off guard with a breaking change. And while there was (is) a simple fix this time, it was only by pure luck I happen to be sitting home and able to push an immediate update for the plugin. Next time I may not be able to respond as quickly so I’ve added the following warning to all TrueNAS CORE plugins I maintain.

:warning: This plugin is not actively maintained – At this time I am no longer using TrueNAS CORE or any iocage jails. As a consequence I may not be aware of, and proactively fixing any issues that could arise. If you’re having trouble with the installation of this plugin you can still open an issue and I will do my best to help. While no further development is currently planned, I will continue trying to support this plugin for as long as it remains feasible.

That list includes the following Home Assistant related plugins

  • Home Assistant Core
  • ESPHome
  • Mosquitto (mqtt broker)
  • Node-RED
  • TasmoAdmin
  • Z-Wave JS 2 MQTT

Really appreciate your work! I’m also considering to upgrade/switch to Scale, most likely once it will be officially released. The most important for me will be to smoothly migrate various jails, I have no problem with setting it up from scratch but making sure that the data is migrated e.g. mariadb, influx, plex. I’m quite confident that HA will be the easy one :slight_smile:
Would be great if you could share your experience with migrating those plugins to Scale

1 Like

I could, but it’s not the typical user experience because I’m using my own script to enable Docker without using the SCALE apps system, which is Kubernetes based. For most users switching to SCALE, it is recommended to either use TrueCharts or create a VM running Linux and host docker from there (which is also an option on TrueNAS CORE).

I switched to SCALE about the alpha release. Initially I was involved with TrueCharts but I have no understanding of Kubernetes. For a while I was trying to learn but with less free time I had to give up.

At that time TrueCharts was still in it’s very first days and the apps I needed were not yet available. I also found using docker and docker-compose was trivial compared to understanding Kubernetes and trying to make a Scale app.

Once I decided to just use docker, it only took about 30 minutes to get all my previous jails running as containers. I also opted to use macvlan so I could assign each container it’s own ip address matching what had previously been used by the corresponding jail. Also using macvlan, Home Assistant discovery works without setting --network=host - I have configured the macvlan driver to use a secondary NIC on my server, which is configured on my switch to be a seperate vlan.

Click to see my docker-compose
version: '3.7'

networks:
  lan:
    driver: macvlan
    driver_opts:
      parent: eno2
    ipam:
      config:
        - subnet: '10.10.1.0/24'


services:

  emby:
    image: emby/embyserver:latest
    container_name: embyserver
    environment:
      - UID=1000
      - GID=1000
      - GIDLIST=107,44  # getent group [video,render] | cut -d: -f3
    devices:
      - /dev/dri:/dev/dri # VAAPI/NVDEC/NVENC render nodes
    volumes:
      - ./emby/config:/config
      - /etc/localtime:/etc/localtime:ro
      - /mnt/media/emby/audible:/media/emby/audible
      - /mnt/media/emby/movies:/media/emby/movies
      - /mnt/media/emby/music:/media/emby/music
      - /mnt/media/emby/tvShows:/media/emby/tvShows
    networks:
      lan:
        ipv4_address: '10.10.1.13'
    restart: unless-stopped

  esphome:
    image: esphome/esphome:latest
    container_name: esphome
    stop_signal: SIGINT
    volumes:
      - ./esphome/config:/config
      - /etc/localtime:/etc/localtime:ro
    networks:
      lan:
        ipv4_address: '10.10.1.21'
    restart: unless-stopped

  gogs:
    image: gogs/gogs:latest
    container_name: gogs
    volumes:
      - ./gogs/data:/data
      - /etc/localtime:/etc/localtime:ro
    networks:
      lan:
        ipv4_address: '10.10.1.11'
    restart: unless-stopped

  homeassistant:
    image: homeassistant/home-assistant:stable
    #image: "ghcr.io/home-assistant/home-assistant:stable"
    container_name: homeassistant
    volumes:
      - ./homeassistant/config:/config
      - /mnt/media/emby/music/google:/media
      - /etc/localtime:/etc/localtime:ro
    networks:
      lan:
        ipv4_address: '10.10.1.18'
    restart: unless-stopped

  mosquitto:
    image: eclipse-mosquitto:latest
    container_name: mosquitto
    volumes:
      - ./mosquitto/config:/mosquitto/config
      - ./mosquitto/data:/mosquitto/data
      - ./mosquitto/log:/mosquitto/log
      - /etc/localtime:/etc/localtime:ro
    networks:
      lan:
        ipv4_address: '10.10.1.16'
    restart: unless-stopped

  zwavejs2mqtt:
    image: zwavejs/zwavejs2mqtt:latest
    container_name: zwavejs2mqtt
    tty: true
    stop_signal: SIGINT
    devices:
      - /dev/serial/by-id/usb-0658_0200-if00:/dev/ttyUSB0:rmw
    volumes:
      - ./zwavejs/store:/usr/src/app/store
      - /etc/localtime:/etc/localtime:ro
    networks:
      lan:
        ipv4_address: '10.10.1.14'
    restart: unless-stopped

We are about to enter our busy season at work. When we slow down again towards summer, I plan on taking another look at TrueCharts but next time will be as a regular user.

Many thanks for sharing your script and docker-compose files!
I’ve started to play a bit with SCALE and the TrueCharts and I must say that it is way more complicated than jails. I’m afraid I won’t have time to make it work easily…
Your approach with docker-compose is so much easier, I’m just wondering if there could be any breaking changes in future TrueNAS releases that would make this option not possible anymore.
I’ll still play a bit with TrueCharts before making final decision.
Btw, based on your work so far on TrueNAS Core 13, do you see any major problems with it? There are a few people using it so maybe we could take it over/fork it and continue maintenance for future releases?

One last question: did you have to do anything special to enable networking for the docker containers? For me the containers can’t talk to external services neither I can connect to them whe using this macvlan network. I could connect to them with host network but it has other limitations e.g. mDNS does not work I think.

Well just installing any single app is stupid easy – Basically you give it a name and click next a bunch of times. But anything beyond that, the TrueCharts team considers an advanced set-up and some existing knowledge, research on your own, etc… is expected. At that point, you’re learning about Kubernetes and I agree, it seems overwhelming. That’s exactly why I’m just using docker-compose (at least for now)

This is absolutely a possibility and definately a risk that needs to be considered. I figure (and I’m just guessing) the worst case could be that docker is removed in a future update. This could be a real hassle if your not prepared, but TrueNAS is only updated a few time a year. My plan is just to check release notes before each update… If I see something to indicate that docker may be removed, I’ll just hold off the update until I either build another docker host or possible just move everything to a VM on SCALE.

No, but I’ve only tested the installation of my plugins is working… Home Assistant was failing to install on FreeBSD 13.0 with a permission error, but I’ve already fixed that.

Absolutely, and I would still try to contribute and help out when I could. For the most part, maintenance at this point should mainly be bumping the python version every year. Having to make sudden changes to this plugin to fix installation issues doesn’t really happen very often.

According to Home Assistant Analytics, there are only about 7,000 installs of Home Assistant Core to begin with. I doubt we make up any significant portion of that. Based on the spike of what I assume to be updates made after Home Assistant 2022.2 release, I’m guestamating there are between 50-100 people who might be using this plugin.

No - I’m just using macvlan, that’s it. I can reach Home Assistant for example using http://ipaddress:8123 just like my jails. And when connecting to the ZWaveJS2MQTT websocket, I can use either ws://ipaddress:3000 (over macvlan) or ws://zwavejs2mqtt:3000 (internal docker network) And far as I can tell, discovery is working as well. At least my ESPHome devices are detected when I switched everything from Tasmota.

I think I saw something on the forums that TrueNAS SCALE does something to actively block mDNS other than it’s own - Honestly, I think the only reason it’s working for me is because I’m using macvlan.

Did you just copy/paste from my compose file, or did you edit the network section to match your own network and set the ip for each container accordingly?

Yeah, I’ve noticed that after my first attempt on discord :slight_smile:

I’ve also came across some discussions about problems with networking even in your docker-compose scenario which required some additional docker.json file entries. Specifically to add two more entries there:
'iptables': True, 'bridge': ''
but that did not solve my problem.

I’ve updated the network section accordingly but maybe I’m doing it wrong? I have only one network adapter so I’ve set it up to use the same address range as my LAN. I’m not a networking expert (rather a noob). Here is my docker-compose.yaml file. My network is 10.144.1.0/24, gateway is 10.144.1.1, TrueNAS Scale ip is 10.144.1.40. DHCP is not assigning addresses between .1 and .50 - I’ve reserved it mainly for various virtual devices e.g. jails etc.

version: "3.7"

networks:
  lan:
    driver: macvlan
    driver_opts:
      parent: eth0
    ipam:
      config:
        - subnet: '10.144.1.0/24'

services:
  esphome:
    image: esphome/esphome:latest
    container_name: esphome
    stop_signal: SIGINT
    volumes:
      - ./esphome/config:/config
      - /etc/localtime:/etc/localtime:ro
    networks:
      lan:
        ipv4_address: '10.144.1.41'
    restart: unless-stopped
    
  homeassistant:
    image: homeassistant/home-assistant:stable
    container_name: homeassistant
    volumes:
      - ./homeassistant/config:/config
      - /etc/localtime:/etc/localtime:ro
    networks:
      lan:
        ipv4_address: '10.144.1.42'
    restart: unless-stopped

Am I missing something obvious?

are you sure it’s not

      parent: eno0

What your docker network ls

Here’s what mine looks like

ce30de6b259e   apps_lan   macvlan   local
9f3ce694d8fa   bridge     bridge    local
f96faaf76d16   host       host      local
69e3dc95b399   none       null      local

Have you enabled, or set a dataset for the scale apps once already. I know that disables some docker networking because it is not compatible with kubernetes.

If it’s a test machine or VM, can you try reinstall SCALE and just go straight to using docker-enable script. Do not ever set a dataset for the scale apps

Pretty sure:

The only difference is that my macvlan network name is docker_lan:

NETWORK ID     NAME         DRIVER    SCOPE
f8e616052396   bridge       bridge    local
72f2eb59b8e0   docker_lan   macvlan   local
9a752bb77e00   host         host      local
8a856dd8c215   none         null      local

Yes I did. Later I’ve removed the dataset it disabled the kubernetes and I was able to use docker.

It is a VM on my desktop. Funny how fast it is compared to the low power NAS :slight_smile:
Thanks for suggestion, I’ll give it a try, let’s see the result.

By any chance is it VirtualBox? If so, be sure to set Promiscuous Mode: Allow All under network. This is Linux version of VirtualBox but it should be similar on Windows. I don’t know about Mac

Freshly installed TrueNAS SCALE, the only thing I’ve configured was the static IP for the server and data pool and dataset for docker. docker network ls:

64eab09a555a   bridge       bridge    local
7454f3e281da   docker_lan   macvlan   local
b1cfb2e8ffec   host         host      local
2a107742e057   none         null      local

Still the same effect. I cannot access the container from outside, neither from the server nor from any other device on the LAN. The app running in container cannot access external network either, esphome immediately returns the following error:

homeassistant    | 2022-02-15 13:11:04 ERROR (MainThread) [homeassistant.components.updater] Error requesting Home Assistant update data: Cannot connect to host www.home-assistant.io:443 ssl:default [Try again]

Are you just testing with default configuration of Home Assistant?

Running out of ideas, I think we are seeing why this is not supported.

Here’s my SCALE network config – I test apps on my primary NIC and everything still works. Maybe you can notice a setting here, that can help

The only other difference I can think, but shouldn’t matter… I manage all IP address on my router, so everything (except containers) uses DHCP

PS I’m using Pi-Hole with unbound, that why I have local address for DNS

Yes, default HA setup - just clean after docker install. Same with esphome. I have not tried others yet.
Yeah, I’ve tried both DHCP and the static addresses for TrueNAS Scale. I’m using adguard as my DNS.
This promiscuous mode makes me think that there might be something wrong with the VM config - I’m on HyperV as my VirtualBox stopped working. And there is no such setting in HyperV (I’ve found some command line configurations but I’m not even sure it this is the same thing).
Maybe I’ll fix VirtualBox first to reduce number of variables… Or maybe even install TrueNAS on bare metal (but that would mean switching back and forth on my desktop) on some spare drive.
Anyway thanks for all your suggestions, I can see that Scale will burn some more of my time… I’m so happy with the Core set up, everything so easy in jails :slight_smile:

1 Like