Giter Site home page Giter Site logo

eternityforest / kaithemautomation Goto Github PK

View Code? Open in Web Editor NEW
45.0 6.0 5.0 82.94 MB

Pure Python, GUI-focused home automation/consumer grade SCADA

License: GNU General Public License v3.0

CSS 4.54% JavaScript 2.85% Python 53.99% Shell 1.29% HTML 35.68% Vue 1.41% Makefile 0.25%

kaithemautomation's Introduction

AI generated picture of a tavern

Linux Single Board Computer badge DMX Python

Offline First GPLv3 Badge Pre-commit Badge Makefile Badge

Ten Year Project Pytest Ruff Poetry

Amidst the mists and fiercest frosts,
with stoutest wrists and loudest boasts,
He thrusts his fists against the posts,
And still insists he sees the ghosts.

Kaithem is Linux home/commercial automation server written in pure Python(3.10 and up). Not tested outside of Linux. Resource usage is low enough to run well on the Raspberry Pi.

You automate things by directly writing python and HTML via a web IDE, or by using the built-in Chandler module, which is a full web-based lighting aud audio control board with a visual programming language adding interactivity.

Installation ๐ŸŒฒ

The careful text-books measure
(Let all who build beware!)
The load, the shock, the pressure
Material can bear.

git clone --depth 1 https://github.com/EternityForest/KaithemAutomation
cd KaithemAutomation

Now you have the repo cloned, all the relevant commands are in the Makefile. This is an interpreted package, and we use Poetry and pipx, but we also use Make just to keep commands in one handy place.

Install system packages ๐Ÿ” 

Many of these have to do with audio features, not all are needed. See Makefile for what is actually installed. This also installs virtualenv support.

It installs the full suite of GStreamer plugins, and OpenCV for NVR object detection, so it's a bit heavy.

make root-install-system-dependencies

Get pipx and Poetry ๐ŸŒป

Skip this if you already have them!

# pipx is a wonderful tool that installs
# Applications in virtual environments
# and makes them available on the command line.

sudo apt install pipx

python3 -m pipx ensurepath

# Poetry manages project
# specific virtual environments
pipx install poetry

After doing this, log out and log back into the py. The program doesn't appear in your usable packages until you do that, because Debian strangely enough doesn't have the directory on PATH by default

Install kaithem in the project folder virtualenv ๐Ÿฑ

Now that you have the system dependencies, you should have pipx from your package manager.

cd into the folder you cloned, probably with cd ~/KaithemAutomation

# This line tells Poetry to put
# it's virtualenv right in the project folder
# Where apps like VS Code will know how to work with it
# If you intend to do any development.

# If you already have a .venv in your folder, it
# May be best to delete it and start over.
poetry config --local virtualenvs.in-project true

# This config setting is needed on many platforms,
# the keyring is not used with Kaithem and on
# some systems enabling it crashes everything.
poetry config --local keyring.enabled false

poetry install -v

# Poetry will run it in the virtualenv
poetry run python dev_run.py

# Hit Ctrl-C to stop. may need to try a few times if there are mamy active threads, or just wait a few.

# On some systems, to use audio mixing
# You may need to run 'sudo make root-use-pipewire-jack'
# And prefix everything that uses JACK with pw-jack

# pw-jack poetry run python dev_run.py

Expect this to take a few minutes. If it gets stuck at Preparing... it is probably not actually stuck and just needs a few. It should only be 15mins max though, at least on a Pi4.

Then visit http://YOUR_PI_ADDRESS:8002/index and log in with your normal Linux username and password.

Most likely it will be http://raspberrypi.local:8002/index if you kept the defaults when installing.

Tips and Troubleshooting โ‰๏ธ

So, when the buckled girder
Lets down the grinding span,
The blame of loss, or murder,
Is laid upon the man.
Not on the Stuff โ€” the Man!

Access from Anywhere ๐ŸŒ

See Wiki Tutorial (https://github.com/EternityForest/KaithemAutomation/wiki/Remote-Access)

Sound Mixing Broken?

Kaithem does not support advanced audio features on anything other than pipewire via the JACK protocol.

Out of the box, JACK apps might not work on Ubuntu. Try:

sudo make root-use-pipewire-jack

And then rebooting. In theory you can just restart the services, but it seems to need a reboot to take effect.

This will make ALL jack apps go through pipewire, you won't ever need to launch jackd. I'm not sure why you would ever want to use the original JACK server, so this shouldn't cause any issues.

Still broken?

Unfortunately, it doesn't work on pi, you'll need to prefix stuff that should use jack with pw-jack.

pw-jack poetry run python dev_run.py

Kaithem's installer does this automatically when you use

Sound Too Quiet?

Some systems like to set volume to 40% at boot, at the ALSA mixer level. Try:

make user-max-volume-at-boot

as whatever user you plan to run kaithem under.

You can also try setting volume to full and storing it

amixer set Master 100%
sudo alsactl store

Sound bad on the Pi?

You might not have pipewire configured correctly. The pi default config seems to set the buffer too low.

Update kaithem and run make user-set-global-pipewire-conf as the user that will be doing this stuff, to get some reasonable defaults. nano ~/.config/pipewire/pipewire.conf to tweak further.

Install globally and run at boot

To run as a systemd user service(Runs as soon as you log in or the desktop/kiosk starts) Expect the command to take about 15 minutes.

sudo make root-use-pipewire-jack
make user-start-kaithem-at-boot

Make sure the SD card stays fresh ๐Ÿƒ

On a dedicated system, you probably want to disable a buch of stuff the Pi comes with that normally writes to the SD card all the time, disable auto update for most system packages(Assuming you're on a private network), and a few other tweaks.

sudo make root-install-linux-tweaks
sudo make root-install-sd-protection

Development ๐Ÿ–ฅ๏ธ

Info for devs here on the wiki (https://github.com/EternityForest/KaithemAutomation/wiki/Development)

Recent Changes ๐Ÿ•—

Good men, the last wave by, crying how bright
Their frail deeds might have danced in a green bay,
Rage, rage against the dying of the light.

(See Full Changelog)

kaithemautomation's People

Contributors

eternityforest avatar dependabot[bot] avatar

Stargazers

David avatar Christopher Webb avatar Daniel avatar Jeff Jerousek avatar Jarad Olson avatar  avatar  avatar Mรกrk Bartos avatar  avatar  avatar Clayton Kehoe avatar Joel Carlton avatar Brendan avatar Tim Kersey avatar JustAnyone avatar Jay Ess avatar  avatar Charith Madhuranga avatar Arth Tyagi avatar No Name avatar Michael avatar Wesley Leach avatar Neeraj Kanhere avatar  avatar Gregory Ostermayr avatar  avatar Steven K. Baum avatar Ian Max Andolina avatar Jerome Velociter avatar Devon 'fire' Adkisson avatar Suri avatar Virag Jain avatar Greg Hochmuth avatar Chris Bergeron avatar Kaan Gรถksal avatar Sanmathi Bharamgouda avatar  avatar Iopen avatar Arihant Chawla avatar  avatar Arash M. avatar Richard Teachout avatar Matt avatar  avatar Guillaume Dumoulin avatar

Watchers

Budi Mulyo avatar  avatar James Cloos avatar  avatar  avatar  avatar

kaithemautomation's Issues

NVRChannel not working over unencrypted connections

ERROR:2022Apr07 17:15:07 BST cherrypy.error.3020579360 [07/Apr/2022:17:15:07] HTTP Traceback (most recent call last):
File "/opt/kaithem/kaithem/src/thirdparty/cherrypy/_cprequest.py", line 638, in respond self._do_respond(path_info)
File "/opt/kaithem/kaithem/src/thirdparty/cherrypy/_cprequest.py", line 688, in _do_respond
self.hooks.run('before_request_body') File "/opt/kaithem/kaithem/src/thirdparty/cherrypy/_cprequest.py", line 95, in
run self.run_hooks(iter(sorted(self[point]))) File "/opt/kaithem/kaithem/src/thirdparty/cherrypy/_cprequest.py",
line 117, in run_hooks hook() File "/opt/kaithem/kaithem/src/thirdparty/cherrypy/_cprequest.py", line 65, in
call return self.callback(**self.kwargs) File
"/opt/kaithem/kaithem/src/thirdparty/ws4py/server/cherrypyserver.py", line 191, in upgrade request.ws_handler =
handler_cls(ws_conn, ws_protocols, ws_extensions, File "/opt/kaithem/kaithem/src/widgets.py", line 445, in init
if cherrypy.request.scheme == 'https' or pages.

For now the workaround is just to use https(Default port 8001) and click through the security stuff. Proper HTTP support coming soon.

Websockets are very slow to start up if the network is crappy

I don't know if there's a workaround for this, but it seems everything hangs on socket.sendall() after the first send. One message usually gets through, the next hangs for up to 30s or so, then all is normal.

This may have something to do with Nighthawk mesh routing.

Occasionally it seems that thread creation can hang.

There is already code to partly mitigate this, but i have no idea what causes it.

File "/home/daniel/.vscode/extensions/ms-python.python-2022.4.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydev_bundle/pydev_monkey.py", line 1034, in call
py_db.notify_thread_created(thread_id, t)
File "/home/daniel/.vscode/extensions/ms-python.python-2022.4.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/pydevd.py", line 1620, in notify_thread_created
additional_info = set_additional_thread_info(thread)
File "/home/daniel/.vscode/extensions/ms-python.python-2022.4.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_additional_thread_info_regular.py", line 136, in set_additional_thread_info
additional_info = PyDBAdditionalThreadInfo()
File "/home/daniel/Projects/KaithemAutomation/kaithem/src/thirdparty/scullery/iceflow.py", line 61, in del
workers.do(self.worker.wait)
File "/home/daniel/Projects/KaithemAutomation/kaithem/src/thirdparty/scullery/workers.py", line 298, in do
addWorker()
File "/home/daniel/Projects/KaithemAutomation/kaithem/src/thirdparty/scullery/workers.py", line 241, in addWorker
t.start()
File "/usr/lib/python3.8/threading.py", line 857, in start
self._started.wait()
File "/usr/lib/python3.8/threading.py", line 558, in wait
signaled = self._cond.wait(timeout)
File "/usr/lib/python3.8/threading.py", l

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.