#Catt hacks

1 messages ยท Page 1 of 1 (latest)

north garden
old bramble
#

/usr/local/bin/catt is where pip put it

#

but that could be cause i didnt uninstall it beforehand

north garden
#

I'm just trying to keep hacky stuff like this as simple as possible. Involving another addon is the opposite of that.

old bramble
#

this post by mmiller7 is what i have almost exactly

#

i have exactly what he has, but my key permissions wont allow the program to run

north garden
#

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.

old bramble
north garden
#

Just follow what I wrote ๐Ÿคจ
There is no SSH command.

old bramble
#

also my /home dir is completely empty, no nenvs

north garden
#

I didn't mention /home.

old bramble
#

oh tru, .pipx/home

north garden
#

You might not need both directories but you can research pipx yourself. I just want to get you started.

old bramble
#

the bash script also needs to be saved not in /config right

north garden
#

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?

old bramble
#

but then wouldnt I have the same issue where the command line couldnt see the script?

old bramble
north garden
#

Ah then just make it simple and use pip3.

#

It will get reinstalled anyway so who cares where it is.

old bramble
#

I installed it using pip in the HA container and it put it here /usr/local/bin/catt

north garden
#

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.

old bramble
#

the original location was /usr/bin/catt how can there be different permissions

north garden
#

Not sure what you mean.

old bramble
north garden
#

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.

old bramble
north garden
#

Sorry, hit enter too soon.

#

accessable by the same things right
What do you mean by that?

old bramble
north garden
#

Sure.

#

Where you are right now in the shell (via docker exec) is exactly what the automation sees.

old bramble
#

okay, so create automation that runs ur CMD on boot

north garden
#

Yup.

#

Try the cmd yourself first.

old bramble
#

then create another automation that runs the catt command when I want it to

north garden
#

Correct. But with full path. Not just catt ....

old bramble
#

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

north garden
#

You need to tell me more about your automation.

#

But it's pretty much the same. Instead of a ssh ... command you use mine.

old bramble
#

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

north garden
#

Yeah. Pretty simple. And it's also portable this way. As in it would work outside of HAOS with a normal docker based install.

old bramble
#

your amazing

#

I still dont understand why they have different permissions

north garden
#

Why thank you.

old bramble
#

so a restart should remove catt from the system right

#

it doesnt as far as i can tell lol

north garden
#

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.

old bramble
#

are those not the same file path?

north garden
#

Yes. In case you haven't noticed I see to be blind and write too fast today.

old bramble
#

u do type very fast

north garden
#

Well check ls -l /usr/local/bin/catt and whatever the other path was you thought was the same.

old bramble
#

almost the same

#

size is slightly off

#

ok, so just make this happen on boot [ -x /usr/local/bin/catt ] || pip3 install catt

north garden
#

Maybe one of them was created through other means. I suppose you tested a few commands.

#

Yup.

old bramble
#

i cant just do that with basic automations right?

north garden
#

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.

old bramble
#

gotcha

north garden
old bramble
#

u dont use automations often? isnt that the whole point of ha

north garden
#

I mostly use HA as a dashboard ๐Ÿ˜„

old bramble
#

so u just manually push all the buttons lol

north garden
#

I said not often, not never.

old bramble
#
    install_catt: [-x /usr/local/bin/catt] || pip3 install catt```
#

somehow this throws an error

north garden
#

Id enclose this in 's.

old bramble
#

ahh

north garden
#

You also have to take care of the spacing. Write it exactly like I did.

old bramble
#

how come my other command didnt need them

north garden
#

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"
old bramble
#

gotcha, use the second one

north garden
old bramble
#

will it always install catt in the same place?

north garden
#

I expect it to.

old bramble
#

aight

north garden
old bramble
#

tru

#

when i test it nothing happens, but thats cause its already installed

north garden
#

It should say it exists with the second example.

old bramble
#

it did

north garden
#

Technically it checks if it's executable but existence is implied for that.

old bramble
#

can we easily force it to install in a designated place

north garden
#

Maybe but why?

old bramble
#

idk, reliability? lol

north garden
#

I want to try to keep this simple.

old bramble
#

but it should install in the same place anyway

#

without forcing it

north garden
#

You'll notice if the path changes.

old bramble
#

yeah itll break lol

#

theres a "when home assistant starts" trigger lol

#

so that was easy

north garden
#

I read about this and apparently it can trigger relatively often (on restarts for example) which is why I added the check.

old bramble
#

makes sense,. cause its not getting wiped on a restart

#

Thank you so much once again!