Mycodo icon indicating copy to clipboard operation
Mycodo copied to clipboard

Measurement is always None though the automation works

Open lalebarde opened this issue 2 years ago • 0 comments

Describe the problem/bug

[I have one function to open a solenoid valve (not listed here) and to activate a conditional controller that monitors a sensor which is True when the tank is full. When this condition is fulfilled, it closes the valve. When I run it, it works, the tank is filled and the water feed is stopped. But, when I look at the logs, the measurement looks always None, and the message f"Tank full, sensor = {measurement}" (f"Cuve pleine, Cuve Niv Haut = {measurement}" in the listing below) does not appear in the logs as expected]

Versions:

  • Mycodo Version: [8.13.9]
  • Raspberry Pi Version: [4 Model B Rev 1.2]
  • Raspbian OS Version: [Raspbian GNU/Linux 10 (buster)]

Reproducibility

Please list specific setup details that are involved and the steps to reproduce the behavior:

  1. [Activate the controller]
  2. [Make the sensor change state for at least 3 seconds = 3x the sampling rate]
  3. [Wait a few seconds (1s sampling rate)]
  4. [See the logs]

Expected behavior

[The measurement should not be None, and the value should appear. Then when the sensor is made change its state, the value measured should change, and the message should appear in the logs]

Screenshots

[Here is a full session log where I do trigger the sensor (light on) "Test Cuve Niv Haut" is the name of the conditional controller "Cuve Niv Haut" is the sensor name 2022-06-23 23:00:41,370 - INFO - mycodo.controllers.controller_conditional_960d9665 - Activated in 132.9 ms 2022-06-23 23:00:41,415 - INFO - mycodo.controllers.controller_conditional_960d9665 - Test Cuve Niv Haut 2022-06-23 23:00:41,538 - INFO - mycodo.controllers.controller_conditional_960d9665 - Cuve Niv Haut = None 2022-06-23 23:00:42,567 - INFO - mycodo.controllers.controller_conditional_960d9665 - Test Cuve Niv Haut 2022-06-23 23:00:42,701 - INFO - mycodo.controllers.controller_conditional_960d9665 - Cuve Niv Haut = None 2022-06-23 23:00:43,464 - INFO - mycodo.controllers.controller_conditional_960d9665 - Test Cuve Niv Haut 2022-06-23 23:00:43,568 - INFO - mycodo.controllers.controller_conditional_960d9665 - Cuve Niv Haut = None 2022-06-23 23:00:44,595 - INFO - mycodo.controllers.controller_conditional_960d9665 - Test Cuve Niv Haut 2022-06-23 23:00:44,679 - INFO - mycodo.controllers.controller_conditional_960d9665 - Cuve Niv Haut = None 2022-06-23 23:00:45,456 - INFO - mycodo.controllers.controller_conditional_960d9665 - Test Cuve Niv Haut 2022-06-23 23:00:45,548 - INFO - mycodo.controllers.controller_conditional_960d9665 - Cuve Niv Haut = None 2022-06-23 23:00:46,580 - INFO - mycodo.controllers.controller_conditional_960d9665 - Test Cuve Niv Haut 2022-06-23 23:00:46,695 - INFO - mycodo.controllers.controller_conditional_960d9665 - Cuve Niv Haut = None 2022-06-23 23:00:47,473 - INFO - mycodo.controllers.controller_conditional_960d9665 - Test Cuve Niv Haut 2022-06-23 23:00:47,611 - INFO - mycodo.controllers.controller_conditional_960d9665 - Cuve Niv Haut = None 2022-06-23 23:00:48,644 - INFO - mycodo.controllers.controller_conditional_960d9665 - Test Cuve Niv Haut 2022-06-23 23:00:48,715 - INFO - mycodo.controllers.controller_conditional_960d9665 - Cuve Niv Haut = None 2022-06-23 23:00:49,491 - INFO - mycodo.controllers.controller_conditional_960d9665 - Test Cuve Niv Haut 2022-06-23 23:00:49,602 - INFO - mycodo.controllers.controller_conditional_960d9665 - Cuve Niv Haut = None 2022-06-23 23:00:50,653 - INFO - mycodo.controllers.controller_conditional_960d9665 - Test Cuve Niv Haut 2022-06-23 23:00:50,835 - INFO - mycodo.controllers.controller_conditional_960d9665 - Cuve Niv Haut = None 2022-06-23 23:00:51,615 - INFO - mycodo.controllers.controller_conditional_960d9665 - Test Cuve Niv Haut 2022-06-23 23:00:51,775 - INFO - mycodo.controllers.controller_conditional_960d9665 - Cuve Niv Haut = None 2022-06-23 23:00:52,561 - INFO - mycodo.controllers.controller_conditional_960d9665 - Test Cuve Niv Haut 2022-06-23 23:00:53,100 - INFO - mycodo.controllers.controller_conditional_960d9665 - Cuve Niv Haut = None 2022-06-23 23:00:53,652 - INFO - mycodo.controllers.controller_conditional_960d9665 - Test Cuve Niv Haut 2022-06-23 23:00:53,869 - INFO - mycodo.controllers.controller_conditional_960d9665 - Cuve Niv Haut = None 2022-06-23 23:00:54,374 - INFO - mycodo.controllers.controller_conditional_960d9665 - Deactivated in 214.4 ms]

Additional context = Conditional Statement

self.logger.info("Test Cuve Niv Haut") # Daemon Log
measurement = self.condition("{b5f6a76b}") 
self.logger.info(f"Cuve Niv Haut = {measurement}") # Check this measurement in the Daemon Log
if measurement is not None:  # If a measurement exists
    if measurement == True:
        self.message += f"Cuve pleine, Cuve Niv Haut = {measurement}\n"
        self.logger.info(f"Cuve pleine, Cuve Niv Haut = {measurement}")
        self.run_all_actions(message=self.message)  # Run all actions sequentially

image

lalebarde avatar Jun 23 '22 21:06 lalebarde