I would like to regulate the humidity via a PID controller.
For this I got myself a humidifier and a dehumidifier.
My problem now is that the dehumidifier has a push button to which I always have to send an impulse that it goes on or off.
My consideration now was that I should use a relay or transistor which I can then control with Mycodo.
But now I can’t find the function how to do this in Mycodo.
So if my humidity is too high, Mycodo should send a 2s pulse to switch the dehumidifier on. Once the desired value has been reached, Mycodo should send a 2s pulse at the same output switch the dehumidifier of.
The immediate issue I see with what you described is this: how will you know if the humidifier is already on or off when you’re assessing whether to turn it on or off?
I can not say that.
The dehumidifier does not have its own logic to switch itself on or off, it is connected to 230v and then switched on and off using the button. What I could do to get a safe state is to switch the 230V via a relay and then send an impulse to switch on the dehumidifier via a second output with 5sec delay, to switch off the dehumidifier I only need to turne off the 230V relay.
In that case, then you could use a Conditional Controller Function that runs periodically to check the humidity and then manipulate the outputs accordingly. Here is some pseudocode for the logic of the controller (not actual code):
That’s not an error, it’s a warning, and it’s merely telling you the pylint score was less than 10/10. The pylint output appears below the code review that’s returned when you save.
Duration is set in the Action settings, not in the function. You would still just execute self.run_action() with only the action ID as the sole parameter.
run_action() does not return anything. To do this would execute them all at once, which I don’t believe is desirable. You only execute run_action() when you want that particular action to run.
run_action() only accepts the action ID. You have the proper syntax in the first part you use run_action(), but you only want to call it when you want that action to actually run.
I also don’t see the proper indentations on the if/elif section. You can enclose the code in triple-bactics to indicate it’s code. You can put the language after the top backtics (e.g. “```python”) to have it use Python syntax hilighting.
but unfortunately it doesn’t work yet in the logs I get the following error
2022-01-10 02:09:20,473 - ERROR - mycodo.controllers.controller_conditional_2f24eb4b - Exception executing Conditional Statement code
Traceback (most recent call last):
File “/var/mycodo-root/mycodo/controllers/controller_conditional.py”, line 184, in check_conditionals
self.conditional_run.conditional_code_run()
File “/home/pi/Mycodo/mycodo/user_python_code/conditional_2f24eb4b-4866-4103-a9bd-9706e86225b9.py”, line 28, in conditional_code_run
run_action(“e7200dfe-8ef3-411b-bc56-22793fe636a6”)
NameError: name ‘run_action’ is not defined
It needs to be self.run_action(). Look below the Conditions and Actions and you will see the exact function call that needs to be made to query the Condition or execute the Action from the Conditional Statement. Also, don’t paste the entire pylint output, only the code in the Conditional Statement text box is needed. Pasting anything else will only serve to confuse other users, as they may copy the entire code into their Conditional Statement trying to mimic what they see here.
Hey, thanks for the help! I’ve got it all working now. Now I just have the next problem. At the moment a measuring cycle is 60sec for, if the humidity is too high and mycodo should turn the air dehumidifier on, it switches it on and off every 60sec.
I could now increase the 60sec but I hope that it can be done differently.
But now I still have the question of whether I could do the whole thing with a custom output as I would like to control my VPD via a PID controller and need the dehumidifire as an output.
You’re probably not going to have much success making an output work properly since your On command is not instantaneous, and thus will experience issues the moment an Off command occurs while your On command is in the sleep period. This is why you need to have specific logic controlling both On and Off at the level of the controller handling its operation (i.e. the controller operates at a pre-defined interval and will only either turn it On or Off according to your specifications).