#Catt hacks
1 messages ยท Page 1 of 1 (latest)
I'm threading this before we get yelled at ๐
https://github.com/pypa/pipx/blob/main/docs/installation.md#installation-options
might be too late lol
/usr/local/bin/catt is where pip put it
but that could be cause i didnt uninstall it beforehand
I'm just trying to keep hacky stuff like this as simple as possible. Involving another addon is the opposite of that.
this post by mmiller7 is what i have almost exactly
https://community.home-assistant.io/t/using-catt/130332/87 this guy does exactly what I want
i have exactly what he has, but my key permissions wont allow the program to run
Write a bash script with something like this
mkdir -p /share/.pipx/{home,bin}
export PIPX_HOME=/share/.pipx/home
export PIPX_BIN_DIR=/share/.pipx/bin
pip install pipx
For now just run this manually, later you can just execute it at "boot".
Then run /share/.pipx/bin/catt or /share/.pipx/home/venvs/catt/bin/catt and tada.
so once catt is installed at root, then I can just run the catt command with no ssh needed
Just follow what I wrote ๐คจ
There is no SSH command.
also my /home dir is completely empty, no nenvs
I didn't mention /home.
oh tru, .pipx/home
You might not need both directories but you can research pipx yourself. I just want to get you started.
the bash script also needs to be saved not in /config right
You can also store it there. Doesn't matter much. As long as it's a persstent directory you're good.
Does it even have to be persisted?
but then wouldnt I have the same issue where the command line couldnt see the script?
it doesnt as long as catt is
Ah then just make it simple and use pip3.
It will get reinstalled anyway so who cares where it is.
I installed it using pip in the HA container and it put it here /usr/local/bin/catt
Then use that path to call it in your sensor.
/usr/local/bin/catt ...
You just have to make sure that you have an automation that installs it again.
Or you install it via the SSH addon in a specific path that is accessible to the HA container as well.
I'd go the first route due to simplicity.
the original location was /usr/bin/catt how can there be different permissions
Not sure what you mean.
this is where the addon installed it
The CMD for your automation could look like this
[ -x /usr/local/bin/catt ] || pip3 install catt
If that doesn't work try
sh -c "[ -x /usr/local/bin/catt ] || pip3 install catt"
You run this in your automation. It will install catt if /usr/local/bin/catt is not executable.
and this is where pip in the container installed it, they have the same base folder so they should both be accessable by the same things right
it just says "bash"
Sorry, hit enter too soon.
accessable by the same things right
What do you mean by that?
like if the automation could see one, it should see the other
Sure.
Where you are right now in the shell (via docker exec) is exactly what the automation sees.
okay, so create automation that runs ur CMD on boot
then create another automation that runs the catt command when I want it to
Correct. But with full path. Not just catt ....
yes
how do I write to the bash in an automation without ssh tho? Thats how i got to ssh last time
i got lost in the sauce lol
You need to tell me more about your automation.
But it's pretty much the same. Instead of a ssh ... command you use mine.
originally i was calling service: hassio.addon_stdin to write to the terminal, but then when i found that didnt work I switched to running the shell command thats in the config file
OH i chnage the shell command
i just remove the ssh part
Yeah. Pretty simple. And it's also portable this way. As in it would work outside of HAOS with a normal docker based install.
Why thank you.
so a restart should remove catt from the system right
it doesnt as far as i can tell lol
A reboot might but it happens whenever the container is re-created. Not sure if that happens on every boot. Note that reboot != restart.
You can check ls -l /usr/local/bin/catt and ls -l /usr/local/bin/catt to see if they are symlinks or have the same file size.
are those not the same file path?
Yes. In case you haven't noticed I see to be blind and write too fast today.
u do type very fast
Well check ls -l /usr/local/bin/catt and whatever the other path was you thought was the same.
almost the same
size is slightly off
ok, so just make this happen on boot [ -x /usr/local/bin/catt ] || pip3 install catt
Maybe one of them was created through other means. I suppose you tested a few commands.
Yup.
i cant just do that with basic automations right?
Technically you can just do pip3 install catt but I figure that in case the automation runs too often this will prevent some CPU cycles wasted because it only runs the install if the file isn't there already.
gotcha
I don't use automations often but you should be able to use it like here: https://www.home-assistant.io/integrations/shell_command/#automation-example
u dont use automations often? isnt that the whole point of ha
I mostly use HA as a dashboard ๐
so u just manually push all the buttons lol
I said not often, not never.
install_catt: [-x /usr/local/bin/catt] || pip3 install catt```
somehow this throws an error
Id enclose this in 's.
ahh
You also have to take care of the spacing. Write it exactly like I did.
how come my other command didnt need them
And again. Test it in the CLI first!
Compare these for example
[-x /usr/local/bin/catt] && echo "It exists" || echo "It doesn't exist"
[ -x /usr/local/bin/catt ] && echo "It exists" || echo "It doesn't exist"
gotcha, use the second one
You don't necessarily need them but I really don't want to remember what does and what does not. It's just safer to enclose strings.
will it always install catt in the same place?
I expect it to.
aight
Use the real one ๐
It should say it exists with the second example.
it did
Technically it checks if it's executable but existence is implied for that.
can we easily force it to install in a designated place
Maybe but why?
idk, reliability? lol
I want to try to keep this simple.
You'll notice if the path changes.
https://stackoverflow.com/questions/2915471/install-a-python-package-into-a-different-directory-using-pip
But you have to fiddle with that yourself.
yeah itll break lol
theres a "when home assistant starts" trigger lol
so that was easy
I read about this and apparently it can trigger relatively often (on restarts for example) which is why I added the check.