Thank you, you’re right. It worked with that. But how do I now run the script permanently in the background? When I close the terminal, the script is also closed. A simple & cannot be appended with Synology.
Hm, nohup should Not make a difference. I only suggested it, so that you see the Output and Potential Errors.
You could Run it with nohup again and See If IT works. If Not, please Run it with nohup and Pipe the Output into a logfile.
Ok, maybe it’s like shooting with “cannons on sparrows”, but I now have a Docker runtime environment with pthon3 running the script.
Dockerfile:
FROM ubuntu:latest
RUN apt update
RUN apt install python3 -y
RUN apt install python3-pip -y
RUN apt install python3-requests -y
RUN apt install python3-paho-mqtt -y
WORKDIR /usr/app/uvr
COPY send_uvr_mqtt.py ./
COPY uvr.py ./
COPY PID.png ./
COPY New.xml ./
CMD ["python3", "./send_uvr_mqtt.py"]
Containerbuild:
docker run -d --name=send_uvr_mqtt \
-p 1883:1883 \
--restart always \
send_uvr_mqtt:latest
And, does it Work well now?
Btw: python, Not pthon
Hi Hendrik, please excuse me for forgetting the punch line.
Yes, it works very well like this. Since I have never written a Dockerfile or built a container before, it took me a few tries. But it’s good like this.
I noticed that the device in the Home Assistant is simply called MQTT after my changeover and no longer as it was before. But that’s not a problem.
Of course, it would be better if I had the files locally instead of in the container. That way I could always make adjustments to them. But I was too stupid to
Hi Henri,
Not Bad for a First Container.
I think you can remove the -p …
Regarding the XML:
Hello Hendrik,
i have adjusted the configuration a little and I’ll leave it that way now. It was important to me that I don’t have the files in the container, but integrate them locally so that I can still make changes to them.
Dockerfile:
FROM ubuntu:latest
RUN apt update
RUN apt install python3 -y
RUN apt install python3-requests -y
RUN apt install python3-paho-mqtt -y
WORKDIR /usr/app/uvr
COPY send_uvr_mqtt.py ./
CMD ["python3", "./send_uvr_mqtt.py"]
Docker RUN:
docker run -d --name=send_uvr_mqtt \
-v /volume1/docker/python:/usr/app/uvr \
--restart always \
send_uvr_mqtt:latest
If I now run uvr.py with it as a test, it also works.
Now I have a second problem that I can’t deal with. I want to convert the status of the UVR1611 outputs into binary values.
The status of my oil burner is either “Außer Betrieb” or “In Betrieb”.
To do this, I have added the following to my template.yaml
- sensor:
- name: Status Ölbrenner ## rechnet den Sensorstatus in einen binären Zustand um
state: >-
{{ is_state('binary_sensor.uvr_tadesigner_anf_brenner_zustand_ein_aus','Außer Betrieb') }}
- name: Status Solarventil Osten ## rechnet den Sensorstatus in einen binären Zustand um
state: >-
{{ is_state('binary_sensor.uvr_tadesigner_solarventso_zustand_ein_aus','Außer Betrieb') }}
- name: Status Solarventil Westen ## rechnet den Sensorstatus in einen binären Zustand um
state: >-
{{ is_state('binary_sensor.uvr_tadesigner_solarventsw_zustand_ein_aus','Außer Betrieb') }}
Unfortunately it does not work (see also Solarventil Osten):
Do you have any ideas on how to implement this?
Hey, I’ve solved the problem. The status is not “Außer Betrieb” or “In Betrieb” but on/off.
Glad to hear that all is working now.