Inconsistent access to sensors on one wire
lalo-uy opened this issue · 5 comments
This inconsistency comes back from cbpi3 Manuel code.
On /cbpi/extension/onewire on line 15 the list of available sensores is collected from
/sys/bus/w1/devices
but when reading the sensors on line 44 goes to
/sys/bus/w1/devices/w1_bus_master1/%s/w1_slave'
not finding sensors under other bus masters.
Most sistems only have bus_master1 on gpio4, but you can have several like
dtoverlay=w1-gpio,gpiopin=4
dtoverlay=w1-gpio,gpiopin=27
dtoverlay=w1-gpio,gpiopin=18
Line 44 shuld read
with open('/sys/bus/w1/devices/%s/w1_slave' % self.sensor_name, 'r') as content_file:
Also the reading loop end with time.sleep(1)
Since reading a sensor takes 0.8 sec if you have 7 or 8 sensors in the bus you cant poll then every second. The code is bloking and delaying in the read.
Spacing at least 5 or 10 sec makes more sence. No vessel change that fast any way.
I will look into it.
However, reading time is anyhow a config parameter for the sensor in this extension. Values of 5, 10, 30 and 60 seconds can be configured.
ok, I missed this since I never touched that part of the code.
I have no experience with the W1 bus. But if I look into the code, the system is reading the content of a file within a thread.
If you add another sensor, another thread is opened for the other sensor which reads a separate file every second in parallel.
So far I do not see a problem. It might well be, that the data has not been updated by the bus and I agree that the kettle does not react that fast. However, there might be other usecases for a sensor where a faster response (< 5 or 10 seconds) might be required.
The question is, if the thread which is reading the file is causing an issue.
If not, I don't want to touch this part.
Removing w1_master1 from line 44 if far more important
Modified in the development branch -> 4.0.1.4