kizniche / Mycodo

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

Add duration in sunrise trigger and/or enable Conditional Controller self deactivation #1212

Closed lalebarde closed 2 years ago

lalebarde commented 2 years ago

I am using a sunrise trigger to enable a Conditional Controller. At present time, I need to use a second sunrise trigger to deactivate it 2 hours later.

Either:

  1. Add a duration in the controller activation command
  2. Enable Conditional Controller self deactivation (I have tested to add a command to deactivate itself but it is not taken into account)
kizniche commented 2 years ago

I don't see the issue with using two Sunrise Trigger Functions to accomplish what you're doing. What is the issue?

kizniche commented 2 years ago

I also don't understand what you mean by the second part. Deactivating a conditional controller can be accomplished with the Deactivate Controller Action.

lalebarde commented 2 years ago

At present time, I use two sunrise trigger functions to activate a conditional controller with the first one, and deactivate the same controller with the second one. It would be easier to maintain and avoid mistakes with one sunrise trigger function doing both. Either with a duration in the sunrise trigger function, either with the capability of a conditional controller to deactivate itself, what I have not managed to perform.

kizniche commented 2 years ago

I'm not sure what change you're proposing to the sunrise/sunset Function. It would help if you explicitly state what you are proposing.

Second, like I mentioned, it is possible for a Conditional Function to deactivate itself with the Deactivate Controller Action.

lalebarde commented 2 years ago

I will retry self deactivation. Actually, I don't need more.

But here is my idea, which may still be useful:

image

kizniche commented 2 years ago

There are a lot of issues with timing actions like this. Without a dedicated controller that is always running, any duration event can be interrupted by a reboot or power failure. This is why explicitly setting times for actions is safer, since a reboot or power failure doesn't prevent the second action from occurring.

lalebarde commented 2 years ago

Understood, so it was a bad idea. Thank you Kyle.

kizniche commented 2 years ago

It's not necessarily a bad idea, but it would take a significant code change to make it reliable, whereas you can get the same effect from the current framework by adding an additional controller to be responsible for the action at the end of your duration.