You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running this simple Python script on the host, it works as expected and collects data from all the sensors over long period of time:
import logging
import os
import sys
import time
from ruuvitag_sensor.ruuvi import RuuviTagSensor
# A map of sensors' MAC to device id.
# All devices need to be pre-created in IoT Hub.
authorized_devices = {"FE:36:EA:1E:62:AF": "sensor_1",
"E4:F2:81:30:8D:52": "sensor_2"}
logging.basicConfig(
format='%(asctime)s %(levelname)-8s %(message)s',
level=logging.DEBUG,
datefmt='%Y-%m-%d %H:%M:%S')
def log_messages(mac, payload):
""" The callback for when a message is received from a sensor.
"""
# This check for authorized devices should not be needed
# given that it should already be enforced by the ruuvitag library
if mac in authorized_devices:
device_id = authorized_devices[mac]
logging.info("publishing message for %s [%s]: {%s}." %(device_id, mac, str(payload)))
else:
logging.warning("ignoring message from an unknown sensor (MAC address: {%s})."%(mac))
def main():
def callback(data):
log_messages(data[0], data[1])
# listening for sensors data.
logging.info("listening for sensors data.")
RuuviTagSensor.get_datas(callback, list(authorized_devices.keys()))
logging.info("exiting.")
if __name__ == "__main__":
main()
However when running the same code in a docker container on the same raspberry pi hardware, it will initially start by collecting data from all sensors but then miss data from sensor 2 after a couple hours.
Here is here is the docker file used:
COPY requirements.txt ./
RUN pip install -r requirements.txt
COPY app .
# For demo purposes, started as root to make sure
# there are no permission issues.
USER root
CMD [ "python3", "-u", "./main.py" ]
and the requirements file: ruuvitag-sensor==1.1.0
And here is the docker run command used:
sudo docker run --rm --network host --privileged arm32v7_container
The text was updated successfully, but these errors were encountered:
Sorry that didn't get back to you regarding this issue. Hope that you got the situation sorted out.
If you are still using RuuviTag and you have this same issue, could you provie me more logging data. You can write all logs to file by changing file_handler's log level, e.g.
Describe the bug
RuuviTag python library looses some sensors when running through a docker container for a few hours.
Environment:
When running this simple Python script on the host, it works as expected and collects data from all the sensors over long period of time:
However when running the same code in a docker container on the same raspberry pi hardware, it will initially start by collecting data from all sensors but then miss data from sensor 2 after a couple hours.
Here is here is the docker file used:
and the requirements file:
ruuvitag-sensor==1.1.0
And here is the docker run command used:
sudo docker run --rm --network host --privileged arm32v7_container
The text was updated successfully, but these errors were encountered: