I spent most of yesterday trying to get a measurement from one DS1B20 and activates an led on the senseHAT. Based on the measurement value sets the color of the led. But, I just cannot get the following to work. Could someone help me out??
It appears that the issue is with the Execute Command: Shell : Execute a Linux shell command.
each Command is:
Command - sense.set_pixel(0, 1, 0,0,xxx)
User - mycodo
Measurement (Single, Last) : self.condition("{95cecc0d}") returns the last value found
self.run_action("{578cf025}") will execute = sense.set_pixel(0, 1, 0,0,0)
self.run_action("{0411875f}") will execute = sense.set_pixel(0, 1, 0,0,255)
self.run_action("{4842a316}") will execute = sense.set_pixel(0, 1, 0,255,0)
self.run_action("{7a3f837f}") will execute = sense.set_pixel(0, 1, 255,0,0)
The Conditional Statement CODE is:
# Lights up an LED based on the current sensor reading
from sense_hat import SenseHat
sense = SenseHat()
sense.clear()
measurement = self.condition("{95cecc0d}")
self.logger.info("DS18B20-1 Measured value is {val}".format(val=measurement))
if measurement is None: # No Measurement Received
self.message += "DS18B20-1 No Measurement Received!\n"
self.run_action("{578cf025}") # Set LED - sense.set_pixel(0, 1, 0,0,0)
self.logger.info("No Measurement Received {val}".format(val=measurement))
elif measurement < 80: # If the measurement is less than 80
self.message += "DS18B20-1 Measured value is too Low! Measurement is {meas}\n".format(meas=measurement)
self.run_action("{0411875f}") # Set LED - sense.set_pixel(0, 1, 0,0,255)
self.logger.info("DS18B20-1 Measured value < 80 {val}".format(val=measurement))
elif 80 < measurement < 100: # measurement is greater than 80 and less than 100
self.message += "DS18B20-1 Measured value is in the ZONE! Measurement is {meas}\n".format(meas=measurement)
self.run_action("{4842a316}") # Set LED - sense.set_pixel(0, 1, 0,255,0)
self.logger.info("DS18B20-1 Measured value is > 80 and < 100 {val}".format(val=measurement))
else: # measurement > 100: # Else If the measurement is greater than 100
self.message += "DS18B20-1 Measured value is too High! Measurement is {meas}\n".format(meas=measurement)
self.run_action("{7a3f837f}") # Set LED - sense.set_pixel(0, 1, 255,0,0)
self.logger.info("DS18B20-1 Measured value is > 100 {val}".format(val=measurement))
The Conditional Status CODE is:
# Example code to provide a return status for other controllers and widgets.
pass
I’ve added self.logger.info just to see if the code is cycling, and mycodo.log shows that he code is:
2021-06-26 07:18:10,934 - INFO - mycodo.daemon - Mycodo daemon started in 7.081 seconds
2021-06-26 07:18:10,937 - INFO - mycodo.daemon - 70.27 MB RAM in use
2021-06-26 07:18:15,456 - INFO - mycodo.controllers.controller_conditional_49e87ba9 - DS18B20-1 Measured value is 69.575
2021-06-26 07:18:15,513 - INFO - mycodo.controllers.controller_conditional_49e87ba9 - DS18B20-1 Measured value < 80 69.575
2021-06-26 07:19:15,560 - INFO - mycodo.controllers.controller_conditional_49e87ba9 - DS18B20-1 Measured value is 69.575
2021-06-26 07:19:15,617 - INFO - mycodo.controllers.controller_conditional_49e87ba9 - DS18B20-1 Measured value < 80 69.575
BUT, none of the self.run_action("{0411875f}") work; none of the led’s light up.
However, if you replace the self.run_action("{0411875f}") with sense.set_pixel(0, 1, 0,0,255), the respective LED on the SenseHAT lights.
I created a 2nd Conditional Controller with NO Action. However, the Mycodo displays:
Info: Conditional activated without any Actions. Typical Conditional Controller use involves the use of Actions. Only proceed without Actions if you know what you’re doing.
Is there anyway to code the ACTION items, sense.set_pixel(0, 1, xxx,xxx,xxx), so they work?
As a side note I’m trying to learn python as I wrap my head around Mycodo.
Sincerely
Keith