add: forward schedule updates to relays
This commit is contained in:
		
							parent
							
								
									574a384d2f
								
							
						
					
					
						commit
						606f2483a5
					
				
					 5 changed files with 75 additions and 18 deletions
				
			
		| 
						 | 
				
			
			@ -2,8 +2,11 @@
 | 
			
		|||
#include <constants.h>
 | 
			
		||||
#include <endpoints/api_v1_schedules.h>
 | 
			
		||||
#include <logger.h>
 | 
			
		||||
#include <command.h>
 | 
			
		||||
#include <models/junction_tag.h>
 | 
			
		||||
#include <models/junction_relay_schedule.h>
 | 
			
		||||
#include <models/schedule.h>
 | 
			
		||||
#include <models/relay.h>
 | 
			
		||||
#include <models/tag.h>
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
| 
						 | 
				
			
			@ -153,6 +156,16 @@ api_v1_schedules_STR_PUT(struct mg_connection *c, endpoint_args_t *args, struct
 | 
			
		|||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    int *relays = junction_relay_schedule_get_relays_ids(schedule->id);
 | 
			
		||||
    for(int i = 0; relays[i] != 0; ++i)
 | 
			
		||||
    {
 | 
			
		||||
        relay_t *relay = relay_get_by_id(relays[i]);
 | 
			
		||||
        if(relay)
 | 
			
		||||
        {
 | 
			
		||||
            command_set_relay_schedule(relay);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    cJSON *json_tag;
 | 
			
		||||
    cJSON *json_tags = cJSON_GetObjectItemCaseSensitive(json, "tags");
 | 
			
		||||
    if(cJSON_IsArray(json_tags))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue