async def delete_curve( id: int, db: Session = Depends(get_db), api: ServerSession = Depends(get_api) ) -> Any: curve = crud.curve.remove(db, id=id) run(disable=True, db=db, api=api) return curve
async def delete_point( id: int, point_index: int, db: Session = Depends(get_db), api: ServerSession = Depends(get_api) ) -> Any: curve = crud.curve.get(db, id=id) curve = crud.curve.delete_point(db, curve=curve, index=point_index) run(disable=True, db=db, api=api) return curve
async def update_curve( id: int, curve_in: schemas.CurveUpdate, db: Session = Depends(get_db), api: ServerSession = Depends(get_api) ) -> Any: curve = crud.curve.get(db, id=id) curve = crud.curve.update(db, db_obj=curve, obj_in=curve_in) run(disable=True, db=db, api=api) return curve
async def update_status( status_in: schemas.StatusCreate, db: Session = Depends(get_db), api: ServerSession = Depends(get_api) ) -> Any: status = crud.status.get(db) status = crud.status.update(db, db_obj=status, obj_in=status_in) run(disable=True, db=db, api=api) return status
async def update_light( id: int, light_in: schemas.LightUpdate, db: Session = Depends(get_db), api: ServerSession = Depends(get_api), ) -> Any: light = crud.light.get(db, id=id) light = crud.light.update(db, api, light=light, light_in=light_in) run(disable=True, lights=[light], db=db, api=api) db.add(light) db.commit() db.refresh(light) return light
async def update_point( id: int, point_index: int, point_in: schemas.PointUpdate, db: Session = Depends(get_db), api: ServerSession = Depends(get_api) ) -> Any: curve = crud.curve.get(db, id=id) curve = crud.curve.update_point( db, curve=curve, index=point_index, point_in=point_in ) run(disable=True, db=db, api=api) return curve
async def update_group( id: int, light_in: schemas.LightUpdate, db: Session = Depends(get_db), api: ServerSession = Depends(get_api) ) -> Any: group = crud.group.get(db, id=id) for light in group.lights: crud.light.update(db, api, light=light, light_in=light_in) if light_in.on is not None: crud.webhook.fire(group=group) run(disable=True, lights=group.lights, db=db, api=api) db.commit() return group