Introducing ... TheSillyHome , a Homeassistant Machine Learning (AI) Addon

I don’t use the Home Assistant Supervised version
but I use this version of Home Assistant Core, so I didn’t add it like you

Hi @lotohov
Apologies for the late reply - am currently out enjoying the sun in Gran Canaria!
The table I need is the “states” table.

You can use sqlworkbench or equivalent to do it!

Thanks,
Chris

Hi @Cao_Hoa
Thanks for expressing interesting in the project and I’ll try my best to support you.
The main reason for the lack of support for other installations types is that I personally don’t have those setup so it will be quite difficult for me to test it out.

Let me know if you any success converting this to a container but feel free to add a enhancement request onto the Github Repo for this.

@Nova
interesting. I also run HA in docker so addon wont work.

i notice you load the appdaemon app into your ai image. Are you building an instance of appdaemon on your image itself?

I run appdaemon on a separate container, So I can add the app in the normal appdaemon insstance. Is this app designed to communicate with your image/python script?

I’m an enthusiast with some docker knowledge, so looking at your repo your dockerfile is already there. Would creating the app in appdaemon separately and building your image without it work?

Thank you

Hi @juan11perez
Thanks for taking interest!

  1. The addon runs pip install appdaemon and also cp appdaemon /appdaemon to copy over the configuration.
  2. You can indeed add the app but you will also need to pip install thesillyhome for the data extraction and sklearn training.
  3. It probably doesn’t work straight out of the box. The reasoning to choose this path (instead of a pure appdaemon app) was that I thought addon installation is just much easier. It would be good if you can give me examples of addon repos that also has support for docker installations. I can try to build support for this.

@Nova thank you for your response.
Not sure if I’m missing it, but I dont see pip install appdeamon in the dockerfile.
I also noticed in some files it needs maria db. I think instructions need a bit more detail.

There’s popular addon for face recognition/identification called doubletake.
It started as a docker only and he subsequently developed the addon.

1 Like

Thanks for the example will take a look at it.

It should only require a sql-like db. I can definitely always add more details on the setup!!

The appdaemon install is from the requirements.txt under thesillyhome/requirements.txt at 028dad3ad3675c2f3fd6572a666fee7d005b6335 · lcmchris/thesillyhome · GitHub . Definitely not a good place to put it :blush: . Will see the best way to make this work for everyone.

Aim to publish something by next week! Keep an eye out.

thank you very much for considering it.

Hi @juan11perez @Cao_Hoa
Just to update that I’m in the middle of changing the structure of the repo and making it into a standalone docker container. Much thanks for sharing double-take! To do this I also had to add a frontend so that the config can be added easily (which is why its taking a bit of time).

I do see the benefit of having this as standalone docker now ::

  1. as Pi will probably not be able to handle training models once the dataset gets large or once fancier models are used. Great suggestion!
  2. Easier development as I can test the results much quicker with a lighter weight image.

I am also going to make thesillyhome python package install locally in Docker (rather than pypi), just to make my life easier for now on the deployment side.

Should be ready by Friday for you guys to test!

2 Likes

Thank you for considering the feedback and your efforts.

1 Like

Thank you for building a standalone docker project

1 Like

Hi @juan11perez and @Cao_Hoa ,

I’ve created the container repo here.

Unfortunately nothing really works yet with the new setup but it would be awesome if you guys could at least test out the docker-compose .
It should at least:

  1. Start a node server listening on port 2300. You can access it on localhost:2300 but nothing on it works. I am a frontend noob to trying to get grips with how I can use it to trigger sh, py scripts, edit config and such.
  2. Kicks off the processing but the default config is set to my instance (so should error out for you). You can try to edit the hesillyhome_src\data\config\options.json file with your instance. What is the best way to keep the config sustained through different docker runs?

Any advice would be sweet but will keep powering on!

Hi
i ran in my docker compose
and get this error exec /startup/run: no such file or directory

Thanks @Cao_Hoa for trying this out. Could you share me your docker-compose.yml? You shouldn’t need to create a thesillyhome_config folder so interested to know why its there.

here is my docker-compose file.

thesillyhome:
container_name: thesillyhome
image: lcmchris1/thesillyhome-container:latest
restart: unless-stopped
volumes:
- /home/thongtuehome/docker/thesillyhome_config:/thesillyhome_src/data/config/
ports:
- 2300:2300

db:
image: mariadb
restart: always
environment:
MYSQL_ROOT_PASSWORD: thongtuehome090916
MARIADB_DATABASE: homeassistant
MARIADB_USER: homeassistant
MARIADB_PASSWORD: thongtuehome090916

 volumes:
   - /home/thongtuehome/docker/mariadb:/var/lib/mysql
 ports:
   - "3306:3306"

Thanks again. I’ve re-pushed a new image and also to github.

Could you re-pull both and also use lcmchris1/thesillyhome-container:0.0.1 in your docker-compose.yml?
I suspect its pointing to an older version of the image.

thank you i will install always what i will inform you have a good day

1 Like

@Nova
Good day I spun your latest image and I get a webui.

I tried editing your options.json, but I have some questions.

Is the database section a connection to HA database? or are you creating a db for the component?

I added options.json and appdaemon. yaml as such

    volumes:
      - /mnt/cache/appdata/thesillyhome/config:/thesillyhome_src/data/config/
      - /mnt/cache/appdata/thesillyhome/appdaemon:/thesillyhome_src/appdaemon/

My homeassitant db is in postgres

I think it’s starting correctly. Below see docker logs, but it breaks with the database

Starting to parse DB data
INFO:root:Reading from homedb...
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/thesillyhome_src/thesillyhome/src/thesillyhome/model_creator/main.py", line 13, in <module>
    parse_data_from_db()
  File "/thesillyhome_src/thesillyhome/src/thesillyhome/model_creator/parse_data.py", line 129, in parse_data_from_db
    df_all = homedb().get_data()
  File "/thesillyhome_src/thesillyhome/src/thesillyhome/model_creator/home.py", line 29, in get_data
    mydb = mysql.connector.connect(
  File "/usr/local/lib/python3.10/site-packages/mysql/connector/__init__.py", line 179, in connect
    return MySQLConnection(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/mysql/connector/connection.py", line 95, in __init__
    self.connect(**kwargs)
  File "/usr/local/lib/python3.10/site-packages/mysql/connector/abstracts.py", line 716, in connect
    self._open_connection()
  File "/usr/local/lib/python3.10/site-packages/mysql/connector/connection.py", line 207, in _open_connection
    self._do_handshake()
  File "/usr/local/lib/python3.10/site-packages/mysql/connector/connection.py", line 99, in _do_handshake
    packet = self._socket.recv()
  File "/usr/local/lib/python3.10/site-packages/mysql/connector/network.py", line 243, in recv_plain
    raise errors.InterfaceError(errno=2013)
mysql.connector.errors.InterfaceError: 2013: Lost connection to MySQL server during query
Starting Appdaemon
Starting frontend on 0.0.0.0:2300
Listening on 0.0.0.0:2300
2022-06-07 16:52:28.378094 INFO AppDaemon: AppDaemon Version 4.2.1 starting
2022-06-07 16:52:28.378183 INFO AppDaemon: Python version is 3.10.4
2022-06-07 16:52:28.378224 INFO AppDaemon: Configuration read from: /thesillyhome_src/appdaemon/appdaemon.yaml
2022-06-07 16:52:28.378261 INFO AppDaemon: Added log: AppDaemon
2022-06-07 16:52:28.378301 INFO AppDaemon: Added log: Error
2022-06-07 16:52:28.378338 INFO AppDaemon: Added log: Access
2022-06-07 16:52:28.378373 INFO AppDaemon: Added log: Diag
2022-06-07 16:52:28.385476 WARNING AppDaemon: appdir: /thesillyhome_src/appdaemon/apps does not exist exist
2022-06-07 16:52:28.385864 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2022-06-07 16:52:28.464596 INFO HASS: HASS Plugin Initializing
2022-06-07 16:52:28.464671 INFO HASS: HASS Plugin initialization complete
2022-06-07 16:52:28.464826 INFO AppDaemon: HTTP is disabled
2022-06-07 16:52:28.467442 INFO HASS: Connected to Home Assistant 2022.6.3
2022-06-07 16:52:28.467640 INFO AppDaemon: Starting Apps with 0 workers and 0 pins
2022-06-07 16:52:28.486871 INFO HASS: Evaluating startup conditions
2022-06-07 16:52:28.488465 INFO HASS: Startup condition met: hass state=RUNNING
2022-06-07 16:52:28.488552 INFO HASS: All startup conditions met
2022-06-07 16:52:28.578688 INFO AppDaemon: Got initial state from namespace default
2022-06-07 16:52:30.470402 INFO AppDaemon: Scheduler running in realtime
2022-06-07 16:52:30.471014 INFO AppDaemon: App initialization complete


mine get this error