mstenta / atmospi

Atmospheric monitoring app for logging and graphing temperatures and humidities over time using a Raspberry Pi and DS18B20, DHT11, DHT22, and AM2302 sensor(s).
31 stars 9 forks source link

New DS18B20 sensor not added automatically #27

Closed mstenta closed 9 years ago

mstenta commented 9 years ago

Originally reported by @janvdbeek in #11 - the following error occurs:

Traceback (most recent call last):
File "/home/pi/atmospi/Atmospi/measure-ds18b20.py", line 75, in 
id = db.fetchone () [0]
TypeError: 'NoneType' object has no attribute '__ getitem __'
janvdbeek commented 9 years ago

Thank you for your quick response. Yes, I've the addresses of my sensors. I will manually put them into the database and I'll let you know if that solves the problem.

janvdbeek commented 9 years ago

I did: sqlite3 and then INSERT INTO Devices (DeviceID........); and got an error: no such table: Devices But the table exists. So what I'm doing wrong?

ultima-originem commented 9 years ago

Jan,

I had to do this as well yesterday and it worked:

CREATE TABLE Devices(DeviceID INTEGER PRIMARY KEY, Type TEXT, SerialID TEXT, Label TEXT); INSERT INTO Devices (DeviceID, Type, SerialID, Label) VALUES (NULL, 'ds18b20', '28-000005e4d76b', 'radiator aanvoer'); INSERT INTO Devices (DeviceID, Type, SerialID, Label) VALUES (NULL, 'ds18b20', '28-000005e4f2fd', 'radiator retour'); ...

mstenta commented 9 years ago

Hmm, it definitely sounds like the table is NOT created @janvdbeek ... what happens when you run the following:

.tables
janvdbeek commented 9 years ago

.tables gives nothing. I tried that already and I was very surprised. I have a log.db in the /home/pi/atmospi directory and when I open the database with SQLite Epert Personal 3 I can see all the tables and indexes. But maybe I've to create it again and immediately insert the sensor addresses as ot3 mentioned in his post above.

mstenta commented 9 years ago

Hmm weird. Yea, if you don't have any data to lose I would recommend deleting log.db and setting it up again manually (step 6 in the readme). Hope that helps!

janvdbeek commented 9 years ago

I'll try to set up the database manually (again :-) ). Thanks so far.

janvdbeek commented 9 years ago

OK, I deleted the existing database and set up a new database. I also inserted the sensor addresses into the Devices table. I checked the contents of the table and the sensor addresses are there. I ran the file measure-ds18b20.py manually and no errors occured this time :-) So, I checked the webpage and I've a graph and measurement data!

Thanks a lot for your help.

mstenta commented 9 years ago

That's great! Welcome to the atmospi club! ;-)

I'm going to assume that the error was with the database file, and not the code... closing this issue.

janvdbeek commented 9 years ago

Yes, the error was with the database and not with the code.

mstenta commented 9 years ago

Reopening this issue because someone else reported the same thing. I'm guessing that the auto-device-detection code doesn't work right, so it's only working if you manually add the device to the Devices table (per ot3's comment above).

Probably not too hard to fix... just need to debug it.

mstenta commented 9 years ago

Fixed!