kizniche / Mycodo

An environmental monitoring and regulation system
http://kylegabriel.com/projects/
GNU General Public License v3.0
3k stars 500 forks source link

Can't read DHT22 - power output error #454

Closed MrDeadBeef closed 6 years ago

MrDeadBeef commented 6 years ago

Mycodo Issue Report:

Problem Description

Please list:

Read input from DHT22 on GPIO 2

Fresh install of Raspbian Stretch Lite did update/upgrade/dist-upgrade before installing Mycodo

Errors

2018-04-21 23:17:44,643 - mycodo.inputs.dht22_1 - INFO - Turning on sensor 2018-04-21 23:17:44,650 - mycodo.output - WARNING - Cannot turn on Output with ID 0. It doesn't exist 2018-04-21 23:17:46,655 - mycodo.input_8bed4119 - INFO - Activated in 2148.0 ms 2018-04-21 23:17:46,715 - mycodo.inputs.dht22_1 - ERROR - DHT22Sensor raised an exception when taking a reading: 'NoneType' object has no attribute 'is_on' Traceback (most recent call last): File "/var/mycodo-root/mycodo/inputs/dht22.py", line 212, in read self._temperature) = self.get_measurement() File "/var/mycodo-root/mycodo/inputs/dht22.py", line 155, in get_measurement not db_retrieve_table_daemon(Output, unique_id=self.power_output_id).is_on()): AttributeError: 'NoneType' object has no attribute 'is_on'

https://github.com/kizniche/Mycodo/blob/c6b7ae3ba5f5d8a852919d702a5131c594682742/mycodo/inputs/dht22.py#L154

Steps to Reproduce the issue:

How can this issue be reproduced?

  1. Fresh Raspian install
  2. Install Mycodo
  3. Attach DHT22
  4. Add Input and try to read data

Additional Notes

Maybe i'm doing something wrong, but if you edit the dht22.py and comment out the lines 154 up to 160 save and restart the backend it will display the data from the sensor without any errors.

kizniche commented 6 years ago

Try this fix by manually editing dht22.py and changing the following section:

https://github.com/kizniche/Mycodo/blob/f95c3cc2d65e58e8a270eb40a269cb628bfc851d/mycodo/inputs/dht22.py#L154-L156

Then restart the daemon with sudo service mycodo restart