add: macro endpoint for execution
This commit is contained in:
parent
01ffb1d58d
commit
d3fd48b35a
9 changed files with 110 additions and 26 deletions
src/models
|
@ -123,6 +123,28 @@ macro_action_get_for_macro(int macro_id)
|
|||
return macro_action_db_select(stmt);
|
||||
}
|
||||
|
||||
int
|
||||
macro_action_execute(macro_action_t *macro_action)
|
||||
{
|
||||
schedule_t *schedule = schedule_get_by_id(macro_action->schedule_id);
|
||||
if(!schedule)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
relay_t *relay = relay_get_by_id(macro_action->relay_id);
|
||||
if(!relay)
|
||||
{
|
||||
free(schedule);
|
||||
return 1;
|
||||
}
|
||||
|
||||
schedule_free(relay->schedules[macro_action->weekday]);
|
||||
relay->schedules[macro_action->weekday] = schedule;
|
||||
|
||||
return relay_save(relay);
|
||||
}
|
||||
|
||||
void
|
||||
macro_action_free_list(macro_action_t **macro_actions)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue