Home Assistant Core -- TrueNAS CORE Community Plugin

ls -al /root/.plugin/bin
total 60
drwxr-xr-x  2 root  wheel     7 May  5 00:14 .
drwxr-xr-x  3 root  wheel     3 Mar  4 02:12 ..
-rwxr-xr-x  1 root  wheel  1191 May  5 00:14 get-pip-required
-rwxr-xr-x  1 root  wheel  1354 May  5 00:14 install-hacs
-rwxr-xr-x  1 root  wheel  6281 May  5 00:14 menu
-rwxr-xr-x  1 root  wheel  5864 May  5 00:14 menu-service
-rwxr-xr-x  1 root  wheel   678 May  5 00:14 plugin-info
cat /root/.login
# $FreeBSD: releng/12.2/bin/csh/dot.login 337849 2018-08-15 14:41:24Z brd $
#
# .login - csh login script, read by login shell, after `.cshrc' at login.
#
# See also csh(1), environ(7).
#

# Query terminal size; useful for serial lines.
if ( -x /usr/bin/resizewin ) /usr/bin/resizewin -z

# Uncomment to display a random cookie on each login.
# if ( -x /usr/bin/fortune ) /usr/bin/fortune -s

set path = (${path} /root/.plugin/bin)
if ( -x /root/.plugin/bin/menu ) menu

:thinking: everything looks goods but for some reason your plugin is referencing the old menu (which should have been removed)

Lets just make sure the original location is removed.

iocage console $JAIL_NAME
# Press 0 to exit menu
rm -r /root/bin

Now if you log out of the jail, then log back inā€¦ does the menu start?

If not, can you can start it manually using the full path

/root/.plugin/bin/menu

If so, please try remove/install appdaemon again

that did the trick
thanks!!!

I might have another configuration issue: after appdaemon completed installation with the message:

appdaemon_enable:  -> YES
Starting appdaemon.
appdaemon is running as pid 25792.
http://192.168.0.35:5050


Press ENTER to continue...

I checked with option 2 :

Select: 2
appdaemon is not running.

Press ENTER to continue...

and indeed the appdaemon window does not start in home assistant
btw, just to be sure I have a fresh install, Iā€™ve deleted the appdaemon subdirectory in homeassistant so that the defaults are installed

you are awesome.

Itā€™s the only way to work on Frenas.

1 Like

So it looks like appdaemon is starting, but then it stops (this is better than not starting at all)

You can try a couple things to possibly show the cause

This will run in the foreground, showing any output from appdaemon in the console.

  • press Ctrl C to stop
iocage console $JAIL_NAME
# Press 0 to exit menu
su - homeassistant
source /usr/local/share/appdaemon/bin/activate
appdaemon --config /home/homeassistant/appdaemon

When starting appdaemon in the foreground as shown above, you should see the error.

FYI, there should also be a log file which should show the same output you would see in the console

iocage console $JAIL_NAME
# Press 0 to exit menu
cat '/var/log/appdaemon_daemon.log'

Thanks!!
The main problem was with a timezone setting in secrets.yaml not recognized by pytz.
After changing the timezone, appdaemon starts successfully (also visible from the ui panel).
However, when examining the log I see the following repeated every 5 seconds:

2021-05-06 22:08:26.982738 INFO HASS: Connected to Home Assistant 2021.4.6
2021-05-06 22:08:26.986584 WARNING HASS: Error in authentication
2021-05-06 22:08:26.987175 WARNING HASS: Disconnected from Home Assistant, retrying in 5 seconds

where do I set hte authentication?

Weā€™re getting there!

You can create a new Long Live Access Token under your user profile in Home Assistant. The Appdaemon docs have a great example if youā€™re unsure what Iā€™m talking about.

When you have created the access token, add it to the (Home Assistant) secrets.yaml

appdaemon_token: "PASTE_LONG_LIVED_ACCESS_TOKEN_HERE"

yes indeed! we are definitely getting thereā€¦
thanks for your help!!!
the problem was that somehow with reinstallation the long lived token got ā€œmessed upā€

While going over the home assistant logs, I noticed the following (unrelated) error message:

Logger: aiohttp.server
Source: /usr/local/share/homeassistant/lib/python3.8/site-packages/aiohttp/web_protocol.py:393
First occurred: 5:31:28 PM (8 occurrences)
Last logged: 5:32:02 PM

Error handling request
Traceback (most recent call last):
  File "/usr/local/share/homeassistant/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 314, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 546, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'invalid HTTP method'"

any clue what could be the cause of this error?
is there any way to increase the debug level or run home assistant interactively to trace the source of the error?

Iā€™m not sure about this oneā€¦

Yes, I think you will find the Home Assistant logger most relevant

This is similar to the previous commands for appdaemon

  • You may still need to increase the logging level
  • You should stop the service before starting HA in the foreground
iocage console $JAIL_NAME
# Press 0 to exit menu
service homeassistant stop
su - homeassistant
source /usr/local/share/homeassistant/bin/activate
hass --config /home/homeassistant/homeassistant

I increased the log level to info, but I did not see anything useful in the log arround the error message
Then I increased the log level to debug and ā€œdrownedā€ in messages, but Iā€™ve found the ā€œculpritā€:
The message is between a series of ā€œdiscoveryā€ messages of the LocalTuya integration
Iā€™ll raise an issue in the repoā€™s github page

on an unrelated note, is there a template for ā€œverifiedā€ scenes/automations? by verified, I mean that the script not only issues a command but also checks that the appropriate state has changed. For example check that light was turned on/off, or wait and check that shutter/blinds were opened/closed. In the event that the state has not changed, repeat (and rinseā€¦) once or twice finally raise an alert.

The aiohttp error turned out to be related to port forwarding rule I had left in previous attempts to create external access (duckdnsā€¦)
I might try to revisit this later, but now that my configuration is working without errors I am seeking stability, and I want to be able to restore my configuration should something ā€œbreakā€ in the future
I followed your instruction to create an external dataset and mount it in the jail
The missing piece in the puzzle is how do I create routine backups so that I can use them as restore points (otherwise what is the point of the external dataset?)

btw, what about backip up node-red and esphome as well?

Generally speaking, thereā€™s nothing specific to Home Assistant here.

Snapshots

Keep in mind, these are zfs snapshots proved by the zfs file system itself. This is not the same thing as snapshots you might here mentioned with Home-Assistant OS / Supervisor

I also made a blueprint for taking snapshots from Home Assistant (using TrueNAS API). Honestly, this is more proof of concept and could be greatly improved. Thereā€™s a few steps involved so it must be created manually.

Even if you never took a snapshot or made some other backup, you config is at least separate from the jail. If the plugin failed, it can just be destroyed and recreated. After reinstalling, you simply add your mountpoint to the new plugin and configuration is restored.

Personally, I only ran the Plugin UPDATE, which to my understanding is basically the same as running pkg update && pkg upgrade. In addition, Plugin UPDATE will also update the scripts I proved in the overlay (like the console menu). When the jail RELEASE needs upgraded, from 12.1 ā†’ 12.2 for example, I would just re-installed the plugin.

Keep in mind TrueNAS SCALE is coming later this year. I suspect most people using this plugin will be migrating at some point in the future. Having your pluginā€™s configuration on a separate dataset will make this much easier. In fact, Iā€™ve already installed the latest ALPHA version of SCALE on my main server. Using docker-compose with macvlan, I managed to bring everything back up without a glitch. (I should mention, using docker-compose on SCALE is not officially supported)

From inside the jail, you may find the config in the following locations

  • ESPHome ā€“ /var/db/esphome
  • Node-RED ā€“ /var/db/nodered

Itā€™s basically rinse and repeat for these or any other plugins - You can make a separate dataset, copy the configuration to it, then add that dataset as a mount point back to the jail.

In my opinion, a key feature missing from the iocage plugin system, is the ability to mount an external dataset during installation.

@troy,
Do you use Zigbee and, if so, what integration do you use, please?

I do own a few Zigbee devices but Iā€™m primarily a Z-Wave user. For the few Zigbee devices I do own, I have always used the built in ZHA integration

I canā€™t add integration Z-Wave JS
image

what is URL
try IP but get error same

Hi @dasis

The URL should be set to the IP address of your Z-Wave JS server ā€“ That is the IP of your Z-Wave JS to MQTT jail

Also if your using Z-Wave JS to MQTT, youā€™ll need to enable the Z-Wave JS server in the settings before Home Assistant can connect

@troy
Thank you for this great plugin for TrueNAS.
Could you explain how to upgrade a HACS installation?
By typing ā€œinstall hacsā€ in Console Menu I get ā€œHACS is already installedā€ and ā€œerror expecting empty directoryā€
Thanks

1 Like

Hi @tebra

HACS is a custom integration. Using ā€œinstall HACSā€ from the menu is basically a one time command for easy installation.

Once installed, you can update HACS from the UI in Home Assistant, similar to updating any component (installed with HACS). For example I have update available for Circadian Lighting. If there was an update for HACS it would show up here as well.

1 Like

@troy
Is it possible to use Zigbee2MQTT with HA on this TrueNAS jail?
If yes, any officially USB adapter will works?
Thanks for your reply

Yes it should work. I would recommend installing Zigbee2MQTT in a separate jail. Someone else has already made TrueNAS plugin that can be installed using the CLI (I have not tried it myself though)

Yes I believe so

1 Like