richibrics / IoTuring

Your Windows, Linux, macOS computer as MQTT and HomeAssistant integration
https://pypi.org/project/IoTuring/
GNU General Public License v3.0
70 stars 6 forks source link

How to set this up to run at startup? #120

Closed andzejsp closed 1 month ago

andzejsp commented 1 month ago

Im on arch btw. The problem is that when i create systemd service (i dont have crontab) to run script bin/bash Ioturing but it says the command is not recognized, then i tried pipx run IoTuring, it runs but the volume control errors out. When i run manually from terminal IoTuring it runs and all volume conrols are enabled..

this is what i get running pipx run IoTuring from systemd service

Aug 11 12:30:39 archie ioturing.sh[5403]: [ 2024-08-11 12:30:39 |   INFO   |           Entity.Cpu           ] Initialization successfully completed
Aug 11 12:30:39 archie ioturing.sh[5403]: [ 2024-08-11 12:30:39 |   INFO   |              MQTT              ] Preparing MQTT client
Aug 11 12:30:39 archie ioturing.sh[5403]: [ 2024-08-11 12:30:39 |   INFO   |              MQTT              ] MQTT Client ready to connect to the broker
Aug 11 12:30:39 archie ioturing.sh[5403]: [ 2024-08-11 12:30:39 |   INFO   |              MQTT              ] Connection established
Aug 11 12:30:39 archie ioturing.sh[5403]: [ 2024-08-11 12:30:39 |  ERROR   |         Entity.Volume          ] Error during Volume command: Connection failu>
Aug 11 12:30:40 archie ioturing.sh[5403]: [ 2024-08-11 12:30:40 |  ERROR   |         Entity.Volume          ] Error during Volume command: Connection failu>
Aug 11 12:30:40 archie ioturing.sh[5403]: [ 2024-08-11 12:30:40 |  ERROR   |         Entity.Volume          ] Error occured during update: Error getting vo>
Aug 11 12:30:40 archie ioturing.sh[5403]: [ 2024-08-11 12:30:40 |   INFO   |              MQTT              ] Preparing MQTT client
Aug 11 12:30:40 archie ioturing.sh[5403]: [ 2024-08-11 12:30:40 |   INFO   |              MQTT              ] MQTT Client ready to connect to the broker
Aug 11 12:30:40 archie ioturing.sh[5403]: [ 2024-08-11 12:30:40 |   INFO   |              MQTT              ] Connection established
~
         Entity.Cpu           ] Initialization successfully completed
            MQTT              ] Preparing MQTT client
            MQTT              ] MQTT Client ready to connect to the broker
       Entity.Volume          ] Error during Volume command: Connection failure: Connection refused pa_context_connect() failed: Connection refused
            MQTT              ] Connection established
       Entity.Volume          ] Error during Volume command: Connection failure: Connection refused pa_context_connect() failed: Connection refused
       Entity.Volume          ] Error occured during update: Error getting volume from
            MQTT              ] Preparing MQTT client
            MQTT              ] MQTT Client ready to connect to the broker
            MQTT              ] Connection established

bash script

#!/bin/bash
pipx run IoTuring

and systemd service

[Unit]
Description=IoTuring service
After=network.target
After=systemd-user-sessions.service
After=network-online.target

[Service]
User=thicklin
ExecStart=/home/thicklin/ioturing.sh

[Install]
WantedBy=multi-user.target

How do i do an autostart?

infeeeee commented 1 month ago

There are some instructions in the documentation: https://github.com/richibrics/IoTuring/blob/main/docs/Autostart%20tips.md#as-a-user-service-with-systemd-recommended

If you want to use the volume entity you should run it as a user service.

Does everything work as expected if you start it manually?

andzejsp commented 1 month ago

There are some instructions in the documentation: https://github.com/richibrics/IoTuring/blob/main/docs/Autostart%20tips.md#as-a-user-service-with-systemd-recommended

If you want to use the volume entity you should run it as a user service.

Does everything work as expected if you start it manually?

yeah, if i run : IoTuring everything works. same if i run script that has: pipx run IoTuring. I solved this, by adding .sh script file to the startup/autorun and it works now no problem.. too bad that systemd didnt work, but oh well..

infeeeee commented 1 month ago

Follow the docs I linked, volume entity works only in user-units. I use IoTuring that way on Arch, this is my setup in the docs.

infeeeee commented 1 month ago

Could you set this up? Or do you need some more help with this?

infeeeee commented 1 month ago

Please reply if you still can't set it up, I will close this issue until that