Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable and disable logics #108

Merged
merged 11 commits into from Sep 1, 2016
Merged

Conversation

ohinckel
Copy link
Member

@ohinckel ohinckel commented Aug 20, 2016

(copied from mknx/smarthome#137)

In some cases it makes sense to temporarily disable a given logic and enable later again. At least I would like to disable some logics for some days but enable it again later. And I don't want to comment out the logic and restart SmartHome.py.

This patch contains the following enhancements:

  • enable and disable logics with logic.enable() and logic.disable()
  • check enabled status with logic.enabled property
  • enable and disable logic using el and dl CLI commands
  • show if logic is disabled when using ll CLI command
  • add posibility to enable and disable logics via visu plugin (using { "cmd" : "logic", "name" : "<name>", "enabled" : 0/1 } - the val attribute can also be specified to additionally trigger the logic, as this is the current behaviour)

@psilo909
Copy link
Contributor

will try to review this some day this week, as i highly need that PR for myself

@ohinckel
Copy link
Member Author

Just to quote myself (from the original issue):

I just saw, that the scheduler has already an ˋactiveˋ flag for all tasks. Since each (cron/cycle)
logic is a task in the scheduler we can use this instead of using an own flag in the logic object.

If possible this patch can be changed to retrieve the ˋactiveˋ flag from the scheduler for a
given logic to show it enabled or disabled. The methods to change the flag could simply tell
the scheduler to activate or deactivate the logic task.

But I'm not sure if this is a clean solution. Suggestions and ideas are welcome.

Using the scheduler's active flag instead would completely remove the logic execution/trigger (which would be better since it is not anymore in the task/run queue of the scheduler) but needs more coupling between scheduler and logic class (because enabling/disabling would require a scheduler.change() and retrieval of the active status of a logic access to the schedulers tasks).

The current implementation triggers the logic in any case (enabled or disabled) and will just skip the actual logic execution.

I'm still not sure which is the best implementation. So suggestions are welcome!

@cstrassburg cstrassburg merged commit bb5c87e into smarthomeNG:develop Sep 1, 2016
@ohinckel ohinckel deleted the dev-logic-switch branch September 4, 2016 19:55
cstrassburg added a commit that referenced this pull request Dec 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants