Closed TeaPot169 closed 1 year ago
There's nothing I can see in the code that would cause this behavior. I've also never experienced it and have used this output type extensively (it was the very first Output created in Mycodo). Perhaps the power outages have caused fileysetem corruption. An uninterruptable power supply is recommended to allow proper shutdown and filesystem dismounting. If you can provide a way to replicate the issue without cutting the power to the Pi, I'll investigate the issue. I would suggest installing the OS/Mycodo on a new SD card and see if the issue persists, which will indicate if it's a filesystem/disk issue.
The only reason I can think why this would happen is if you have something else set up to set your GPIO pins as something other than outputs (i.e. as input). You may be incorrectly using the GPIO State Condition rather than the Output State Condition in your Conditional Controller.
I just updated the descriptions of the Conditions to make this distinction more clear in https://github.com/kizniche/Mycodo/commit/503a7081e5c25a46b26c5d53ef4c51ea4e5d1eb2.
Hi Kyle
Thanks for the response. I do not see a way to replicate it without having the power go off. I do now have a UPS on the system as well as backup power so avoiding the problem in this manner.
Kind regards
On Sun, 06 Nov 2022, 22:34 Kyle Gabriel, @.***> wrote:
I just updated the descriptions of the Conditions to make this distinction more clear in 503a708 https://github.com/kizniche/Mycodo/commit/503a7081e5c25a46b26c5d53ef4c51ea4e5d1eb2 .
— Reply to this email directly, view it on GitHub https://github.com/kizniche/Mycodo/issues/1238#issuecomment-1304887940, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVSF45DUNENBW2WS7NOUNK3WHAB45ANCNFSM6AAAAAARQAK6VU . You are receiving this because you authored the thread.Message ID: @.***>
Is this the cause of the issue: https://github.com/kizniche/Mycodo/issues/1238#issuecomment-1304883771 ?
I went to check the conditional controller, nothing seems out of place there to me, they are working with the output state condition and not GPIO state condition.
This is my code is the conditional controller:
# Example code for learning how to use a Conditional. See the manual for more information.
self.logger.info("Starting humidity measurement")
self.run_loop_count += 1 # Counts how many times the run code has been executed
measurement = self.condition("41d0035d") # Replace ID with correct Conditional ID
self.logger.info(f"Measurement value is {measurement}")
if measurement is not None: # If a measurement exists
self.message += "This message appears in email alerts and notes.\n"
if measurement < 88: # If the measurement is less than 80
self.message += f"Humidity is too Low! Measurement is {measurement}\n"
self.run_action("0d2f939e", message=self.message) # Run actions sequentially
elif measurement > 90: # Else If the measurement is greater than 27
self.message += f"Humidity is too High! Measurement is {measurement}\n"
self.run_action("59a1103a", message=self.message) # Run a single specific Action
I went to have a look at the rest and wondering if this may be causing the problem: I have inputs tracking those outputs (Raspberry Pi GPIO state). But according to my understanding that only measures the state and does not have an impact on set up of the pin. Have deactived those inputs for now to see what impact it has, but I do like using them for the graphical interface.
You are not describing your setup correctly. You are using a Measurement Condition, not the Output State Condition. This is why you are having an issue. There is also no reason to have a GPIO State Input in use. This is the reason for the output not working.
You cannot use both a GPIO Output and a GPIO Input, i.e. a GPIO cannot simultaneously be set as an input and output.
Delete the GPIO Input. Delete the Measurement Condition. Add an Output State Condition to the Conditional Function.
Describe the problem/bug
I have 2 outputs that are controlled by conditional controllers. I have a few other outputs that I turn on and off manually. We experience frequent power outages where I assume the PI shuts down and will restart again. After this the 2 outputs that are automated no longer automatically switch on or off, and when manually trying to switch them they give the following error: 2022-10-27 12:23:22,099 - ERROR - mycodo.outputs.on_off_gpio_b1fcf97d - State change error: The GPIO channel has not been set up as an OUTPUT Traceback (most recent call last): File "/home/pi/Mycodo/mycodo/outputs/on_off_gpio.py", line 175, in output_switch not self.options_channels['on_state'][output_channel]) RuntimeError: The GPIO channel has not been set up as an OUTPUT
If I go into the output and save it, it functions normally again until after another power outage.
A few more details that may be important: The other outputs that are not under controllers switch on/off fine after the shutdown without having to be saved again. I have moved the GPIO pin of the controlled output around on the PI to see if this makes a difference, no success. I have even moved it to the GPIO pin of a previously working output that I used to switch on manually and modified the controller to control this output. The issue then carried over to that output as well...
Any advice on how to possibly add something in that automatically saves the outputs at certain intervals. Or of course a solution that would prevent the issue altogether, any help would be appreciated.
Versions: