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.
@henfri , apparently there is still a small problem. I noticed yesterday that temperature values below freezing point are not displayed negatively. Have you noticed this yet?
Hi Henry,
in uvr.py you could change in line 17:
numeric_parts = re.findall(r’-?[\d.,]+', s)
I did not test this yet. Please let me know, if it works.
Greetings,
Hendrik
Hello Hendrik,
I get the following error after customizing the code in the uvr.py file and restarting the container:
SyntaxError: invalid character '’' (U+2019)
Traceback (most recent call last):
File "/usr/app/uvr/./send_uvr_mqtt.py", line 6, in <module>
from uvr import filter_empty_values
File "/usr/app/uvr/uvr.py", line 17
numeric_parts = re.findall(r’-?[\d.,]+', s)
Update:
I have no idea about python, but I searched for your expression “re.findall”. According to the documentation, only one apostrophe is wrong. I changed it as follows and it works like this.
numeric_parts = re.findall(r'-?[\d.,]+', s)
Now I just have to wait until we have minus degrees.
Sorry Hendrik, it doesn’t work yet.
My Scheme (you can see the outside temperature):
HomeAssistant: