Controlling TrueNAS CORE using Home Assistant

Disclosure: This post contains affiliate links. If you click through and make a purchase, I will earn a commission, at no additional cost to you. Read my full disclosure here.

A digital illustration of a futuristic server room.
Update: Dec 21, 2019

Correcting the code: Updated examples for a seamless setup

It has come to my attention that the previously provided code examples contained an error. I understand the frustration this may have caused. Fear not, for we have revised and updated the examples to ensure a smooth setup experience for you. Simply follow the instructions below, and you'll be on your way to a flawless execution.

As well as housing my Home Assistant on a Proxmox VE application server, I also have a NAS (Network Attached Storage) device serving as a repository for a variety of media, including archived photographs and an array of scrumptious recipes. For now, my NAS runs on TrueNAS CORE, an operating system I plan to stick with despite its shortcomings.

A noisy NAS requires manual control

My existing TrueNAS CORE NAS leaves something to be desired. Built on a budget, I opted for the most cost-effective case and installed only the most essential hardware. Consequently, it's far from quiet, and the lack of sound dampening means it can be rather noisy when writing data. Since it's situated right next to my sleeping quarters, it's impractical to leave it running around the clock.

Integrating Home Assistant and TrueNAS CORE for seamless control

Enter Home Assistant, the solution to my remote NAS control needs. Given that my TrueNAS CORE server is perched on an inconveniently high shelf, I required a method to switch it on and off without physically reaching for it.

To achieve this, I'm utilising the TrueNAS CORE API to initiate a system shutdown via Home Assistant. Powering up the TrueNAS CORE is a breeze, courtesy of Home Assistant's Wake on LAN (WOL) integration. Without further ado, let me demonstrate how to use the WOL switch to instantly turn on your TrueNAS CORE.

Waking up TrueNAS CORE with Home Assistant

Before diving into the process, it's essential to have a firm grasp of both Home Assistant and TrueNAS CORE. To set up the Wake-on-LAN (WOL) switch, you'll need the IP and MAC address of your TrueNAS CORE machine. Although the IP address is optional, it's likely that you're already aware of it.

To discover your MAC address, simply type ifconfig in the TrueNAS CORE shell and search for hwaddr. The IP address is used by Home Assistant to determine whether your TrueNAS CORE machine is powered on or not. If you're planning to use the switch in the user interface, it's highly recommended to include the IP in the configuration.

With the MAC and IP addresses at your disposal, add the following entry to your configuration.yaml file to create a switch that enables you to power on your TrueNAS CORE machine:

  - platform: wake_on_lan
    name: "TrueNAS CORE"

Remember to replace “YOUR_MAC_ADDRESS” and “YOUR_IP_ADDRESS” with the appropriate information for your TrueNAS CORE machine. This configuration will establish a WOL switch, providing you with the ability to power on your TrueNAS CORE system with ease through Home Assistant.

Shutting down TrueNAS CORE using Home Assistant

Shutting down a TrueNAS CORE system using Home Assistant can be slightly more complex. There is no option for reverse WOL or similar functionality, and no standard method for handling shutdowns. Therefore, I have chosen to use the TrueNAS CORE API. To make the API call, you can create a REST command that includes the following details:


  url: http://IP-OF-YOUR-TRUENAS-CORE/api/v1.0/system/shutdown/
  method: post username: !secret truenas_core_user
  password: !secret truenas_core_password
  headers: content-Type: application/json

As you might have noticed, I’ve used the secrets.yaml file to store my credentials. I had to use root to get this API call to work. There might be a nicer and safer way of doing this. To accomplish this, simply open the secrets.yaml on your Home Assistant server and enter the following on a new line:

truenas_core_user: YOUR-ROOT-USER
truenas_core_password: YOUR-PASSWORD

Tying it all together in one switch

With the TrueNAS CORE RESTful Command complete, it can be added to the switch that was created earlier. To accomplish this, simply append the “turn_off” variable to the end of the switch’s configuration, as shown below:

  platform: wake_on_lan
  name: TrueNAS Core host: YOUR-TRUENAS-CORE-IP
  mac_address: "XX:XX:XX:XX:XX:XX"
  turn_off: service: rest_command.truenas_core_shutdown

And there you have it, TrueNAS CORE can now be controlled by Home Assistant. This switch can be used in automations using switch.turn_on, switch.toggle, and switch.turn_off and can be placed in the UI.

And that’s it, you can now control your TrueNAS CORE machine using Home Assistant. This switch can be integrated into automations using commands such as “switch.turn_on”, “switch.toggle”, and “switch.turn_off”. You can also add it to your Dashboard for manual control.

A portrait photo oif Liam Alexander Colman, the author, creator, and owner of Home Assistant Guide wearing a suit.

About Liam Alexander Colman

is an experienced Home Assistant user who has been utilizing the platform for a variety of projects over an extended period. His journey began with a Raspberry Pi, which quickly grew to three Raspberry Pis and eventually a full-fledged server. Liam's current operating system of choice is Unraid, with Home Assistant comfortably running in a Docker container.
With a deep understanding of the intricacies of Home Assistant, Liam has an impressive setup, consisting of various Zigbee devices, and seamless integrations with existing products such as his Android TV box. For those interested in learning more about Liam's experience with Home Assistant, he shares his insights on how he first started using the platform and his subsequent journey.


    • That’s great to hear! I don’t use FreeNAS anymore so thanks for confirming that this still works😊


Leave a comment

Share to...